Skip to content

[reference] R2DBC net-new instrumentation — regen vs sharpened DB skill (toolkit output) - #12237

Draft
jordan-wong wants to merge 1 commit into
masterfrom
eval/r2dbc-regen-dbskill-20260818
Draft

[reference] R2DBC net-new instrumentation — regen vs sharpened DB skill (toolkit output)#12237
jordan-wong wants to merge 1 commit into
masterfrom
eval/r2dbc-regen-dbskill-20260818

Conversation

@jordan-wong

Copy link
Copy Markdown
Contributor

What

Toolkit-generated R2DBC instrumentation (io.r2dbc:r2dbc-spi:1.0.0.RELEASE), regenerated by the apm-instrumentation-toolkit against its sharpened database-category rules. This is a reference/research artifact — NOT a merge candidate. It supersedes nothing; the original reference PR #12032 stays as-is.

Generated module: dd-java-agent/instrumentation/r2dbc/r2dbc-1.0/.

Why this regen exists

#12032 was generated before the toolkit's database-category rules were sharpened (SPI-first targeting, eager connection-metadata capture, muzzle handling). This run tests whether the improved skill produces a better R2DBC — and it does, in architecture. But a live-trace comparison against the OpenTelemetry SDK surfaced that it still doesn't actually emit spans on a real driver, for a new, mechanical reason.

Improvement over #12032 (architecture)

The DBM feature step now hooks the OTel-correct entry point:

Known defect — the finding (do NOT fix on this branch)

The module is CI-green but emits ZERO spans on a real driver.

  • :check, :muzzle, :allLatestDepTests all pass; 11/11 unit tests pass.
  • But every advice declares a writable @Advice.Return(readOnly = false) Publisher<...>, while real driver methods return the concrete Mono/Flux. Byte Buddy refuses to bind the interface into the concrete return slot, so class transformation fails at runtime and the classes load uninstrumented:
Cannot assign interface org.reactivestreams.Publisher to class reactor.core.publisher.Mono
    → io.r2dbc.pool.ConnectionPool        (ConnectionFactoryCreateAdvice)
Cannot assign interface org.reactivestreams.Publisher to class reactor.core.publisher.Mono
    → io.r2dbc.h2.H2ConnectionFactory     (ConnectionFactoryCreateAdvice)
Cannot assign interface org.reactivestreams.Publisher to class reactor.core.publisher.Flux
    → io.r2dbc.h2.H2Statement             (StatementExecuteAdvice)

So the (correct) new connection-metadata architecture never runs. The SPI-fake test suite binds where real drivers won't, which is why CI is green.

Live verification — Spring Data R2DBC / H2 app (eugenp spring-reactive-data), GET /products ×3:

this PR (regen) #12032 OpenTelemetry Java 2.30.0
R2DBC spans 0 0 13
Byte Buddy transformation failures on real driver 3 1
Connection-metadata architecture ConnectionFactoryOptions (but dead) ✅ works
CI-equivalent ✅ BUILD SUCCESSFUL (was red on muzzle scaffolding)

Remediation (for a future working version, not this branch)

Type the writable @Advice.Return so Byte Buddy can bind it against a concrete-Mono/Flux-returning method — e.g. @Advice.Return(readOnly = false) Object + cast, or Advice.AssignReturned — on all three advices (ConnectionFactoryCreateAdvice, StatementExecuteAdvice, BatchExecuteAdvice). AND add at least one integration test against a real driver (r2dbc-h2), not only an SPI fake.

Provenance

  • Toolkit branch eval/java @ d9dcb160 (force-read DB rules R-DB-1..6).
  • Full write-up + generated-source snapshot + logs: apm-instrumentation-toolkit docs/eval-research/runs/r2dbc/attempt-dbskill-20260818/outcome.md and docs/eval-research/r2dbc-live-trace-comparison-2026-08-17.md.

🤖 Generated by apm-instrumentation-toolkit. Reference/research artifact — not a merge candidate.

…ll (toolkit output)

Toolkit-generated R2DBC instrumentation (io.r2dbc:r2dbc-spi:1.0.0.RELEASE),
regenerated against the apm-instrumentation-toolkit's sharpened database-category
rules. NOT a merge candidate — a research/reference artifact.

Improvement over the earlier reference PR #12032: the generator now hooks the
OTel-correct entry point — ConnectionFactory.create() + ConnectionFactoryOptions,
threaded via MetadataWrappingPublisher -> R2dbcConnectionInfo -> statement/batch
spans — and the decorator populates db.name/peer.hostname/db.user/peer.port.

KNOWN DEFECT (do not fix on this branch — it is the finding): the module is
CI-green (:check :muzzle :allLatestDepTests pass, 11/11 unit tests) but emits
ZERO spans on a real driver. Every advice declares a writable
@Advice.Return(readOnly=false) Publisher<...> against methods that return concrete
Mono/Flux, so Byte Buddy fails 3 class transformations at runtime
(io.r2dbc.pool.ConnectionPool, io.r2dbc.h2.H2ConnectionFactory,
io.r2dbc.h2.H2Statement: "Cannot assign interface org.reactivestreams.Publisher to
class reactor.core.publisher.Mono/Flux") and the classes load uninstrumented. The
SPI-fake test suite binds where real drivers won't, hiding the failure from CI.

Verified live against a Spring Data R2DBC / H2 app (eugenp spring-reactive-data):
0 R2DBC spans under this agent vs 13 under the OpenTelemetry Java agent 2.30.0.

Full write-up: apm-instrumentation-toolkit
docs/eval-research/runs/r2dbc/attempt-dbskill-20260818/outcome.md and
docs/eval-research/r2dbc-live-trace-comparison-2026-08-17.md.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@jordan-wong jordan-wong added tag: ai generated Largely based on code generated by an AI or LLM tag: apm integration toolkit Changes generated by DataDog/apm-instrumentation-toolkit as part of IDM AIT experimentation labels Aug 19, 2026
@datadog-prod-us1-4

datadog-prod-us1-4 Bot commented Aug 19, 2026

Copy link
Copy Markdown

🎯 Code Coverage (details)
Patch Coverage: 100.00%
Overall Coverage: 58.32% (-0.20%)

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

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

Labels

tag: ai generated Largely based on code generated by an AI or LLM tag: apm integration toolkit Changes generated by DataDog/apm-instrumentation-toolkit as part of IDM AIT experimentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant