[IGNORE] 🪞 #6108 - Honor DD_DOGSTATSD_URL/DD_DOGSTATSD_SOCKET for the runtime metrics statsd client - #6117
[IGNORE] 🪞 #6108 - Honor DD_DOGSTATSD_URL/DD_DOGSTATSD_SOCKET for the runtime metrics statsd client#6117p-datadog wants to merge 6 commits into
Conversation
…atsd client Metrics::Client#default_statsd_client always passed an explicit host and port to Datadog::Statsd.new, which bypasses dogstatsd-ruby's environment resolution entirely: DD_DOGSTATSD_URL and DD_DOGSTATSD_SOCKET were ignored and runtime metrics were silently sent to the UDP default (127.0.0.1:8125) on UDS-only setups — for example pods instrumented by the Datadog Admission Controller, which injects DD_DOGSTATSD_URL but not DD_AGENT_HOST. When one of those variables is set, no explicit DD_AGENT_HOST or DD_METRIC_AGENT_PORT is configured, and the installed dogstatsd-ruby understands them (>= 5.6), construct the client without positional arguments so dogstatsd-ruby resolves the transport itself. Explicit host/port configuration keeps the existing behavior. Fixes #6107 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Review of PR #6108 noted the new public predicate statsd_transport_from_env? had no entry in sig/datadog/core/metrics/client.rbs (its sibling private helper dogstatsd_version is declared) and no @return tag. Declare it as () -> bool and document the return in YARD. client.rb is in the Steepfile ignore list, so this is signature/documentation consistency, not a Steep fix.
PR #6108 makes the runtime-metrics statsd client honor DD_DOGSTATSD_URL and DD_DOGSTATSD_SOCKET but did not document them. Per the repo rule to record new env vars in GettingStarted.md, add a paragraph in the runtime metrics section covering the two variables, the >= 5.6 dogstatsd-ruby requirement, and the DD_AGENT_HOST/DD_METRIC_AGENT_PORT precedence.
|
👋 Hey @p-datadog, please fill "Change log entry" section in the pull request description. If changes need to be present in CHANGELOG.md you can state it this way **Change log entry**
Yes. A brief summary to be placed into the CHANGELOG.md(possible answers Yes/Yep/Yeah) Or you can opt out like that **Change log entry**
None.(possible answers No/Nope/None) Visited at: 2026-07-28 18:13:33 UTC |
|
|
Adding the "do not merge/WIP" label to make it easier for my team to follow your [IGNORE] tag 🙂 If anything changes and you need review, just take that label off! |
The `rake local_config_map:generate` template emits `require 'set'` with single quotes (tasks/local_config_map.rake:69), which standard flags as Style/StringLiterals (prefer double quotes). The generated file must be run through `rake standard:fix` after regeneration; that step was skipped when DD_DOGSTATSD_URL/DD_DOGSTATSD_SOCKET were added, so the standard/lint CI job failed on line 3. Change `require 'set'` to `require "set"`, matching what standard:fix produces (and master's committed generated file). Verified: `BUNDLE_GEMFILE=gemfiles/ruby-4.0.gemfile bundle exec rake standard` on Ruby 4.0.6 (the CI config) exits 1 before this change with the offense at supported_configurations.rb:3:9 and exits 0 after.
Address review comment: statsd_transport_from_env? is an internal helper used only by default_statsd_client and should not expand the public surface area of Datadog::Core::Metrics::Client. - Moved the method (and its doc comment) into the existing private section in lib/datadog/core/metrics/client.rb - Moved its signature under the private keyword in sig/datadog/core/metrics/client.rbs Verified: rspec spec/datadog/core/metrics/client_spec.rb (85 examples, 0 failures); steep check (no type error); standardrb clean.
Address review comment: in the DD_DOGSTATSD_URL (>=5.6) and DD_DOGSTATSD_SOCKET
contexts, the before block referenced the metrics subject before setting the
Datadog::Statsd.new expectation. Because let(:options) is shadowed to
{single_thread: true} (no injected statsd), Client#initialize builds a real
statsd client, and with the URL/SOCKET env set that resolves a real env-based
(UDS) transport during test setup.
- Stub Datadog::Statsd.new with allow before building metrics so the
initialization call returns the double instead of opening a real transport;
the explicit expectation then observes only the #default_statsd_client call
- Stub statsd_client#close since @statsd is now the double closed by the
after hook
- Applied to both flagged locations (URL >=5.6 branch and SOCKET context)
Verified: rspec spec/datadog/core/metrics/client_spec.rb (85 examples, 0
failures); standardrb clean.
BenchmarksBenchmark execution time: 2026-07-29 00:33:46 Comparing candidate commit 52efb8c in PR branch Found 0 performance improvements and 0 performance regressions! Performance is the same for 48 metrics, 1 unstable metrics.
|
This PR mirrors the changes from the original community contribution to enable CI testing with maintainer privileges.
Original PR: #6108
Original Author: @ollym
Original Branch: ollym/dd-trace-rb:fix/runtime-metrics-dogstatsd-url
Mirror Type: exact mirror (preserves original commits and signatures)
Closes #6108
This is an automated mirror created to run CI checks. See tooling/mirror-community-pull-request.sh for details.