Skip to content

Let Remote Config enable Data Streams Monitoring when it is off at startup - #13460

Open
labbati wants to merge 37 commits into
masterfrom
labbati/dsm2-612-remote-config-for-dsm-dd-trace-java-verify
Open

labbati wants to merge 37 commits into
masterfrom
labbati/dsm2-612-remote-config-for-dsm-dd-trace-java-verify

Conversation

@labbati

@labbati labbati commented Nov 15, 2026 •

Copy link
Copy Markdown
Member

What Does This Do

Lets Remote Config (lib_config.data_streams_enabled) turn Data Streams Monitoring on at runtime for a service that started with DSM off:

  • The DSM propagator is registered the first time the live config turns DSM on, so pathway context is injected and extracted. The payload product mask uses the live config.
  • Kafka 0.11 and 3.8, SQS (AWS SDK v1 and v2), SNS and JMS check the live DSM config instead of the startup value.
  • Kafka client configs and consumer metadata are kept as pending at client construction, then reported once DSM is on. Clients built before the first Remote Config poll therefore report their config and cluster ID after an enable.
  • Kafka consumers built from a Map report Kafka's full ConsumerConfig, defaults included, like the Properties constructor, rather than only the caller's keys (on 2.7.x, which builds no reachable ConsumerConfig, the caller's map is kept and converted at report time).
  • The default propagator rebuild is thread-safe against runtime Propagators.register() calls. Concurrent callers never see a stale or null propagator.
  • The DSM inbox re-reads the live config before dropping an item. One-shot items (Kafka config, group member) enqueued right after an enable are kept.
  • A Remote Config enable that arrives during tracer startup is not lost.

With DSM off, behaviour is unchanged apart from cheap live-config checks. Spans and stored consumer info stay the same as before.

Motivation

Since v1.47.0 (#8368), the DSM propagator was only registered when DSM was on at startup. Enabling DSM through Remote Config then produced no pathway context and no checkpoints, even though the setting showed as applied.

Additional Notes

Known limits:

  • Kafka consumers without a group.id that were built while DSM was off get no kafka_cluster_id.
  • With DD_TRACE_SQS_INJECT_DATADOG_ATTRIBUTE_ENABLED=false, SQS clients (AWS SDK v1 and v2) built while DSM was off get no SqsInterceptor, so a Remote Config enable has no effect on them. A follow-up PR will always add the interceptor and check the live settings per request.
  • After an enable followed by a disable, the DSM propagator stays registered. Injection is skipped, but the composite extract allocation remains.
  • Stats start at the next 10 s report tick after Remote Config applies.

Tests run: unit tests, muzzle, spotless, latestDepTest/latestDepForkedTest for the touched modules, and new forked Remote Config toggle tests (DSM off at startup, enable, disable) for Kafka 0.11 and 3.8, SQS v1 and v2, and JMS. The JMS test checks stats only: JMS records DSM checkpoints for IBM MQ but never injects the pathway context (same as before this change). Verified end to end on a staging org: UI toggle on and off, no restart. JMH benchmarks were not run.

Contributor Checklist

Jira ticket: [DSM2-612]

…-612)

DSM enabled via remote config (lib_config.data_streams_enabled) after
startup with DD_DATA_STREAMS_ENABLED off never registered the DSM
propagator, so no pathway context was injected. Register it when the
live config first turns DSM on, check the live config first in inject,
and use the live config for the payload ProductMask.
Replace startup-only Config.get().isDataStreamsEnabled() checks with the
live trace config so DSM enabled by remote config takes effect for the
_datadog attribute parser, SQS client builders and JMS producer/consumer.
…M2-612)

Kafka clients are usually built before the first remote config poll, so
always keep consumer metadata and pending client config at construction
and gate cluster ID lookup and reporting on the live DSM config.

With DSM off, spans and stored consumer info match previous behavior: no
kafka.cluster_id on 0.11 and 3.8 async consume spans, while the 3.8
classic consumer keeps its existing tag.
The first metadata update consumed the pending config even with DSM
off, so a later remote config enable never reported it. Also adds
config-report coverage, a cluster-ID helper test, and closes a tracer
in CoreTracerTest.
…le (DSM2-612)

The worker re-reads the live config before dropping a data item, so one-shot
items (Kafka config, group member) enqueued before the next report tick are kept.
…-612)

Before the tracer is installed traceConfig() is the noop config, so construction
time gates also check Config.get(); per-message paths keep using the live config.
…M2-612)

Keep the ProducerConfig/ConsumerConfig reference instead of copying it at
construction, so clients built with DSM off keep no extra map; raw map configs
are still copied. Consumer construction gates also check the startup DSM config,
since traceConfig() is the noop config before the tracer is installed. Adds
KafkaConfigHelper.reportPendingConfig unit tests and comment nits.
…rebuild flag (DSM2-612)

Clearing the flag first let a lock-free reader return the stale, possibly
null, propagator. reset() now also clears the cached propagator, and the
concurrency test races several readers against the first build.
@labbati labbati added type: bug fix Bug fix inst: aws sdk AWS SDK instrumentation inst: kafka Kafka instrumentation inst: jms JMS instrumentation comp: data streams Data Streams Monitoring comp: remote config Configuration at Runtime tag: ai generated Largely based on code generated by an AI or LLM labels Nov 15, 2026
@linear-code

linear-code Bot commented Nov 15, 2026

Copy link
Copy Markdown

DSM2-612

@datadog-prod-us1-5

datadog-prod-us1-5 Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

🎯 Code Coverage (details)
• Patch Coverage: 50.94%
• Overall Coverage: 60.88% (-0.02%)

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: b00f2c5 | Docs | Give us feedback!

@dd-octo-sts

dd-octo-sts Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

🟢 Java Benchmark SLOs — All performance SLOs passed

Suite Status
Startup 🟢 pass

SLO thresholds are defined here based on automatically generated metrics. A warning is raised when results are within 5% of the threshold.

PR vs. master results
Scenario Candidate master Δ (95% CI of mean)
startup:insecure-bank:iast:Agent 14.98 s 14.84 s [+0.1%; +1.7%] (maybe worse)
startup:insecure-bank:tracing:Agent 13.75 s 13.81 s [-1.0%; +0.2%] (no difference)
startup:petclinic:appsec:Agent 17.82 s 17.52 s [+0.7%; +2.7%] (maybe worse)
startup:petclinic:iast:Agent 17.03 s 17.68 s [-7.8%; +0.5%] (no difference)
startup:petclinic:profiling:Agent 17.40 s 16.89 s [-1.4%; +7.5%] (no difference)
startup:petclinic:sca:Agent 17.74 s 17.71 s [-0.7%; +1.0%] (no difference)
startup:petclinic:tracing:Agent 16.51 s 16.47 s [-6.0%; +6.4%] (unstable)

Commit: b00f2c59 · CI Pipeline · Benchmarking Platform UI


Load and DaCapo benchmarks can be triggered manually in the GitLab pipeline. Results will appear in the Benchmarking Platform UI after completion.

@pr-commenter

pr-commenter Bot commented Nov 15, 2026 •

Copy link
Copy Markdown

Kafka / producer-benchmark

Parameters

Baseline Candidate
baseline_or_candidate baseline candidate
git_branch master labbati/dsm2-612-remote-config-for-dsm-dd-trace-java-verify
git_commit_date 1795187445 1795201870
git_commit_sha aec21f6 b00f2c5
See matching parameters
Baseline Candidate
ci_job_date 1795202941 1795202941
ci_job_id 2284492457 2284492457
ci_pipeline_id 155328102 155328102
cpu_model Intel(R) Xeon(R) Platinum 8175M CPU @ 2.50GHz Intel(R) Xeon(R) Platinum 8175M CPU @ 2.50GHz
jdkVersion 11.0.31 11.0.31
jmhVersion 1.36 1.36
jvm /usr/lib/jvm/java-11-openjdk-amd64/bin/java /usr/lib/jvm/java-11-openjdk-amd64/bin/java
jvmArgs -Dhttp.proxyHost=127.0.0.1 -Dhttp.proxyPort=15002 -Dhttps.proxyHost=127.0.0.1 -Dhttps.proxyPort=15002 -Dhttp.nonProxyHosts=localhost *.localhost
kernel_version Linux runner-zfyrx7zua-project-304-concurrent-0-t0ph4gg9 6.8.0-1031-aws #33~22.04.1-Ubuntu SMP Thu Jun 26 14:22:30 UTC 2025 x86_64 x86_64 x86_64 GNU/Linux Linux runner-zfyrx7zua-project-304-concurrent-0-t0ph4gg9 6.8.0-1031-aws #33~22.04.1-Ubuntu SMP Thu Jun 26 14:22:30 UTC 2025 x86_64 x86_64 x86_64 GNU/Linux
vmName OpenJDK 64-Bit Server VM OpenJDK 64-Bit Server VM
vmVersion 11.0.31+11-post-1ubuntu1-22.04.2-Ubuntu 11.0.31+11-post-1ubuntu1-22.04.2-Ubuntu

