Peel dbUser out of DatabaseClientDecorator into a param-injected TagExtractor#11823
Draft
dougqh wants to merge 2 commits into
Draft
Peel dbUser out of DatabaseClientDecorator into a param-injected TagExtractor#11823dougqh wants to merge 2 commits into
dougqh wants to merge 2 commits into
Conversation
…xtractor The null-ratio scan showed dbUser was the sparsest template method on DatabaseClientDecorator: 28/30 leaves returned null (only JDBC and Vertx-SQL provide a real user). That sparsity is the SQL/NoSQL false-generalization showing through — db.user is a SQL-auth concept the NoSQL/cache stores can only answer with null, yet every DB span paid a virtual dbUser() call to set DB_USER=null. Replaces the dbUser template method with a param-injected connection-tags extractor: - DatabaseClientDecorator gains onConnection(span, conn, TagExtractor<C>); the 2-arg overload delegates with a shared no-op extractor. The extractor is passed as a caller-side constant so it devirtualizes+inlines at a monomorphic advice site (rather than a virtual provider method). dbInstance/dbHostname stay for now (they are DERIVED — feed service-name split — a later peel). - The 2 SQL providers set db.user themselves: JDBC folds it into ConnectionInfoExtractor; Vertx-SQL gets VertxSqlConnectionExtractor, both applied via the param form. db.user is set unconditionally to preserve the prior (present-check-free) behavior exactly. - The 26 NoSQL/cache decorators shed their dead `return null` dbUser override. Behavior-preserving. agent-bootstrap decorator tests updated (the mock interaction-asserts for the old mechanism; these are Spock migration candidates) and green; JDBCInstrumentationV0Test 87/87. Vertx-SQL's extractor is auto-injected as a transitive helper (its tests are container-gated / CI-only). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
🎯 Code Coverage (details) 🔗 Commit SHA: f4cad21 | Docs | Datadog PR Page | Give us feedback! |
Acceptance harness for the dbUser peel's inlining claim. Exercises the real DatabaseClientDecorator.onConnection param-form at a mono call site (one static-final extractor — the production shape) vs mega (8 rotating extractor types — the worst case of a single shared site). PrintInlining (mono) confirms the chain collapses: DatabaseClientDecorator ::onConnection inline (hot) and the concrete extractor's extract() devirtualizes and inlines (the abstract TagExtractor::extract slot is bypassed). mega only costs ~14% here because the trivial extractor bodies fit HotSpot's polymorphic inline ceiling; larger real bodies would fall to a virtual call sooner, so mega is an optimistic worst-case. The production shape is mono. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Contributor
🟢 Java Benchmark SLOs — All performance SLOs passed
PR vs. master results
Commit: Load and DaCapo benchmarks can be triggered manually in the GitLab pipeline. Results will appear in the Benchmarking Platform UI after completion. |
This was referenced Jul 1, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
First real dissolution of the DB decorator hierarchy: removes the
dbUsertemplate method fromDatabaseClientDecoratorand replaces it with a param-injected connection-tagsTagExtractor. Stacked on #11820.Why dbUser
A null-ratio scan of the DB template methods flagged it as the sparsest: 28/30 leaves returned
null— only JDBC and Vertx-SQL provide a real user. That sparsity is the SQL/NoSQL false-generalization showing through:db.useris a SQL-auth concept the NoSQL/cache stores (Redis, Mongo, Cassandra, …) can only answer withnull, yet every DB span paid a virtualdbUser()call to setDB_USER = null. (dbInstance0.65 /dbHostname0.52 are next, but they're DERIVED — they feed service-name split — so they wait on the declarative-derivation layer.)The pattern (param-injected extractor)
DatabaseClientDecoratorgainsonConnection(span, conn, TagExtractor<CONNECTION>); the 2-arg overload delegates with a shared no-op extractor. The extractor is passed as a caller-sidestatic finalconstant, so at a monomorphic advice site it devirtualizes + inlines whenonConnectioninlines — the key advantage over a virtualconnectionExtractor()provider (which would re-megamorphize). This is also the seam for disentangling pure extraction from side-effects in the harder decorators later.Changes
onConnection+ no-op default; removeabstract dbUserand thesetTag(DB_USER, …)line.db.userintoConnectionInfoExtractor, apply viasuper.onConnection(..., INSTANCE).VertxSqlConnectionExtractor, applied via the param form at itssuper.onConnectioncall (the provider-with-no-override case the param form is for).dbUser→nulloverride.DatabaseClientConnectionBenchmark(jmh): the inlining acceptance harness (below).Net −71 lines.
db.useris set unconditionally by the two providers to preserve the prior (present-check-free) behavior exactly.Inlining verification (the acceptance test — done)
DatabaseClientConnectionBenchmarkexercises the real param-formonConnectionat a mono site (onestatic finalextractor — the production shape) vs mega (8 rotating extractor types — worst case).-XX:+PrintInlining:DatabaseClientDecorator::onConnection — inline (hot)and the concrete extractor'sextract() — inline (hot)(the abstractTagExtractor::extractslot is bypassed). Full devirt + inline. 79.0M ops/s.So the devirt claim holds at a monomorphic site.
Testing
agent-bootstrapdecorator tests updated + green (incl. new param-form coverage). These are mock interaction-asserts for the old mechanism — flagged as Spock→JUnit migration candidates, not migrated here to keep the PR focused.JDBCInstrumentationV0Test: 87/87;ConnectionInfoExtractor(now incl.db.user) auto-injected as a transitive helper — nohelperClassNames()edit.VertxSqlConnectionExtractorrides the same transitive-helper collection (VertxSqlClientDecoratoris an explicit helper).Follow-ups
dbInstance/dbHostnamepeel — gated on the declarative-derivation layer (their values feedsetServiceName, a computed side-effect, not just a tag). Until that lands,onConnection(and its 2-arg overload) stays as the wrapper around that derivation.DatabaseClientDecoratorTestcascade.🤖 Generated with Claude Code