Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Allow user to bypass trace id generator and provide it externally. The use case I have for this is the AWS XRay extractor running in
ALB
mode. As described below, we can't insert a parent span in our use case, as our upstream only provides a trace id, but does really implement tracing. To provide loose-coupling an external trace id can be provided via Context.Use case
We're using this library to push traces to AWS X-Ray with the help of the forked library to accomodate trace id format that AWS uses. We are using AWS Load Balancer as the entry-point. AWS LB provides
X-Amzn-Trace-Id
that can be used for request tracing and has the format that XRay expects. It's very convenient to have a single correlation id that can be used across the whole system (load balancer access logs, X-Ray, application logs, etc). Having separate lookalike ids causes only confusion.In a typical scenario, extractor would get trace id and parent span id. However, LB is not fully integrated with X-Ray – it does not communicate a trace to X-Ray. The header is also not in the expected format – only trace id is present with no span id (e.g.
X-Amzn-Trace-Id: Root=1-63441c4a-abcdef012345678912345678
). I have tried to deterministically generate span id based on trace id for the root span, this however caused only issues – since the root span has been never reported, X-Ray did not display traces correctly wrt. to timing or response statuses. That's why an external trace id is needed.