Skip to content

Propagate Oracle dynamic service hash without SQL comments - #12234

Open
joelmarcotte wants to merge 4 commits into
masterfrom
joel.marcotte/sdbm-2904-oracle-action-propagation
Open

Propagate Oracle dynamic service hash without SQL comments#12234
joelmarcotte wants to merge 4 commits into
masterfrom
joel.marcotte/sdbm-2904-oracle-action-propagation

Conversation

@joelmarcotte

@joelmarcotte joelmarcotte commented Aug 18, 2026

Copy link
Copy Markdown

What changed

  • Add opt-in DD_DBM_PROPAGATION_ORACLE_ACTION_ONLY_ENABLED configuration. It defaults to false.
  • With DD_DBM_PROPAGATION_MODE=dynamic_service, write _DD_DDSH:<BaseHash> through setClientInfo("OCSID.ACTION", ...) for Oracle connections.
  • Suppress Oracle SQL-comment injection in that opt-in mode, including prepared-statement preparation.
  • Track the last attempted ACTION per physical connection. Set it once for a stable hash and refresh it only if the base hash changes.
  • Keep parsed URL metadata cached while cloning it before connection attachment so connection-local ACTION state cannot leak between connections with the same URL.
  • Preserve full mode, service mode, and dynamic-service SQL comments for other databases.

Why

SDBM-2904 requires Oracle DBM/APM correlation without changing statement text. Oracle SQL Plan Management matches exact SQL text, so injected comments can prevent stored baselines from matching.

The ACTION payload uses the same signed BaseHash already emitted as ddsh, so the backend can reuse the existing dynamic-service linker.

Enablement

DD_DBM_PROPAGATION_MODE=dynamic_service
DD_DBM_PROPAGATION_ORACLE_ACTION_ONLY_ENABLED=true

Verification

  • ./gradlew :dd-trace-api:spotlessApply :internal-api:spotlessApply :dd-java-agent:agent-bootstrap:spotlessApply :dd-java-agent:instrumentation:jdbc:spotlessApply
  • ./gradlew :internal-api:test --tests 'datadog.trace.api.ConfigTest.Oracle DBM action propagation enabled*'
  • ./gradlew :dd-java-agent:instrumentation:jdbc:forkedTest --tests 'OracleInjectionForkedTest' --tests 'OracleDynamicServiceActionInjectionForkedTest' --tests 'DBMDynamicServiceInjectionForkedTest'

Links

@datadog-datadog-prod-us1

datadog-datadog-prod-us1 Bot commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

🎯 Code Coverage (details)
Patch Coverage: 80.00%
Overall Coverage: 58.40% (-0.02%)

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 35692f7 | Docs | View more details | Give us feedback!

@dd-octo-sts

dd-octo-sts Bot commented Aug 18, 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 13.94 s 14.02 s [-1.1%; +0.1%] (no difference)
startup:insecure-bank:tracing:Agent 12.88 s 12.94 s [-1.2%; +0.2%] (no difference)
startup:petclinic:appsec:Agent 16.91 s 16.70 s [+0.4%; +2.1%] (maybe worse)
startup:petclinic:iast:Agent 16.98 s 17.01 s [-1.1%; +0.7%] (no difference)
startup:petclinic:profiling:Agent 16.81 s 16.87 s [-1.4%; +0.7%] (no difference)
startup:petclinic:sca:Agent 16.65 s 16.49 s [-0.0%; +1.9%] (no difference)
startup:petclinic:tracing:Agent 16.10 s 16.16 s [-1.2%; +0.5%] (no difference)

Commit: 35692f70 · 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.

@joelmarcotte
joelmarcotte marked this pull request as ready for review August 19, 2026 17:47
@joelmarcotte
joelmarcotte requested review from a team as code owners August 19, 2026 17:47
@joelmarcotte
joelmarcotte requested review from mhdatie and ygree and removed request for a team August 19, 2026 17:47
@dd-octo-sts

dd-octo-sts Bot commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

Hi! 👋 Thanks for your pull request! 🎉