Summary

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

See unchanged results
scenario Δ mean throughput
scenario:not-instrumented/KafkaProduceBenchmark.benchProduce same
scenario:only-tracing-dsm-disabled-benchmarks/KafkaProduceBenchmark.benchProduce same
scenario:only-tracing-dsm-enabled-benchmarks/KafkaProduceBenchmark.benchProduce unsure
[-6098.889op/s; -203.805op/s] or [-4.540%; -0.152%]

@pr-commenter

pr-commenter Bot commented Nov 15, 2026 •

Copy link
Copy Markdown

Kafka / consumer-benchmark

Parameters

Baseline Candidate
baseline_or_candidate baseline candidate
git_branch master labbati/dsm2-612-remote-config-for-dsm-dd-trace-java-verify
git_commit_date 1795187445 1795201870
git_commit_sha aec21f6 b00f2c5
See matching parameters
Baseline Candidate
ci_job_date 1795203100 1795203100
ci_job_id 2284492460 2284492460
ci_pipeline_id 155328102 155328102
cpu_model Intel(R) Xeon(R) Platinum 8175M CPU @ 2.50GHz Intel(R) Xeon(R) Platinum 8175M CPU @ 2.50GHz
jdkVersion 11.0.31 11.0.31
jmhVersion 1.36 1.36
jvm /usr/lib/jvm/java-11-openjdk-amd64/bin/java /usr/lib/jvm/java-11-openjdk-amd64/bin/java
jvmArgs -Dhttp.proxyHost=127.0.0.1 -Dhttp.proxyPort=15002 -Dhttps.proxyHost=127.0.0.1 -Dhttps.proxyPort=15002 -Dhttp.nonProxyHosts=localhost *.localhost
kernel_version Linux runner-zfyrx7zua-project-304-concurrent-0-v7apq0go 6.8.0-1031-aws #33~22.04.1-Ubuntu SMP Thu Jun 26 14:22:30 UTC 2025 x86_64 x86_64 x86_64 GNU/Linux Linux runner-zfyrx7zua-project-304-concurrent-0-v7apq0go 6.8.0-1031-aws #33~22.04.1-Ubuntu SMP Thu Jun 26 14:22:30 UTC 2025 x86_64 x86_64 x86_64 GNU/Linux
vmName OpenJDK 64-Bit Server VM OpenJDK 64-Bit Server VM
vmVersion 11.0.31+11-post-1ubuntu1-22.04.2-Ubuntu 11.0.31+11-post-1ubuntu1-22.04.2-Ubuntu

Summary

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

See unchanged results
scenario Δ mean throughput
scenario:not-instrumented/KafkaConsumerBenchmark.benchConsume same
scenario:only-tracing-dsm-disabled-benchmarks/KafkaConsumerBenchmark.benchConsume same
scenario:only-tracing-dsm-enabled-benchmarks/KafkaConsumerBenchmark.benchConsume unsure
[-9091.289op/s; -944.246op/s] or [-5.538%; -0.575%]

@labbati
labbati requested a review from a team as a code owner November 17, 2026 09:57
@labbati
labbati requested review from AlexeyKuznetsov-DD, ValentinZakharov and jandro996 and removed request for a team November 17, 2026 09:57
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-17T10:03:34.239727Z dfc6ec3 Draft marked ready
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: dfc6ec32eb

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@datadog-prod-us1-5 datadog-prod-us1-5 Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Bits Code Review: PASS

More details

DSM propagator registration is ordered against startup-time enablement, and the inbox rechecks live configuration before discarding queued items. Runtime behavior and overhead remain unverified.

Was this helpful? React 👍 or 👎

Open Bits AI session

🤖 Bits Code Review · Commit dfc6ec3

@labbati
labbati enabled auto-merge November 17, 2026 11:06

