-
Notifications
You must be signed in to change notification settings - Fork 821
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
Add or change resource detection to be synchronous #2912
Comments
I had the same issue and ended up implementing a sync api for the detectors and implemented a few sync detectors with the api. I can upstream it to the core repo if there is interest. This will mean that users will have to choose between the following alternative:
Options 1, 3, 4 can probably be used with (--require). Maybe we can have some environment variable to instruct the |
What about packing the resource into a Promise/Future? This one can be created sync and it's immutable. |
This would be a good starting point for sure, nobody needs to reinvent the wheel!
What would be the issue with having only sync detectors?
As far as I understand, that's what we have right now, looks like it's accepted as "OK" behaviour but having some issues (you loose some insights on application startup, might not work well with shortlived processes, lambdas ,...)
Looks like a good solution, except the conflict with the spec. How are other language SIGs implementing that? I think they should have similar issues with resource detection on startup? I can not imagine that this is unique to JavaScript.
Also, this sounds like something that's not unique to javascript? |
It is not always possible. If the detect function involves some API call then it cannot block in JS and has to be awaited. As far as I understand it, This would mean that cloud providers' detectors will not be able to be used when sync resource detection is necessary. א
Where do we have it?
I only investigated it in ruby, which blocks the thread until resources are resolved. This is not possible in JS.
Not sure if it's implemented in any other SDK. The RUM SIG need it to store things like session id in the resource which can change over the lifetime of the application. We talked about adding it in the SIG last week, but there was no progress yet. I have a feeling it will mess up backend logic. |
The resource is currently part of the If we can make it work, I think this is the best option. |
One example is GCP where it is required to call the gcp metadata server to get some resource attributes.
At the SIG meeting we talked briefly about this. At least ruby, java, python all simply block startup.
Most other SIGs are able to block execution. Those that aren't (I think erlang?) just decided to use sync only. We are the only one that has an async startup process. |
I have an idea here. Rather than packing the whole Resource into a promise, we can add a promise to the Resource for just the async attributes. Synchronous detectors can be set in the attributes when the Resource is created. This way there is no breaking change, SpanProcessors can continue to access the synchronously detected attributes on the resource. Exporters can await the resource detectors if they want to. Working on a prototype for this in #2933 |
This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 14 days. |
This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 14 days. |
I was thinking that for node 19+, instead of In other words:
Sadly, Node19 is not available for AWS lambdas, so I guess I have to go down another route. From what I understand, if the SDK initialization is async, then at least the auto-instrumentation needs to be loaded synchronously before the first async call ? Is that correct ? If so, the documentation seems to be lacking |
That can probably work for 19+ but we won't be able to rely on it as the "default" solution for a long time.
Yes that is correct. Any updates to the documentation would be welcome. |
Actually there is no need to wait with instrumentation creation until SDK has finished resource detection (see #3146). So maybe we should fix this instead of documenting the bug. |
#2933 was auto closed. I think there were a few outstanding issues but where do we stand overall on this approach? Do we still need this? |
Is your feature request related to a problem? Please describe.
As of now resource detection is happening asynchronous, this means that spans that are generated early at application start might be lost (e.g. lambdas) or the whole application needs to be wait for the detection promise to fulfill, something like
This is especially problematic when the SDK is loaded in a "don't touch my code" manner, e.g. via
node --require tracing.js
, as described in the Getting Started, used by the operator for autoinstrumentation or suggested at #2891: there is no way to "wait" for resource detection to finish before the application runsDescribe the solution you'd like
via #2891 (comment) from @dyladan:
The text was updated successfully, but these errors were encountered: