Skip to content

fix: use DD_SERVICE for inferred spans when integration service names are removed - #834

Merged
zarirhamza merged 7 commits into
mainfrom
zarir/dd-service-inferred-spans
Aug 27, 2026
Merged

fix: use DD_SERVICE for inferred spans when integration service names are removed#834
zarirhamza merged 7 commits into
mainfrom
zarir/dd-service-inferred-spans

Conversation

@zarirhamza

@zarirhamza zarirhamza commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

Summary

  • When DD_TRACE_REMOVE_INTEGRATION_SERVICE_NAMES_ENABLED=true and DD_SERVICE is set, inferred (synthetic) spans use the base service name (DD_SERVICE) instead of the AWS resource/instance representation.
  • An explicit DD_SERVICE_MAPPING entry still takes precedence over DD_SERVICE.
  • Default behavior (flag off) is unchanged: inferred spans use the AWS resource name (queue/stream/table/etc.), so existing integration snapshots are unaffected.
  • Adds config.aws_service_representation_enabled (DD_TRACE_AWS_SERVICE_REPRESENTATION_ENABLED, default true) and config.remove_integration_service_names_enabled (DD_TRACE_REMOVE_INTEGRATION_SERVICE_NAMES_ENABLED, default false).

Resolution order in determine_service_name

  1. DD_SERVICE_MAPPING (specific key, then generic key)
  2. If DD_TRACE_REMOVE_INTEGRATION_SERVICE_NAMES_ENABLED and DD_SERVICE set → DD_SERVICE
  3. If AWS service representation disabled → fallback
  4. Extracted resource/instance name, else fallback

Motivation

Part of the Serverless Service Representation (SSR) work. The flag lets inferred spans collapse onto the function's base service when integration-specific service names are turned off, while keeping the resource-name behavior by default.

Test plan

  • tests/test_tracing.py (TestServiceMapping + inferred-span tests) pass with and without DD_SERVICE / the flag
  • Integration snapshots unchanged (default behavior)

When DD_SERVICE (config.service) is set, use it as the service for
inferred (synthetic) spans, taking precedence over DD_SERVICE_MAPPING
and the AWS service representation. When DD_SERVICE is unset, the
existing resolution logic is preserved.
@datadog-prod-us1-6

datadog-prod-us1-6 Bot commented Jun 18, 2026

Copy link
Copy Markdown

Tests

🔄 Datadog auto-retried 4 jobs - 2 passed on retry View in Datadog

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 3faee2d | Docs | View more details | Give us feedback!

The inferred-span and service-mapping tests assert the AWS service
representation, which only applies when DD_SERVICE is unset. CI sets
DD_SERVICE, so pin config.service to None to keep them deterministic.
Verify create_inferred_span uses DD_SERVICE as the service (over an
explicit service mapping) when DD_SERVICE is set.
Inferred (synthetic) spans now use DD_SERVICE (integration-tests-python)
as their service instead of the AWS service representation, so the
redundant _dd.base_service tag is dropped on those spans. Regenerated
via UPDATE_SNAPSHOTS for all Python versions.
…moved

Gate the DD_SERVICE inferred-span service resolution behind
DD_TRACE_REMOVE_INTEGRATION_SERVICE_NAMES_ENABLED: when enabled (and
DD_SERVICE is set), inferred (synthetic) spans use the base service name
instead of the AWS resource/instance representation. Default behavior
(flag off) is unchanged, so integration snapshots match main. Reverts
the earlier unconditional DD_SERVICE-first and experimental peer.service
/ span.kind changes.
@zarirhamza zarirhamza changed the title fix: prefer DD_SERVICE as the inferred span service name fix: use DD_SERVICE for inferred spans when integration service names are removed Jun 18, 2026

@joeyzhao2018 joeyzhao2018 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@zarirhamza
zarirhamza merged commit 117d396 into main Aug 27, 2026
105 of 113 checks passed
@zarirhamza
zarirhamza deleted the zarir/dd-service-inferred-spans branch August 27, 2026 19:18
zarirhamza added a commit to DataDog/datadog-lambda-extension that referenced this pull request Aug 27, 2026
…ice names are removed (#1343)

## Summary

- Adds `DD_TRACE_REMOVE_INTEGRATION_SERVICE_NAMES_ENABLED` (default
`false`). When it is set **and** `DD_SERVICE` is configured, inferred
(synthetic) event-source spans report the function's base service
instead of the AWS resource/instance representation.
- An explicit `DD_SERVICE_MAPPING` entry still takes precedence.
- Applies to the wrapped inferred spans too (SQS→SNS, SQS→EventBridge,
SNS→EventBridge).

## Motivation

Customers currently need one `DD_SERVICE_MAPPING` entry 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](https://datadoghq.atlassian.net/browse/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/datadog-lambda-python#834),
[datadog-lambda-js#814](DataDog/datadog-lambda-js#814).

## Implementation note

Rather than thread two more parameters through `Trigger::enrich_span`
and `resolve_service_name` (a ~200-line mechanical change across all 13
trigger modules and their tests), the override is applied in
`span_inferrer.rs` immediately after enrichment.

To keep `DD_SERVICE_MAPPING` precedence expressed in one place,
`Trigger` gains a default `has_service_mapping_entry` method that reuses
the same specific/generic identifiers `resolve_service_name` looks up.
Happy to switch to the full parameter-threading approach if reviewers
prefer a single resolution ladder.

The override lowercases `DD_SERVICE` to match the invocation span built
in `processor.rs`, so both spans land on the same service.

## Scope

Service-name resolution only. `complete_inferred_spans` still sets
`peer.service` to the invocation span's service as it does today;
revisiting that pairing is deliberately left to a follow-up.

## Test plan

- [x] 6 new tests in `span_inferrer.rs`: override applies, disabled by
default, yields to `DD_SERVICE_MAPPING`, no-op without `DD_SERVICE`,
lowercases `DD_SERVICE`, applies to wrapped spans
- [x] 3 new config tests: default off, from env, from YAML
- [x] `cargo test --lib` — 550 passed
- [x] `cargo clippy --lib --tests -- -D warnings` clean
- [x] `cargo fmt --check` clean

[FRSLES-869]:
https://datadoghq.atlassian.net/browse/FRSLES-869?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants