Skip to content

[NO-TICKET] Convert as much direct env var access to config DSL as possible#5559

Draft
vpellan wants to merge 4 commits intomasterfrom
vpellan/env-vars-to-config-dsl
Draft

[NO-TICKET] Convert as much direct env var access to config DSL as possible#5559
vpellan wants to merge 4 commits intomasterfrom
vpellan/env-vars-to-config-dsl

Conversation

@vpellan
Copy link
Copy Markdown
Contributor

@vpellan vpellan commented Apr 3, 2026

What does this PR do?

This PR converts as much configurations that are accessed directly through environment variable to our config DSL as possible. Some cannot be converted (env vars accessed before initializing the config DSL, or when booting a single piece of the tracer such as DI or AppSec)

Motivation:

By doing this, customers will not only be able to configure them through Datadog.configure blocks, but also through Stable Config. These configs will also be correctly reported through telemetry thanks to the work done for config visibility.

Change log entry

Yes. Enable the configuration of DD_GIT_REPOSITORY_URL, DD_GIT_COMMIT_SHA, DD_TRACE_AGENT_URL, DD_TRACE_AGENT_TIMEOUT_SECONDS, DD_METRIC_AGENT_PORT and DD_DYNAMIC_INSTRUMENTATION_PROBE_FILE through Datadog.configure blocks and in the Datadog UI

Additional Notes:

I'll open a PR on datadog-ci-rb so that DD_GIT_REPOSITORY_URL, DD_GIT_COMMIT_SHA are supported.

How to test the change?

@github-actions github-actions bot added core Involves Datadog core libraries integrations Involves tracing integrations tracing labels Apr 3, 2026
@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 3, 2026

Typing analysis

Ignored files

This PR clears 5 ignored files. It increases the percentage of typed files from 45.87% to 46.37% (+0.5%).

Ignored files (+0-5)Cleared:
lib/datadog/core/environment/variable_helpers.rb
lib/datadog/core/metrics/client.rb
lib/datadog/core/runtime/ext.rb
lib/datadog/core/runtime/metrics.rb
lib/datadog/core/workers/runtime_metrics.rb

Note: Ignored files are excluded from the next sections.

steep:ignore comments

This PR introduces 6 steep:ignore comments, and clears 4 steep:ignore comments.

steep:ignore comments (+6-4)Introduced:
lib/datadog/core/metrics/client.rb:158
lib/datadog/core/telemetry/event/app_started.rb:130
lib/datadog/core/telemetry/event/app_started.rb:136
lib/datadog/core/telemetry/event/app_started.rb:151
lib/datadog/core/telemetry/event/app_started.rb:162
lib/datadog/core/telemetry/event/app_started.rb:172
Cleared:
lib/datadog/core/telemetry/event/app_started.rb:139
lib/datadog/core/telemetry/event/app_started.rb:145
lib/datadog/core/telemetry/event/app_started.rb:156
lib/datadog/core/telemetry/event/app_started.rb:166

Untyped methods

This PR introduces 22 untyped methods and 9 partially typed methods. It decreases the percentage of typed methods from 61.72% to 60.81% (-0.91%).

