feat(traces): use DD_SERVICE for inferred spans when integration service names are removed - #1343
Open
zarirhamza wants to merge 2 commits into
Open
feat(traces): use DD_SERVICE for inferred spans when integration service names are removed#1343zarirhamza wants to merge 2 commits into
zarirhamza wants to merge 2 commits into
Conversation
…ice names are removed When DD_TRACE_REMOVE_INTEGRATION_SERVICE_NAMES_ENABLED=true and DD_SERVICE is set, inferred (synthetic) event-source spans report the function's base service instead of the AWS resource/instance representation. This gives users a single setting to consolidate every trigger span onto the function's service, rather than requiring one DD_SERVICE_MAPPING entry per trigger type per function. An explicit DD_SERVICE_MAPPING entry still takes precedence, and the flag defaults to false, so existing behavior is unchanged. This is the only inferred-span implementation for Go, Java, .NET, and Ruby, which delegate span inference to the extension entirely.
Contributor
There was a problem hiding this comment.
Pull request overview
Adds an opt-in configuration that, when enabled and DD_SERVICE is set, forces inferred (synthetic) trigger spans (including wrapped spans) to report the function’s base service instead of the trigger’s AWS resource/instance-derived service—while preserving DD_SERVICE_MAPPING precedence.
Changes:
- Introduces
DD_TRACE_REMOVE_INTEGRATION_SERVICE_NAMES_ENABLED(falseby default) and wires it through env/YAML config loading. - Adds a post-enrichment override in
span_inferrer.rsto set inferred-spanservicefromDD_SERVICEunless an explicit service mapping exists. - Adds unit tests covering default behavior, override behavior, mapping precedence, and wrapped-span behavior.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
bottlecap/src/lifecycle/invocation/triggers/mod.rs |
Adds a helper on Trigger to detect whether DD_SERVICE_MAPPING targets a trigger (specific or generic key) to preserve precedence. |
bottlecap/src/lifecycle/invocation/span_inferrer.rs |
Applies the new base-service override to inferred spans and wrapped inferred spans; adds targeted tests. |
bottlecap/src/config/mod.rs |
Adds the new Lambda extension config flag with defaults and env/YAML parsing, plus config tests. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
… is disabled Copilot flagged that the base-service override could diverge from the invocation span when DD_TRACE_AWS_SERVICE_REPRESENTATION_ENABLED=false, since processor.rs names the invocation span "aws.lambda" in that case. It does not: ChunkProcessor rewrites any "aws.lambda" span to the lowercased DD_SERVICE from the tags map, so both spans converge. Adds a test on each side of that seam and corrects the doc comment, which credited processor.rs alone for the match.
|
zarirhamza
marked this pull request as ready for review
August 27, 2026 15:00
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.
Summary
DD_TRACE_REMOVE_INTEGRATION_SERVICE_NAMES_ENABLED(defaultfalse). When it is set andDD_SERVICEis configured, inferred (synthetic) event-source spans report the function's base service instead of the AWS resource/instance representation.DD_SERVICE_MAPPINGentry still takes precedence.Motivation
Customers currently need one
DD_SERVICE_MAPPINGentry per trigger type per function to get their event-source spans onto their own service name. This gives them a single setting that consolidates all of them at once.Tracked by FRSLES-869. This repo is the only inferred-span implementation for Go, Java, .NET, and Ruby, which delegate inference to the extension entirely. Companion PRs: datadog-lambda-python#834, datadog-lambda-js#814.
Implementation note
Rather than thread two more parameters through
Trigger::enrich_spanandresolve_service_name(a ~200-line mechanical change across all 13 trigger modules and their tests), the override is applied inspan_inferrer.rsimmediately after enrichment.To keep
DD_SERVICE_MAPPINGprecedence expressed in one place,Triggergains a defaulthas_service_mapping_entrymethod that reuses the same specific/generic identifiersresolve_service_namelooks up. Happy to switch to the full parameter-threading approach if reviewers prefer a single resolution ladder.The override lowercases
DD_SERVICEto match the invocation span built inprocessor.rs, so both spans land on the same service.Scope
Service-name resolution only.
complete_inferred_spansstill setspeer.serviceto the invocation span's service as it does today; revisiting that pairing is deliberately left to a follow-up.Test plan
span_inferrer.rs: override applies, disabled by default, yields toDD_SERVICE_MAPPING, no-op withoutDD_SERVICE, lowercasesDD_SERVICE, applies to wrapped spanscargo test --lib— 550 passedcargo clippy --lib --tests -- -D warningscleancargo fmt --checkclean