To help us review it, please make sure to:

  • Add at least one type, and one component or instrumentation label to the pull request

If you need help, please check our contributing guidelines.

@joelmarcotte joelmarcotte added comp: database Database Monitoring type: feature Enhancements and improvements inst: jdbc JDBC instrumentation tag: ai generated Largely based on code generated by an AI or LLM labels Aug 19, 2026

@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: ab2505d811

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

@datadog-datadog-prod-us1 datadog-datadog-prod-us1 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.

Datadog Autotest: FAIL

The new Oracle ACTION path ignores the process-tag propagation opt-out. It can send a hash without the matching span tag, so DBM-to-APM correlation fails.

Open Bits AI session

🤖 Datadog Autotest · Commit ab2505d · What is Autotest? · @DataDog review to ask questions · Any feedback? Reach out in #autotest

private final String warehouse;
private final String schema;
private volatile String poolName;
private volatile String oracleServiceAction;

@dougqh dougqh Aug 19, 2026

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 mix of final & volatiles here worries me from thread-safety / correctness perspective.
If I recall correctly, DbInfo objects are cached, so we really should set everything as construction rather than mutating later on.

Maybe switching to a builder idiom would be a better approach.
Normally, I don't like builders for performance reasons, but if we're already caching, it would be fine.

@dougqh dougqh Aug 19, 2026

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.

[Drafted by Claude on behalf of @dougqh]

Confirmed the caching concern is real, and worse than just field-mix hygiene: JDBCConnectionUrlParser.extractDBInfo caches DBInfo by (url, props) in a fixed 32-entry DDCache (JDBCConnectionUrlParser.java:847-861), shared across every Connection that connects with the same URL. That's why this PR had to add .toBuilder().build() after both extractDBInfo call sites (DriverInstrumentation.java, JDBCDecorator.parseDBInfoFromConnection) — without that defensive copy, markOracleServiceAction's "have I already set this for this connection?" flag would be shared across unrelated connections, and the second connection to a given URL would silently skip setClientInfo, breaking DBM correlation for it.

poolName/oracleServiceAction are per-Connection/session state; DBInfo is per-URL parse-result state that's cache-shared by design. Mixing them means correctness now depends on every call site remembering to copy — nothing in the type enforces it, so a future call site that reads DBInfo from the context map or extractDBInfo directly and forwards it without .toBuilder().build() reintroduces the cross-connection leak.

I'd rather keep DBInfo as the pure immutable parse result and track the mutable per-connection bits (poolName, oracleServiceAction) in their own holder keyed off InstrumentationContext.get(Connection.class, ...), which is already the correct scope this code relies on elsewhere.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

So, I tried to go this way with these new changes but this significantly increases the scope (and reviewers needed).

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

I think the mutable parts of DbInfo need to live elsewhere.
Please see inline comments for more details.

@datadog-datadog-prod-us1 datadog-datadog-prod-us1 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.

Datadog Autotest: FAIL

A BaseHash update can put one hash in Oracle ACTION and a different hash on the JDBC span. This mismatch prevents DBM correlation for that query.

Open Bits AI session

🤖 Datadog Autotest · Commit c8283cb · What is Autotest? · @DataDog review to ask questions · Any feedback? Reach out in #autotest

@joelmarcotte
joelmarcotte requested a review from a team as a code owner August 20, 2026 14:47

@datadog-datadog-prod-us1 datadog-datadog-prod-us1 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.

Datadog Autotest: PASS

More details

The opt-in path keeps Oracle statement text unchanged. It updates ACTION when BaseHash changes and keeps mutable ACTION state per connection. No concrete failure mode clears the reporting threshold.

Was this helpful? React 👍 or 👎

Open Bits AI session

🤖 Datadog Autotest · Commit 35692f7 · What is Autotest? · @DataDog review to ask questions · Any feedback? Reach out in #autotest

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

Labels

comp: database Database Monitoring inst: jdbc JDBC instrumentation tag: ai generated Largely based on code generated by an AI or LLM type: feature Enhancements and improvements

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants