[feature request] support extensible tag serialization #6052
Labels
enhancement
New feature or request
pkg:OpenTelemetry.Exporter.OpenTelemetryProtocol
Issues related to OpenTelemetry.Exporter.OpenTelemetryProtocol NuGet package
Package
OpenTelemetry.Exporter.OpenTelemetryProtocol
Is your feature request related to a problem?
It would be useful to better support the serialization of types not directly supported by the OTel protocol to tags.
Currently types not supported in
TagWriter.TryWriteTag
are converted to strings. While this is better than nothing, we loose opportunities to convert objects into rich key/ value pairs. Such an approach would lend itself well to supporting wide events as users would no-longer have to serialize objects to tags by hand and could instead rely upon library code to do this.The motivation for such an enhancement is discussed here: #5718.
The difference between this issue and the prior linked issue is that instead of asking this project to build + support such a serializer, this issue asks that
TagWriter
is simply made to be extensible, in order to support any custom serialization of types not supported natively by Otel such as:MyObject
List<MyObject>
DateTime
What is the expected behavior?
I would expect the changes might be of this form:
TagWriter
TagWriter
instanceWhich alternative solutions or features have you considered?
The alternative is that you can provide an extension method to support serialization of unsupported objects. But this has several drawbacks around performance:
Activity
is relatively slow, due to casting/ boxing of structs and acquiring/ releasing the mutex that synchronizes adding tagsobject
incurs additional allocationsstring
s ahead of time doesn't allow for the pooling of buffers, further increasing memory allocationsAdditional context
No response
The text was updated successfully, but these errors were encountered: