fix: keep manual-instrumentation traces (honor faas.invocation_id; document AWS_LAMBDA_EXEC_WRAPPER)#66
Draft
parker-edwards wants to merge 2 commits into
Conversation
Spans created from a custom ActivitySource/Tracer (a scope not in the recognized AWS Lambda instrumentation list) had their faas.invocation_id ignored: process_trace_request only extracted the invocation id from spans in recognized Lambda scopes. When no id is found and the Runtime API proxy fallback is unavailable, the receiver discards the trace ("/v1/traces has no invocation IDs, discarding trace").
Extract faas.invocation_id from spans in any scope for invocation correlation. The handler-span rewrites (rename, kind, reparent) stay limited to recognized Lambda scopes, so non-Lambda spans are correlated but otherwise left untouched.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The Manual Instrumentation steps did not mention AWS_LAMBDA_EXEC_WRAPPER=/opt/wrapper, which is required to enable tracing (it routes the Runtime API through the extension so spans can be correlated to the current invocation and enriched). Without it, traces are discarded with "no invocation IDs" unless every exported span already carries a faas.invocation_id. Add it as an explicit step. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
6fca404 to
8c27540
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Problem
There are instances where individuals using the manual layer (
dash0-extension-manual) with hand-rolled OpenTelemetry instrumentation in .NET see every trace dropped:In one example, a handler span is created from a custom
ActivitySource("<service>.Handler") and explicitly setsfaas.invocation_id— yet it's still discarded.Test case environment details
This was detected in an environment with the following attributes:
arn:aws:lambda:eu-central-1:115813213817:layer:dash0-extension-manual:11)Root cause
The extension needs an invocation ID to keep a trace, and it has two ways to get one — both missed here:
process_trace_requestonly readsfaas.invocation_idfrom spans whose instrumentation scope is on the recognized-Lambda allow-list (is_lambda_instrumentation_scope). A customActivitySourcescope isn't on the list, so the explicitly-set attribute is ignored.get_current_invocation_id) is only populated when the Runtime API proxy runs, which requiresAWS_LAMBDA_EXEC_WRAPPER=/opt/wrapper. The Manual Instrumentation docs never mention that variable, so a customer following them has the proxy inactive.With both missed, the receiver discards the trace.
What this PR does
1. Docs — make the wrapper requirement explicit (the primary fix).
Adds
AWS_LAMBDA_EXEC_WRAPPER=/opt/wrapperas a required step in the Manual Instrumentation section, cross-linking the existing Required config note. This is what unblocks the customer: with the proxy active, the fallback stamps every invocation's traces with the AWS request ID regardless of span scope.2. Code — honor
faas.invocation_idfrom any scope (defense-in-depth).process_trace_requestnow extractsfaas.invocation_idfor invocation correlation from spans in any instrumentation scope, not just allow-listed ones. The README documentsfaas.invocation_idas the correlation attribute with no scope caveat, so this change should protect against cases where we silently drop spans that have it set via manual instrumentation.Why the code change is safe and narrowly scoped
handler, set kindInternal, reparent to the synthetic root) stay limited to recognized Lambda scopes. Non-Lambda spans are correlated but otherwise left untouched — their trace shape is preserved.faas.invocation_id, so existing auto-instrumentation flows are unaffected; the only behavior change is that an explicitly-set ID is now honored instead of dropped.Testing
cargo fmt --all --check— cleancargo test --all-features— 267 passed, 0 failedprocess_trace_request_honors_invocation_id_in_non_lambda_scope_without_rewrite(custom.Handlerscope → ID extracted, span not rewritten) andprocess_trace_request_non_lambda_span_without_invocation_id_adds_no_ids.🤖 Generated with Claude Code