-
Notifications
You must be signed in to change notification settings - Fork 896
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 possibility to set parent span context after span creation #3781
Comments
You could add a link from the root span of Changing the parent after span creation is problematic, as this can effectively change the trace id of the span and so would also make it necessary to also change the trace id of all children spans that might have been created before the change took place. |
Following @pyohannes's remark, the OpenTelemetry specification has support for adding a link to another span after it starts via While we have heard reasons to defer various aspects of determining a span (e.g., its links, its attributes, even its name), parenting a new span means making a head-sampling decision. While we are aware of Jaeger's support for deferring a sampling decision until the first child, we believe this rarely-used feature should be accomplished in some other way. In addition to #2918, is seems that to respect sampling and span links it is necessary to support exporting spans that were not sampled, as discussed in #2986. I will close this in favor of those two issues. I would like to see us adopt a solution in which your two accessory spans are started with a "record-only-with-span-link-sampling" configuration; your spans will not sample unless they are linked with a sampled trace, which you'll do by calling Since I see this ultimately as a sampling-related problem, you are invited to join the weekly Sampling SIG, which is Thursdays at 4PM UTC. |
@jmacd @pyohannes Thanks you very much for the detailed responses! Linking can definitely tackle this use-case. |
What are you trying to achieve?
Since the
SpanContext
is immutable, the parent context can only be set at the span creation time and not after.This means that during the creation of the span, one already needs to have the trace context in order to create the new span with the corresponding parent context. Though, in case one does not have the context yet and to get it after the span creation, the span cannot point to the correct parent span.
Example use case
Under the normal circumstances (e.g. HTTP request or message broker), the trace context can be put into the headers by the
client
or theproducer
which theserver
or theconsumer
can then get it out and propagate the trace further. However for serverless applications talking to each other via some cloud-managed infrastructure, this is not possible.In an example scenario as follows
Lambda1 -> S3 bucket -> Lambda2
, whereLambda1
puts an object into aS3 bucket
that triggersLambda2
, one cannot simply propagate the context under one trace.The trace context is to be put into the metadata of the
S3 object
by theLambda1
. TheLambda2
needs to have this context and start it's own spans on top it. SinceS3Event
do not support metadata propagation,Lambda2
has to retrieve the object from theS3
first.This means that
Lambda2
will going to have 2 initial spans:client
span to get the object from theS3
which has the root span ofLambda2
as a parent spanAfter 2 spans, one finally has the actual trace context. However, the 2 spans are already created and are immutable. This means that if one were to propagate the trace, these 2 spans would belong to a complete different trace that makes the trackability of the business flow a lot more difficult.
What did you expect to see?
The entire flow described above represents (or should represent) only one trace and therefore, it would be great to somehow set it up that way. This would highly ease querying of the spans belonging to a particular business logic.
The text was updated successfully, but these errors were encountered: