OTEL: Update Operation Name to Match Frontend Usage#1033
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Updates the OTLP → Datadog span name resolution so OTEL-instrumented AWS Lambda invocation spans are reported with an operation name the Datadog Serverless UI recognizes, preventing “0 traces” in the invocation table for Extension-forwarded OTEL traces.
Changes:
- Thread the OTEL
InstrumentationScopeintoget_otel_operation_name_v2. - Override operation name to
aws.lambdaforSpanKind::Serverspans emitted byopentelemetry.instrumentation.aws_lambda. - Extend/add unit tests covering the new AWS Lambda-specific naming branch and regressions.
The previous comment said "root Lambda invocation span" but the code only checks SpanKind::Server + instrumentation scope name, which does not verify root-ness — a Lambda span can have a remote parent when the upstream caller (e.g. API Gateway, Step Functions, another Lambda) propagates trace context. That is still the Lambda invocation span we want to rename to aws.lambda, so the behavior is correct; just clarify the comment to avoid implying a root guarantee that the predicate doesn't enforce. No code change.
duncanista
reviewed
Apr 29, 2026
duncanista
approved these changes
Apr 29, 2026
duncanista
left a comment
Contributor
There was a problem hiding this comment.
Approved, left a comment
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.
Overview
OTEL Lambda spans emitted by the
opentelemetry.instrumentation.aws_lambdaPython instrumentation come through the Extension withname: server.request— the OTEL semantic-convention generic-server fallback. The Datadog Serverless page invocation table filters by:server.requestmatches none of those, so OTEL Lambda functions show 0 traces on the Serverless page even though the spans land in APM correctly.This PR overrides the operation name to
aws.lambdafor OTEL Lambda root-invocation spans on the Extension side. Detection is gated on the instrumentation scope beingopentelemetry.instrumentation.aws_lambdaAND span kind beingServer, so other spans in the trace (HTTP clients, internal spans, custom spans) are not touched.What Changed
bottlecap/src/otlp/transform.rs—get_otel_operation_name_v2:InstrumentationScopereference through to the operation-name resolverlib.name == "opentelemetry.instrumentation.aws_lambda"ANDspan.kind == Server→"aws.lambda"libparameter was already available at the call site inotel_span_to_dd_span; the change just plumbs it intoget_otel_operation_name_v2Why on the Extension (vs. logs-backend)
The complementary path — spans arriving through the OTLP endpoint without going through the Extension — is handled by https://github.com/DataDog/logs-backend/pull/134974, which performs the same
server.request → aws.lambdaoverride inSpansOTLPProtobufPayloadParseralong with the broader OTEL → Datadog field remap (cloud.resource_id → function_arn,faas.invocation_id → request_id, etc.).Doing the override on the Extension side for the Extension-forwarded path is preferred because:
aws_lambdainstrumentationaws.lambdaname, avoiding "named differently in different places" bugsTesting
Existing
test_otel_operation_name_*extended to assertserver.requestis still produced when the lib name does not match the AWS Lambda scope (regression coverage for the threading change).New
test_otel_operation_name_aws_lambdacovers three cases:Serverkind →aws.lambdaInternalkind (handler child spans) → unchanged (SPAN_KIND_INTERNAL)handler) +Serverkind → unchanged (server.request)Companion PRs
request_idfallback in the trace list hook + widened log queries that match OTLP-ingested logs alongside Datadog Forwarder logsTogether with this PR, OTEL-instrumented AWS Lambda functions (both endpoint-only and Extension-forwarded) work end-to-end on the Datadog Serverless page: trace discovery, invocation correlation, function-level log discovery, error filter, log count.