Skip to content

feat(config): support OTEL_SERVICE_NAME as alias for DD_SERVICE#266

Draft
bm1549 wants to merge 12 commits into
mainfrom
worktree-otel-service-name-alias
Draft

feat(config): support OTEL_SERVICE_NAME as alias for DD_SERVICE#266
bm1549 wants to merge 12 commits into
mainfrom
worktree-otel-service-name-alias

Conversation

@bm1549

@bm1549 bm1549 commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?

Registers OTEL_SERVICE_NAME as a first-class configuration entry, with DD_SERVICE taking precedence and OTEL_SERVICE_NAME used as a fallback when DD_SERVICE is absent or empty. This matches how other Datadog tracers (Python, Go, Java, .NET, Node.js) handle it.

Previously, OTEL_SERVICE_NAME was not a tracer config value. It was picked up only via the OpenTelemetry SDK's resource detection and applied post-init in set_resource, as a Calculated-origin override on the service config plus the span resource. Because the Remote Config worker starts before set_resource runs and builds its request lazily, the initial RC request(s) could be sent with the wrong (default or DD_SERVICE) service name. Resolving OTEL_SERVICE_NAME at config-initialization time removes that startup window, so Remote Config targeting and all config-level consumers use the correct service name from the start.

Changes:

  • supported-configurations.json: Adds OTEL_SERVICE_NAME as a top-level entry (version B, matching the FPD registry), alongside the existing OTel config entries. It is registered as a separate config rather than a DD_SERVICE alias because the FPD treats OTel env vars as distinct configs, not aliases (using the aliases field caused the FPD validation CI job to fail).
  • configuration.rs: Adds a update_non_empty_string_with_fallback helper on ConfigItemSourceUpdater and uses it for the service field. The service is the first non-empty value among [DD_SERVICE, OTEL_SERVICE_NAME], else the default. An empty value on either key is treated as unset.
  • supported_configurations.rs: Regenerated, OTEL_SERVICE_NAME is now a SupportedConfigurations enum variant.

Motivation

Users who configure their services via OTEL_SERVICE_NAME (a standard OpenTelemetry env var) expect dd-trace-rs to honor it the same way the other Datadog tracers do.

Additional Notes

Service-name precedence tests cover:

  1. OTEL_SERVICE_NAME alone is used as the service name
  2. DD_SERVICE + OTEL_SERVICE_NAME means DD_SERVICE wins
  3. DD_SERVICE="" + OTEL_SERVICE_NAME set falls through to OTEL_SERVICE_NAME (empty DD_SERVICE is treated as unset, matching dd-trace-go)
  4. OTEL_SERVICE_NAME="" alone uses the default
  5. Both empty uses the default

bm1549 and others added 2 commits June 23, 2026 16:44
… DD_SERVICE

OTEL_SERVICE_NAME is a standard OpenTelemetry env var that other dd-trace-*
libraries accept as a first-class DD_SERVICE alias. Previously, dd-trace-rs
only handled it indirectly via the OTel SDK resource detection (which set the
span service name post-init, but not config-level fields like RC service
targeting or telemetry service name at startup).

This adds OTEL_SERVICE_NAME as a proper alias in supported-configurations.json
and updates the code generator to distinguish non-deprecated aliases (aliases
field) from deprecated old names (deprecated_aliases field), so users setting
OTEL_SERVICE_NAME do not see a spurious deprecation warning.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
… comments

- docs/add_configurations.md: document the new deprecated_aliases field and
  correct the now-stale "aliases are auto-deprecated" rule
- configuration.rs: add service_is_default() assertion to precedence test;
  add test documenting DD_SERVICE="" behavior (empty primary does not fall
  through to OTEL_SERVICE_NAME alias)
- local_config_map_generate.py: use extend/.get() idiom for consistency
- span_processor.rs: clarify comment to document the two service-name
  intake paths (env-var alias vs programmatic Resource)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@datadog-datadog-prod-us1

datadog-datadog-prod-us1 Bot commented Jun 23, 2026

Copy link
Copy Markdown

Tests

🎉 All green!

🧪 All tests passed
❄️ No new flaky tests detected

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 56bfd33 | Docs | Datadog PR Page | Give us feedback!

bm1549 and others added 10 commits June 23, 2026 17:01
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
The FPD (Feature Parity Dashboard) validation checks that local aliases
are a subset of aliases registered in the FPD registry. Since the FPD
treats OTEL_SERVICE_NAME as a separate config (not an alias of DD_SERVICE),
declaring it in the aliases field causes the validation to fail.

Follow the pattern of other Datadog tracers (Python, Go, Java): register
OTEL_SERVICE_NAME as its own top-level entry (version B) and implement
the DD_SERVICE -> OTEL_SERVICE_NAME fallback explicitly in code.

The behavior is identical to the alias-based approach:
- DD_SERVICE set -> use it
- DD_SERVICE absent -> try OTEL_SERVICE_NAME
- DD_SERVICE="" (empty) -> use default (fallback suppressed)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…rator

Remove the deprecated_aliases field introduced for DD_REMOTE_CONFIGURATION_ENABLED
now that OTEL_SERVICE_NAME is a top-level supportedConfigurations entry — the
automatic heuristic (mark an alias deprecated if it is not itself a top-level key)
handles all existing cases correctly without requiring an explicit field.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…fallback

Replaces the inline match in the Config struct literal with a reusable
ConfigItemSourceUpdater helper, so the service field reads as a one-liner
consistent with the surrounding fields. The fallback key (OTEL_SERVICE_NAME)
now also requires a non-empty value; an empty OTEL_SERVICE_NAME="" produces
the default, matching DD_SERVICE="" behavior.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Treat an empty value on either key the same as the key being absent, so the
service is the first non-empty value among [DD_SERVICE, OTEL_SERVICE_NAME],
else the default. This simplifies the fallback helper (both keys handled
uniformly) and matches dd-trace-go's behavior for DD_SERVICE="".

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Pick the result (primary if non-empty, else fallback) first, then apply it
once if non-empty. Removes the nested match and duplicated apply_result call.
Also drops the now-redundant comment at the service field; the helper doc
covers the precedence.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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.

1 participant