opentelemetry-java icon indicating copy to clipboard operation
opentelemetry-java copied to clipboard

Being able to associate resources with spans and not only a with a tracer

Open lb-actoron opened this issue 3 years ago • 2 comments

Is your feature request related to a problem? Please describe.
I would like to create spans and associate custom resources to that span. Currently I cannot call setResource() on the span builder to achieve this. Instead internally the resource associated with the tracer is used and can only be overridden on tracer level. In my case I do not have microservices but kind of virtual processes (not physical ones represented as threads) and do not want to create separate tracers for each virtual process (could be thounsands). Instead I would like to share the tracer and just adapt the resource on span creation.

Describe the solution you'd like.
I would like to have a setResource() method on span builder to set the resource used.

Describe alternatives you've considered.
As a workaround I am using setAccessible() on the resource field of a span.

lb-actoron avatar Jul 28 '22 12:07 lb-actoron

This would require a significant change to the specification to make this happen. Please open an issue there if you want this to move forward.

jkwatson avatar Jul 28 '22 15:07 jkwatson

@lb-actoron +1, and in addition to being able to set the resource, in fact, I also hope that the current resource can be easily obtained

CoderPoet avatar Sep 15 '22 15:09 CoderPoet