Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[feature request] support extensible tag serialization #6052

Open
djluck opened this issue Jan 8, 2025 · 0 comments
Open

[feature request] support extensible tag serialization #6052

djluck opened this issue Jan 8, 2025 · 0 comments
Labels
enhancement New feature or request pkg:OpenTelemetry.Exporter.OpenTelemetryProtocol Issues related to OpenTelemetry.Exporter.OpenTelemetryProtocol NuGet package

Comments

@djluck
Copy link

djluck commented Jan 8, 2025

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
  • etc.

What is the expected behavior?

I would expect the changes might be of this form:

  • A public interface is extracted from TagWriter
  • A convenient way is provided to override the default TagWriter instance

Which 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:

  • Adding tags to Activity is relatively slow, due to casting/ boxing of structs and acquiring/ releasing the mutex that synchronizes adding tags
  • Boxing of struct types to object incurs additional allocations
  • Converting objects to strings ahead of time doesn't allow for the pooling of buffers, further increasing memory allocations

Additional context

No response

@djluck djluck added enhancement New feature or request needs-triage New issues which have not been classified or triaged by a community member labels Jan 8, 2025
@github-actions github-actions bot added the pkg:OpenTelemetry.Exporter.OpenTelemetryProtocol Issues related to OpenTelemetry.Exporter.OpenTelemetryProtocol NuGet package label Jan 8, 2025
@TimothyMothra TimothyMothra removed the needs-triage New issues which have not been classified or triaged by a community member label Jan 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request pkg:OpenTelemetry.Exporter.OpenTelemetryProtocol Issues related to OpenTelemetry.Exporter.OpenTelemetryProtocol NuGet package
Projects
None yet
Development

No branches or pull requests

2 participants