Untyped methods (+22-0)Introduced:
sig/datadog/core/metrics/client.rbs:22
└── def supported?: () -> untyped
sig/datadog/core/metrics/client.rbs:24
└── def enabled?: () -> untyped
sig/datadog/core/metrics/client.rbs:26
└── def enabled=: (untyped enabled) -> untyped
sig/datadog/core/metrics/client.rbs:28
└── def default_hostname: () -> untyped
sig/datadog/core/metrics/client.rbs:30
└── def default_port: () -> untyped
sig/datadog/core/metrics/client.rbs:32
└── def default_statsd_client: () -> untyped
sig/datadog/core/metrics/client.rbs:36
└── def send_stats?: () -> untyped
sig/datadog/core/metrics/client.rbs:38
└── def count: (untyped stat, ?untyped? value, ?untyped? options) { () -> untyped } -> untyped
sig/datadog/core/metrics/client.rbs:40
└── def distribution: (untyped stat, ?untyped? value, ?untyped? options) ?{ () -> untyped } -> untyped
sig/datadog/core/metrics/client.rbs:42
└── def increment: (untyped stat, ?untyped? options) { () -> untyped } -> untyped
sig/datadog/core/metrics/client.rbs:44
└── def gauge: (untyped stat, ?untyped? value, ?untyped? options) ?{ () -> untyped } -> untyped
sig/datadog/core/metrics/client.rbs:46
└── def time: (untyped stat, ?untyped? options) { () -> untyped } -> untyped
sig/datadog/core/metrics/client.rbs:48
└── def send_metrics: (untyped metrics) -> untyped
sig/datadog/core/metrics/client.rbs:54
└── def dogstatsd_version: () -> untyped
sig/datadog/core/metrics/client.rbs:58
└── def ignored_statsd_warning: () -> untyped
sig/datadog/core/runtime/metrics.rbs:11
└── def gc_metrics: () -> untyped
sig/datadog/core/runtime/metrics.rbs:13
└── def try_flush: () { () -> untyped } -> untyped
sig/datadog/core/runtime/metrics.rbs:15
└── def default_metric_options: () -> untyped
sig/datadog/core/runtime/metrics.rbs:25
└── def compile_service_tags!: () -> untyped
sig/datadog/core/runtime/metrics.rbs:27
└── def nested_gc_metric: (untyped prefix, untyped k, untyped v) -> untyped
sig/datadog/core/runtime/metrics.rbs:29
└── def to_metric_name: (untyped str) -> untyped
sig/datadog/core/workers/runtime_metrics.rbs:16
└── def register_service: (untyped service) -> untyped
Partially typed methods (+9-0)Introduced:
sig/datadog/core/metrics/client.rbs:20
└── def initialize: (telemetry: Core::Telemetry::Component, port: Integer, ?logger: Datadog::Core::Logger, ?statsd: untyped?, ?enabled: bool, **untyped _) -> void
sig/datadog/core/metrics/client.rbs:34
└── def configure: (?::Hash[untyped, untyped] options) -> untyped
sig/datadog/core/metrics/client.rbs:50
└── def close: () -> (untyped | nil)
sig/datadog/core/runtime/metrics.rbs:7
└── def initialize: (telemetry: Core::Telemetry::Component, port: Integer, **untyped options) -> void
sig/datadog/core/runtime/metrics.rbs:8
└── def register_service: (untyped service) -> (nil | untyped)
sig/datadog/core/runtime/metrics.rbs:9
└── def flush: () -> (nil | untyped)
sig/datadog/core/runtime/metrics.rbs:31
└── def gauge_if_not_nil: (untyped metric_name, untyped metric_value) -> (untyped | nil)
sig/datadog/core/workers/runtime_metrics.rbs:12
└── def initialize: (telemetry: Core::Telemetry::Component, port: Integer, **untyped) -> void
sig/datadog/core/workers/runtime_metrics.rbs:17
└── def stop: (*untyped args, ?close_metrics: bool) -> untyped

Untyped other declarations

This PR introduces 6 untyped other declarations. It increases the percentage of typed other declarations from 77.79% to 77.89% (+0.1%).

Untyped other declarations (+6-0)Introduced:
sig/datadog/core/metrics/client.rbs:16
└── attr_reader statsd: untyped
sig/datadog/core/metrics/client.rbs:56
└── IGNORED_STATSD_ONLY_ONCE: untyped
sig/datadog/core/runtime/metrics.rbs:19
└── attr_reader service_tags: untyped
sig/datadog/core/runtime/metrics.rbs:21
└── attr_reader services: untyped
sig/datadog/core/runtime/metrics.rbs:23
└── attr_reader process_tags_enabled: untyped
sig/datadog/core/workers/runtime_metrics.rbs:10
└── attr_reader metrics: untyped

If you believe a method or an attribute is rightfully untyped or partially typed, you can add # untyped:accept on the line before the definition to remove it from the stats.

@pr-commenter
Copy link
Copy Markdown

pr-commenter bot commented Apr 3, 2026

Benchmarks

Benchmark execution time: 2026-04-03 15:52:41

Comparing candidate commit ae7651a in PR branch vpellan/env-vars-to-config-dsl with baseline commit e9d478b in branch master.

Found 0 performance improvements and 0 performance regressions! Performance is the same for 45 metrics, 1 unstable metrics.

Explanation

This is an A/B test comparing a candidate commit's performance against that of a baseline commit. Performance changes are noted in the tables below as:

  • 🟩 = significantly better candidate vs. baseline
  • 🟥 = significantly worse candidate vs. baseline

We compute a confidence interval (CI) over the relative difference of means between metrics from the candidate and baseline commits, considering the baseline as the reference.

If the CI is entirely outside the configured SIGNIFICANT_IMPACT_THRESHOLD (or the deprecated UNCONFIDENCE_THRESHOLD), the change is considered significant.

Feel free to reach out to #apm-benchmarking-platform on Slack if you have any questions.

More details about the CI and significant changes

You can imagine this CI as a range of values that is likely to contain the true difference of means between the candidate and baseline commits.

CIs of the difference of means are often centered around 0%, because often changes are not that big:

---------------------------------(------|---^--------)-------------------------------->
                              -0.6%    0%  0.3%     +1.2%
                                 |          |        |
         lower bound of the CI --'          |        |
sample mean (center of the CI) -------------'        |
         upper bound of the CI ----------------------'

As described above, a change is considered significant if the CI is entirely outside the configured SIGNIFICANT_IMPACT_THRESHOLD (or the deprecated UNCONFIDENCE_THRESHOLD).

For instance, for an execution time metric, this confidence interval indicates a significantly worse performance:

----------------------------------------|---------|---(---------^---------)---------->
                                       0%        1%  1.3%      2.2%      3.1%
                                                  |   |         |         |
       significant impact threshold --------------'   |         |         |
                      lower bound of CI --------------'         |         |
       sample mean (center of the CI) --------------------------'         |
                      upper bound of CI ----------------------------------'

@datadog-prod-us1-6
Copy link
Copy Markdown

datadog-prod-us1-6 bot commented Apr 3, 2026

⚠️ Tests

Fix all issues with BitsAI or with Cursor

⚠️ Warnings

🧪 26 Tests failed

Datadog::Core::Configuration::AgentSettingsResolver timeout priority when all of agent.timeout_seconds, DD_TRACE_AGENT_TIMEOUT_SECONDS are provided logs a warning from rspec   View in Datadog   (Fix with Cursor)
    expected: 1 time with arguments: (/Configuration mismatch/)
    received: 0 times


      expected: 1 time with arguments: (/Configuration mismatch/)
      received: 0 times
./spec/datadog/core/configuration/agent_settings_resolver_spec.rb:544:in \`block (5 levels) in <top (required)>'
./spec/datadog/core/configuration/agent_settings_resolver_spec.rb:5:in \`block (3 levels) in <top (required)>'
/usr/local/bundle/gems/climate_control-1.2.0/lib/climate_control.rb:24:in \`block in modify'
/usr/local/bundle/gems/climate_control-1.2.0/lib/climate_control.rb:15:in \`synchronize'
...
Datadog::Core::Configuration::AgentSettingsResolver timeout when a custom timeout is specified via code using "agent.timeout_seconds = " behaves like parsing of timeout when it's not an integer when the timeout is an invalid object falls back to the defaults from rspec   View in Datadog   (Fix with Cursor)
The setting \`agent.timeout_seconds\` inside your app's \`Datadog.configure\` block expects a int or \`nil\`, but a \`Object\` was provided (#<Object:0x00007fe3c213c768>). Please update your \`configure\` block.

Failure/Error: raise ArgumentError, error_msg

ArgumentError:
  The setting \`agent.timeout_seconds\` inside your app's \`Datadog.configure\` block expects a int or \`nil\`, but a \`Object\` was provided (#<Object:0x00007fe3c213c768>). Please update your \`configure\` block. 
Shared Example Group: "parsing of timeout when it's not an integer" called from ./spec/datadog/core/configuration/agent_settings_resolver_spec.rb:512
./lib/datadog/core/configuration/option.rb:276:in \`validate_type'
./lib/datadog/core/configuration/option.rb:311:in \`internal_set'
./lib/datadog/core/configuration/option.rb:115:in \`set'
...
Datadog::Core::Configuration::AgentSettingsResolver timeout when a custom timeout is specified via code using "agent.timeout_seconds = " behaves like parsing of timeout when it's not an integer when the timeout is an invalid object logs a warning from rspec   View in Datadog   (Fix with Cursor)
The setting \`agent.timeout_seconds\` inside your app's \`Datadog.configure\` block expects a int or \`nil\`, but a \`Object\` was provided (#<Object:0x00007fe3c21343d8>). Please update your \`configure\` block.

Failure/Error: raise ArgumentError, error_msg

ArgumentError:
  The setting \`agent.timeout_seconds\` inside your app's \`Datadog.configure\` block expects a int or \`nil\`, but a \`Object\` was provided (#<Object:0x00007fe3c21343d8>). Please update your \`configure\` block. 
Shared Example Group: "parsing of timeout when it's not an integer" called from ./spec/datadog/core/configuration/agent_settings_resolver_spec.rb:512
./lib/datadog/core/configuration/option.rb:276:in \`validate_type'
./lib/datadog/core/configuration/option.rb:311:in \`internal_set'
./lib/datadog/core/configuration/option.rb:115:in \`set'
...
View all

ℹ️ Info

No other issues found (see more)

❄️ No new flaky tests detected

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: ae7651a | Docs | Datadog PR Page | Was this helpful? React with 👍/👎 or give us feedback!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core Involves Datadog core libraries integrations Involves tracing integrations tracing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant