Skip to content

Use TagExtractor for JDBC connection-info tags (canary)#11820

Draft
dougqh wants to merge 2 commits into
dougqh/tag-extractor-apifrom
dougqh/jdbc-tag-extractor
Draft

Use TagExtractor for JDBC connection-info tags (canary)#11820
dougqh wants to merge 2 commits into
dougqh/tag-extractor-apifrom
dougqh/jdbc-tag-extractor

Conversation

@dougqh

@dougqh dougqh commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Draft — stacked on #11817 (the TagContributor/TagExtractor API). First real use of the API; the canary for dissolving the decorators.

Lifts JDBCDecorator's JDBC-specific pure field→tag connection tags (db.warehouse / db.schema / db.pool.name — the setTagIfPresent block in onConnection) into ConnectionInfoExtractor, a named singleton TagExtractor<DBInfo>, applied via the span-first span.setTags(dbInfo, ConnectionInfoExtractor.INSTANCE) at the single onConnection site (monomorphic → the JIT inlines it). Behavior-identical: the extractor makes the same three setTagIfPresent calls via the same helper (now on the extractor class).

Scope (deliberately minimal)

Bucket-(b) pure extraction only, JDBC-only, no shared-base change. DB_TYPE / user / instance / hostname stay in the decorator — db.user moves in #11823; instance/hostname feed service-name derivation, which awaits the declarative-derivation step.

Perf

Perf-neutral by construction — the tags moved here were already direct setTagIfPresent calls (not the megamorphic template-method dispatches), and the extractor is monomorphic → inlines → same code as before. The dispatch-reduction win (N→1) lives in the template methods (dbUser/dbInstance/dbHostname), addressed in the stacked peels. See the synthetic TagProjectionBenchmark in #11817 for the mechanism.

Validation

JDBCInstrumentationV0Test green (87/87, incl. the db.warehouse/db.schema/db.pool.name assertions). Notably, ConnectionInfoExtractor — a separate top-level helper class (the old lambda used to compile into JDBCDecorator) — is auto-injected via transitive helper collection with no helperClassNames() edit. (RemoteJDBC* tests are postgres/mysql/sqlserver testcontainers — env-gated, CI-only.)

🤖 Generated with Claude Code

@dougqh dougqh added type: enhancement Enhancements and improvements tag: no release notes Changes to exclude from release notes inst: jdbc JDBC instrumentation tag: ai generated Largely based on code generated by an AI or LLM labels Jul 1, 2026
@datadog-prod-us1-6

datadog-prod-us1-6 Bot commented Jul 1, 2026

Copy link
Copy Markdown

🎯 Code Coverage (details)
Patch Coverage: 100.00%
Overall Coverage: 54.95% (+0.01%)

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 56d280d | Docs | Datadog PR Page | Give us feedback!

@dd-octo-sts

dd-octo-sts Bot commented Jul 1, 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.66 s 14.67 s [-1.0%; +0.7%] (no difference)
startup:insecure-bank:tracing:Agent 13.34 s 13.60 s [-2.6%; -1.2%] (significantly better)
startup:petclinic:appsec:Agent 16.96 s 17.32 s [-3.1%; -1.0%] (maybe better)
startup:petclinic:iast:Agent 16.92 s 17.59 s [-4.6%; -2.9%] (significantly better)
startup:petclinic:profiling:Agent 17.21 s 17.49 s [-2.6%; -0.7%] (maybe better)
startup:petclinic:sca:Agent 17.15 s 17.42 s [-2.5%; -0.5%] (maybe better)
startup:petclinic:tracing:Agent 16.33 s 16.71 s [-3.3%; -1.3%] (significantly better)

Commit: 56d280df · 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.

First real use of the TagExtractor mechanism: lifts the pure field->tag
connection tags (warehouse / schema / pool) out of JDBCDecorator into a
static-final non-capturing CONNECTION_INFO_EXTRACTOR, applied via the
span-first span.setTags(dbInfo, CONNECTION_INFO_EXTRACTOR) at the single
onConnection site (a monomorphic call site the JIT inlines). Behavior-
identical to the previous inline setTagIfPresent block.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@dougqh dougqh force-pushed the dougqh/jdbc-tag-extractor branch from 0cf3f5d to ccc7e0d Compare July 1, 2026 00:51
Turns the inline lambda into ConnectionInfoExtractor (a proper TagExtractor<DBInfo>
with a private-ctor INSTANCE singleton), mirroring PeerConnectionExtractor. Gives
it a name at the call site (span.setTags(dbInfo, ConnectionInfoExtractor.INSTANCE))
and makes it composable. The setTagIfPresent helper moves onto the class.

Verified auto-injected as a transitive helper (JDBCInstrumentationV0Test: 87/87
green) — no manual helperClassNames() entry needed.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

inst: jdbc JDBC instrumentation tag: ai generated Largely based on code generated by an AI or LLM tag: no release notes Changes to exclude from release notes type: enhancement Enhancements and improvements

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant