-
Notifications
You must be signed in to change notification settings - Fork 836
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
Resource auto-detection and SDK initialization. #1410
Comments
This is an issue that has been tickling the back of my brain as well. The async nature of resource detection is unfortunate. Previously floated ideas to fix this:
I had not considered the idea of a resource detector being a span processor. This breaks the "one resource per tracer provider" mandate of the spec because you could use the same span processor with multiple tracer providers, but it does allow for the use-case which multiple tracer providers is meant to solve (different resources per-tracer-provider). @obecny @mayurkale22 WDYT about that proposal? That would allow us to make the SDK package init completely sync which simplifies setup as well. |
I will copy paste my response in PR From I user perspective I want to make this
To achieve this I think we could delegate to start detecting resources in some "global object whatever we call it , resource detector, resource provider, etc.", it can be also attached to opentelemetry something like "opentelemetry.getResource which will be an observable in case the resource will change after some time - this in fact might be a true) |
That code example looks very reasonable to me
Resource does not change over time. It is read only.
Would love to see a PR of what it looks like. I tried to throw together something similar locally and ran into the problem that our SpanProcessor pipeline is completely sync, which is a problem. In order to fix this we need to make it so span processors can perform async operations. |
Could always do a deep copy of the "detected resources" object between providers, with some sort of lock to make sure that resource detection completed or timed out. That said, I'm having a hard time thinking of a situation where two providers in the same process would have different detected resources. |
Join the club. It is in the spec, so we don't really have a choice here unless we feel like crusading against it. @mwear has also harbored similar sentiments. I recently was going to do just this, but because tracing is so near GA I didn't want to stir that particular pot. |
Fixed in #1400 |
Is there errata about a 1:1 relationship between tracer providers and resources? Because it seems like you could be spec compliant by simply having the resource processor act like a caching layer - each provider would get a separate instance of the resource processor (so you aren't reassigning anything) but it'd pull from the same pool of values.
This doesn't seem to preclude the behavior I just described - admittedly, I'm not the one trying to implement it, but does my logic seem off? |
Just in case it got lost in the shuffle, #1400 has been updated with a variation on 1 from #1410 (comment)
|
but it doesn't affect exporter, once the span or metrics goes to exporter it already has correct resource - not a promise |
Hi! I'm writing this to summarize an issue I've had in putting together workshop/training content for OpenTelemetry JS and how Node SDK initialization works. Right now, if you initialize a new
NodeSDK
, you are required to do so asynchronously - and my understanding is that this is due to resource detection, as it happens async as well. Unfortunately, this leads to some vaguely ugly code -@obecny opened a PR (#1400) to allow for disabling resource auto-detection, which would allow for synchronous usage of the SDK, but this is mostly a band-aid around the core issue, which is that resource detection happens async.
I understand that the process can't be made synchronous, but I wanted to ask why it needed to be something that end users would need to be so cognizant of. Would it be possible, for example, to move resource auto-detection to the processing pipeline, so that provider/sdk initialization isn't affected by it? Something like
provider.addSpanProcessor(new ResourceDetector({...}))
, and maybe even block processing until resources have been detected/a timeout occurs?The text was updated successfully, but these errors were encountered: