On how to use extensions #6350
-
Hey there, I am currently integrating the opentelemetry javaagent, which actually works out of the box. Great job! What I want to do now, is to create an extension that would add additional attributes to a span that are more business specific and part of the incoming request. E.g. adding attributes from the request to the span in order to give more contextual information in Tracing. From the examples I've seen it's not that clear to me on how I would access attributes from the request that is currently being processed? Hope it's clear what I am asking for. Best |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
Hey @MALPI , |
Beta Was this translation helpful? Give feedback.
-
If you only need to add request parameters as span attributes then https://opentelemetry.io/docs/instrumentation/java/automatic/agent-config/#capturing-servlet-request-parameters could help. |
Beta Was this translation helpful? Give feedback.
Hey @MALPI ,
For simple use cases, you can just use OpenTelemetry API in your application directly -- just get the current Span and set whatever attributes you need. This will be a part of your application code, and you should have no problems when accessing the request attributes (of whatever framework/library you're using).
If you absolutely have to avoid modifying your application in any way, this can be achieved with extensions too, but it will be considerably more difficult, as it will require implementing a custom instrumentation that does that.