-
Notifications
You must be signed in to change notification settings - Fork 842
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
Handling of async resources #1533
Comments
Would be interesting how other techs have solved this problem. I assume GCP resource detection via HTTP call is not JS specific. I agree with @dyladan that resources and spans should be decoupled. Each export message needs resource, not each span or each metric. |
Asking this question in the maintainers gitter channel |
My 3 cents: Imho exporter should not care about resolving anything - whatever comes it will be send to the backend and nothing more. The point 5 should be changed to |
Making the span processor await the promise reintroduces the same problem that the export pipeline is now async. Calling |
Recommended by @trask in the maintainers channel: Make the Resource a lazy wrapper around deferred resources and make |
|
But it doesn't resolve any of our problem. It doesn't matter what will be the interface of resource. If the resource is async it needs to be resolved somewhere somehow at some point. Attaching resources at the very beginning to the span is imho wrong then. I would say that the span should be possible to serialize at any moment. Spec requires us to attach resource to every exported span, how we do this it is up to us. Having said that the most natural place for me for resolving the async resources is the span processor. Moreover keeping this logic in span processor might even give people ability to update resources periodically or on demand adding its own logic to it - if they want that for any reason. Imagine the situation when resource is used to read the version of certain service. The service might get update and the node will be running for 1 year without any restart. What would be more valuable reporting version of this service for the whole year the same or updating the version. Now if we move the resources to the span processors someone can implement an easy mechanism for refreshing resources every 5 minutes and then simply attaching the new resolved resources into spans. I'm not even talking about situation when certain resource is not available and then become available again in 5 minutes. This all circumstances leads me to conclusion that the resources should be refreshed and kept in processors as it feels the best place there, whereas exporter doesn't need to really care about all the things except converting and sending data. |
@obecny Resource is imutable according to spec. Therefore your usecase of the service update doesn't apply to resource. Such information needs to be transferred by some other mechanism. In general the resource is needed together with the spans as they identify the thing monitored. a span alone has just a traceId/spanId, only the resource give the context to which thing a span belongs. |
@Flarna, do you mean that if a span starts off with resource unset, then, according to the spec, it cannot be added at the exporter? |
@rauno56 Yes, the exporter uses the Resource "captured" by span at start. If a resource element is added/changed later it's not updated for in progress spans. Besides that backends may assume that a specific set of resources is a unique description of a process. So they may cache it somehow or use it as a key in a map of processes. |
I guess I lack certain knowledge about the topic to continue the argument:
As a wild hypothetical, I know it might be far fetched(so please tell me if I'm totally outside of the ballpark) depending on the answers to the above questions one could imagine we have an API for the instrumentations to ask for the "current immutable resource"(which we could replace as the resource changes or new things are discovered) or have that internal and only attach it to otherwise resourceless spans during export. |
@rauno56 We've add a discussion about this and explained few things there: https://cloud-native.slack.com/archives/C01NL1GRPQR/p1623080369097000 |
Currently the
So no chance to update spans. Technically you could recreate your Clearly this could be changed but that's a spec topic. |
I think this is resolved by #3460 🙂 |
I am creating this issue in the JS repo so we can discuss, but I believe this may also require a spec change.
In JS, in some cases it is impossible to gather resources synchronously. For instance in GCP, it is required to make a call to a remote endpoint, which cannot be done synchronously. For this reason, our resource detectors are asynchronous. Currently, the resource is provided to the TracerProvider at construction time, which means resource detection must complete before a TracerProvider is created. This means that program startup must be made asynchronous for anyone that wants resource detection.
There is currently a PR to solve this by making the resource a Promise, which is awaited before sending the span to the export pipeline. This solution allows SDK creation to be synchronous, but introduces other problems:
There have been several suggestions for ways to "fix" this issue, but each of them has their own problems
I would prefer solution 5. To me, it is the most straightforward way to ensure resources are included in the export without making the export pipeline async and allowing SDK creation to be sync. Unfortunately, this would violate spec and we would need to request a spec change.
/cc @mwear and @obecny because the async SDK startup issue was originally raised by lightstep
/cc @mayurkale22 as the other maintainer
/cc @open-telemetry/technical-committee @open-telemetry/specs-approvers for any guidance here on what we may be able to achieve within limits of spec, what spec may need to be updated/changed, or if we may be allowed to implement one of the solutions which I identified above as potentially spec-noncompliant.
The text was updated successfully, but these errors were encountered: