Skip to content

Add Env field to DSM stats payload#5427

Merged
ericfirth merged 2 commits into
masterfrom
eric.firth/env-issue
Mar 9, 2026
Merged

Add Env field to DSM stats payload#5427
ericfirth merged 2 commits into
masterfrom
eric.firth/env-issue

Conversation

@ericfirth

Copy link
Copy Markdown
Contributor

What does this PR do?

Adds the Env field to the Data Streams Monitoring stats payload sent to the agent, matching Java tracer behavior.

Motivation:

Ruby services show env:none in DSM despite having DD_ENV configured. The root cause is the Ruby tracer omits Env from the DSM stats payload, while Java includes it. The env value is already available in @settings.env (used for pathway hash computation) — it just wasn't being serialized.

Change log entry

Fix: Data Streams Monitoring now correctly reports the configured environment, resolving services showing as env:none.

Additional Notes:

Falls back to 'none' when env is not configured, consistent with the existing fallback in compute_pathway_hash (line 372).

How to test the change?

  • bundle exec rspec spec/datadog/data_streams/processor_spec.rb — 32 examples, 0 failures
  • Two new tests verify Env is included in the flush payload with the configured value, and defaults to 'none' when unset

The Ruby tracer was not including the Env field in the Data Streams
Monitoring stats payload sent to the agent, causing services to show
env:none in DSM despite having DD_ENV configured. This aligns the
Ruby tracer with Java, which already sends Env as a top-level field.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@ericfirth ericfirth added the AI Generated Largely based on code generated by an AI or LLM. This label is the same across all dd-trace-* repos label Mar 6, 2026
@ericfirth
ericfirth requested review from a team as code owners March 6, 2026 15:55
@github-actions

github-actions Bot commented Mar 6, 2026

Copy link
Copy Markdown

👋 Hey @DataDog/ruby-guild, 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-03-06 15:56:07 UTC

@ericfirth

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

To use Codex here, create a Codex account and connect to github.

@pr-commenter

pr-commenter Bot commented Mar 6, 2026

Copy link
Copy Markdown

Benchmarks

Benchmark execution time: 2026-03-09 14:03:03

Comparing candidate commit 1a66102 in PR branch eric.firth/env-issue with baseline commit de5b703 in branch master.

Found 0 performance improvements and 0 performance regressions! Performance is the same for 46 metrics, 0 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 ----------------------------------'

@ericfirth

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Bravo.

ℹ️ 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".

@Strech Strech left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think a little bit of RSpec adjustments needed, rest is good

Comment thread spec/datadog/data_streams/processor_spec.rb Outdated
Comment thread spec/datadog/data_streams/processor_spec.rb Outdated
Comment thread spec/datadog/data_streams/processor_spec.rb Outdated
Address review feedback from @Strech:
- Use describe '#flush_stats' with context blocks for conditions
- Use let statements for settings and processor
- Move setup into before block

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@datadog-datadog-prod-us1-2

datadog-datadog-prod-us1-2 Bot commented Mar 9, 2026

Copy link
Copy Markdown

✅ Tests

🎉 All green!

❄️ No new flaky tests detected
🧪 All tests passed

🎯 Code Coverage (details)
Patch Coverage: 100.00%
Overall Coverage: 95.11% (-0.02%)

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

@ericfirth
ericfirth requested a review from Strech March 9, 2026 14:13

@Strech Strech left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

👍🏼

@ericfirth
ericfirth merged commit 4517747 into master Mar 9, 2026
631 of 632 checks passed
@ericfirth
ericfirth deleted the eric.firth/env-issue branch March 9, 2026 14:20
@github-actions github-actions Bot added this to the 2.30.0 milestone Mar 9, 2026
@Strech Strech mentioned this pull request Mar 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AI Generated Largely based on code generated by an AI or LLM. This label is the same across all dd-trace-* repos

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants