How to set custom attributes at child spans? #5090
-
I have a common problem where I want to add custom attributes to spans generated by external libraries. Some attributes can be known ahead of time, but others must be generated when the span is being created (e.g. file and line of the caller function). Example of instrumentation libraries where I have this problem
This is different from https://github.com/open-telemetry/opentelemetry-go-contrib where my code executes under the framework and I can simply get the span from context and add attributes. What would be the proper way to go about it? Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
You can use SpanFromContext to retrieve the current span from a |
Beta Was this translation helpful? Give feedback.
Yes, the approach you describe is what I mentioned.
Within your transport, you would have something like this: