fix(serverless): add base_service tag for serverless [backport #17238 to 4.6]#17437
Closed
zarirhamza wants to merge 1 commit into4.6from
Closed
fix(serverless): add base_service tag for serverless [backport #17238 to 4.6]#17437zarirhamza wants to merge 1 commit into4.6from
base_service tag for serverless [backport #17238 to 4.6]#17437zarirhamza wants to merge 1 commit into4.6from
Conversation
## Overview Fixes `_dd.base_service` handling for AWS Lambda environments in the Python tracer, enabling service remapping rules to work on Lambda spans and ensuring trace stats contain a meaningful `base_service`. ### Changes **`ddtrace/internal/settings/_config.py`** — When `DD_SERVICE` is not configured and the tracer is running in AWS Lambda, `config.service` is now automatically set from `AWS_LAMBDA_FUNCTION_NAME`. This mirrors existing GCP (`K_SERVICE`) and Azure (`WEBSITE_SITE_NAME`) auto-detection behavior. **`ddtrace/internal/schema/processor.py`** — Removes the Lambda-specific early exit from `BaseServiceProcessor`. Previously, the processor skipped all Lambda spans to avoid unhelpful `base_service` values from the runtime. Now that the service is correctly resolved from the function name, the processor runs normally and `_dd.base_service` is properly attached to spans. ## Testing Existing serverless system tests pass (ALB, API Gateway HTTP/REST, Function URL). ## Risks Low. The change only affects Lambda environments where `DD_SERVICE` is not explicitly set. The resolved service name (`AWS_LAMBDA_FUNCTION_NAME`) matches what the extension already uses for extension-based languages, ensuring consistency across runtimes. Co-authored-by: zarir.hamza <zarir.hamza@datadoghq.com>
wantsui
approved these changes
Apr 9, 2026
Codeowners resolved as |
emmettbutler
approved these changes
Apr 9, 2026
mabdinur
approved these changes
Apr 9, 2026
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.
Backport of #17238 to 4.6.
(cherry picked from commit 93778cc)
Description
Fixes
_dd.base_servicehandling for AWS Lambda environments in the Python tracer, enabling service remapping rules to work on Lambda spans and ensuring trace stats contain a meaningfulbase_service.Changes
ddtrace/internal/settings/_config.py— WhenDD_SERVICEis not configured and the tracer is running in AWS Lambda,config.serviceis now automatically set fromAWS_LAMBDA_FUNCTION_NAME. This mirrors existing GCP (K_SERVICE) and Azure (WEBSITE_SITE_NAME) auto-detection behavior.ddtrace/internal/schema/processor.py— Removes the Lambda-specific early exit fromBaseServiceProcessor. Previously, the processor skipped all Lambda spans to avoid unhelpfulbase_servicevalues from the runtime. Now that the service is correctly resolved from the function name, the processor runs normally and_dd.base_serviceis properly attached to spans.Testing
Existing serverless system tests pass (ALB, API Gateway HTTP/REST, Function URL). Includes new unit tests for Lambda service name auto-detection and base_service processor behavior.
Risks
Low. The change only affects Lambda environments where
DD_SERVICEis not explicitly set. The resolved service name (AWS_LAMBDA_FUNCTION_NAME) matches what the extension already uses for extension-based languages, ensuring consistency across runtimes.