@dougqh dougqh left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The concurrency changes look right to me. Making Propagators rebuild under the map lock also fixes the race where a register() could get lost. /perf-review found nothing on the paths that run per message. One request before I approve: see the inline comment. With DSM off, the tracer shouldn't do extra work.

@dougqh dougqh left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

One more gap, for SQS. It's more serious than a nit, but it doesn't need to block this PR: a follow-up PR works, as long as it's listed under "Known limits" until then.

@dougqh dougqh left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks, both addressed. Reusing the ConsumerConfig Kafka already built, with the copy only on 2.7.x, is the right shape, and the test for changes made after construction covers the side issue. LGTM once it's rebased onto master. Looking forward to the SQS follow-up.

return;
}
// Copied so later caller mutations aren't reported nor race with reporting threads
Map<String, Object> rawConfigCopy = new LinkedHashMap<>(rawConfig);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nit: a plain HashMap would do here. Order doesn't matter anywhere this config goes: convertToStringMap copies it again, KafkaConfigReport equality uses Map.equals, and the payload writes it as a msgpack map. On 2.7.x with DSM off, this copy stays for the life of the consumer, so the extra links per entry in LinkedHashMap aren't needed.

@joeyzhao2018 joeyzhao2018 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

this pr LGTM but it's worth pointing out the feature itself can't work in any serverless runtime except Fargate. And I just found out that we didn't turn remote config off in lambda, which I will follow up with a separate PR.

@lucaspimentel lucaspimentel 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.

AI-drafted review comments. 🤖

int generationId,
String memberProtocol) {
if (memberId == null || memberId.isEmpty() || clusterId == null || clusterId.isEmpty()) {
if (memberId == null

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.

Could we retain the membership observed while DSM is off and report it after enablement, as we do for pending client configs?

Returning here discards the membership, and the callers only retry on another group join. A consumer that joined before the RC toggle can therefore keep processing indefinitely without reporting its membership if the group remains stable. A regression test could join while DSM is disabled, enable it without triggering a rebalance, and verify that the membership is reported.

🤖

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Done in 99e2014 and ad067fa. A join seen while DSM is off, or before the cluster ID is known, is now kept on the consumer's metadata state. It's reported on the first metadata update after DSM is on, and a newer join replaces it. The join thread re-checks after storing, so a concurrent metadata update can't delay it. Covered by unit tests, and by subscribe()-based forked tests for 0.11 and 3.8 (b00f2c5) that enable DSM after the join with no rebalance.

}

/** Re-reads the live config so items enqueued right after a remote enable are not dropped. */
private boolean refreshDynamicConfig() {

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.

Could we also initialize the configured transaction extractors when DSM becomes enabled?

updateExtractorsFromConfig() is only called at startup and returns immediately when DSM is disabled. A later RC enable updates supportsDataStreams but leaves extractorsByType null, so automatic trackTransaction(...) calls continue returning without recording anything. Please add coverage for starting with DSM off and an extractor configured, then enabling DSM and verifying transaction extraction.

🤖

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Done in 1dacd73. Extractors now load whenever DSM switches from off to on, through Remote Config or an agent feature change. They no longer load only at startup. dynamicEnableLoadsTransactionExtractors covers it.

assertNotNull(onRecord.headers().lastHeader(PROPAGATION_KEY_BASE64));
assertNotNull(consumeSpan().getTag(KAFKA_CLUSTER_ID));
new PollingConditions(5)
.eventually(() -> {

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.

Could we assert that the inbound group's parent hash matches the outbound group's hash after enablement? The same assertion would help in the Kafka 3.8 test.

The current checks establish that the producer injects a header and both sides emit checkpoints, but they would also pass if consumer extraction were broken and the inbound checkpoint started a separate pathway. Checking the parent/hash relationship would cover the end-to-end propagation this change restores.

🤖

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Done in 02436e0. Both forked tests now assert that the outbound hash is non-zero and that the inbound group's parent hash equals it.

This branch has not been deployed

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

Labels

comp: data streams Data Streams Monitoring comp: remote config Configuration at Runtime inst: aws sdk AWS SDK instrumentation inst: jms JMS instrumentation inst: kafka Kafka instrumentation tag: ai generated Largely based on code generated by an AI or LLM type: bug fix Bug fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants