-
Notifications
You must be signed in to change notification settings - Fork 849
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
Make it easier for agent extensions to get the autoconfigured Resource #3924
Comments
Hmm this is a good point. The intent was that the autoconfigured SDK would be available within an app for where Resource is needed. I wonder if the agent should be providing an API for accessing the SDK it built. Would you be able to provide the code you have that references the Resource to understand the pattern fully? With the new knobs perhaps there is an alternative just want to check. |
I might recall the code copied resource attributes into env vars? In that case, using a resource customizer may be a reasonably clean solution. While ordering considerations may come to mind we have the broader issue anyways of adding the concept of ordering to all the SPIs. |
I'm looking at the agent extension examples and don't understand why an extension would need access to the resource. Curious if you can provide a concrete example @breedx-splk. |
I did find the AgentListener interface, and see a couple of usages of it here. Going off @anuraaga's idea of the agent providing an API to access the SDK it built, we could extend agent listener to include access to
Not sure if it matters that |
Splunk has several extensions that need access to the Resource. Jason can provide links to the concrete examples in our distro when he's back from the holidays, I think. |
I found another code affected by the change open-telemetry/opentelemetry-java-contrib#139 But in this case I feel the root cause is the inability for even a normal SDK user to be able to use the SDK's resource automatically when creating a sampler which could be remedied with the ability to register a factory instead. |
@jack-berg Thanks for finding Splunk's references - indeed, for AgentListener, it seems to make sense to have it provide the SDK, assuming it doesn't want to provide it statically. I guess in principle, anything that uses Resource needs to be executed after autoconfiguration as that is where we create the Resource. For cases like the AgentListener and Sampler, we'll need to find ways of accomplishing that. One other usage in Splunk is this logs thing But not thinking too deeply about it yet given it's logs :P |
The problem with adding |
It seems convenient, not necessary, that we initialize the OTel SDK in an AgentListener. What about adjusting the startup sequence to be:
|
That would work too, I think - both instrumentation and splunk repos don't really contain anything that desperately needs to be run before OTel initialization. |
Thanks for powering thru some of this while I was afk. :)
This seems workable. It's a little goofy tho because Unfortunately, however, it is complicated by the fact that
|
@breedx-splk Yeah the main motivation of the |
Yeah makes sense. I'd be ok with the two-arg version as a stop-gap measure. |
I'd also like access to |
@jsuereth If you're using autoconfigure, then |
Opened a ticket in I'll try to get that implemented before the next release, so that we can merge the PR to remove deprecated autoconfigured methods. |
@breedx-splk can we close this ticket now that |
Absolutely. Thanks for the great work (and for this reminder!) |
just as a heads up for anyone looking at this issue, as a workaround, you can use |
Now that
OpenTelemetryResourceAutoConfiguration.configureResource()
is deprecated, it's difficult for agent extensions to get the resource.The javadoc for the deprecated
configureResource()
says to useAutoConfiguredOpenTelemetrySdk.getResource()
(an instance method). This suggest that a user who is migrating away from the deprecated call should use a newAutoConfiguredOpenTelemetrySdk
, something like this:But that doesn't seem right -- doing this in multiple places could lead to multiple instances of the sdk getting created, possibly with different configurations/customizations.
There should be a clearer and consistent way to get the autoconfigured Resource.
The text was updated successfully, but these errors were encountered: