feat(otel): support DD_HOSTNAME as host.name OTel resource attribute#5705
Conversation
Add a top-level `hostname` option backed by the `DD_HOSTNAME` env var. When `DD_TRACE_REPORT_HOSTNAME` is enabled, prefer the configured hostname over Socket.hostname for the `host.name` OTel resource attribute. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 4e099643c3
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Move the host.name assignment to after the tag loop so DD_HOSTNAME overrides any host.name set via DD_TAGS/OTEL_RESOURCE_ATTRIBUTES, consistent with how service/env/version first-class settings take precedence over their tag equivalents. When DD_HOSTNAME is not set, Socket.hostname is used only as a fallback when no host.name tag is present, preserving the existing tag behavior. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…is enabled Aligned with dd-trace-py: DD_HOSTNAME now takes precedence over the system hostname for the trace-level hostname tag. Also adds missing RBS type declarations for the hostname setting and ENV_HOSTNAME constant. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
StandardRB requires parentheses around complex ternary conditions. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
✨ Fix all issues with BitsAI or with Cursor
|
Co-authored-by: Munir Abdinur <munir.abdinur@datadoghq.com>
BenchmarksBenchmark execution time: 2026-05-11 15:38:55 Comparing candidate commit e8507ba in PR branch Found 0 performance improvements and 0 performance regressions! Performance is the same for 46 metrics, 0 unstable metrics.
|
8b34fa6 to
cd4c511
Compare
cd4c511 to
8003c01
Compare
Typing analysisThis PR does not change typing compared to the base branch. |
2b581cc to
142bb71
Compare
8e42dd3 to
8c3ee01
Compare
…STNAME resolution Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
8c3ee01 to
c6deba3
Compare
|
/merge |
|
View all feedbacks in Devflow UI.
This pull request is not mergeable according to GitHub. Common reasons include pending required checks, missing approvals, or merge conflicts — but it could also be blocked by other repository rules or settings.
devflow unqueued this merge request: It did not become mergeable within the expected time |
Co-authored-by: Sergey Fedorov <oni.strech@gmail.com>
Co-authored-by: Munir Abdinur <munir.abdinur@datadoghq.com>
What does this PR do?
Adds a top-level
hostnameconfiguration option backed by theDD_HOSTNAMEenvironment variable. WhenDD_TRACE_REPORT_HOSTNAMEis enabled:DD_HOSTNAMEis used as thehost.nameOpenTelemetry resource attribute (OTel metrics and logs), falling back toSocket.hostnameif unset.DD_HOSTNAMEis used as the trace-level hostname tag, matching the behavior of other Datadog SDKs.Motivation:
The
DD_HOSTNAMEenv var is supported by other Datadog SDKs (Python, Java, etc.) and allows overriding the host name reported by the process. This brings Ruby parity and allows theTest_FR07_Host_Name::test_hostname_from_dd_hostnameparametric test to pass.Alignment with dd-trace-py:
Reviewed the dd-trace-py implementation. Python uses a single
get_hostname()helper that returnsDD_HOSTNAMEif set, else falls back tosocket.gethostname(). This value is applied to:report_hostnameis true (_trace/tracer.py:564)host.nameattribute whenreport_hostnameis truehost.nameattribute whenreport_hostnameis trueThis PR aligns Ruby with that pattern:
Datadog.configuration.hostname(readsDD_HOSTNAME) takes precedence over the system hostname in traces and OTel resource attributesENV_HOSTNAMEconstant andhostnamemethod onSettingsPrecedence (OTel resource
host.name):DD_HOSTNAME(explicit override)host.namefromDD_TAGS/c.tagsSocket.hostname(system fallback)Change log entry
Yes. Added
DD_HOSTNAMEenvironment variable support. WhenDD_TRACE_REPORT_HOSTNAMEis enabled, the value ofDD_HOSTNAMEis used as the trace hostname andhost.nameOpenTelemetry resource attribute.Additional Notes:
@settings.hostnamefallback is applied in both the metrics (metrics.rb) and logs (lib/datadog/opentelemetry/logs.rb, in the companion PR feat(otel): add otel logs support #5446) resource builders.ENV_HOSTNAME: Stringinsig/datadog/core/environment/ext.rbsanddef hostname: -> String?insig/datadog/core/configuration/settings.rbs.