feat(mariadb): migrate instrumentation from shimmer to orchestrion#7925
feat(mariadb): migrate instrumentation from shimmer to orchestrion#7925
Conversation
Overall package sizeSelf size: 5.49 MB Dependency sizes| name | version | self size | total size | |------|---------|-----------|------------| | import-in-the-middle | 3.0.1 | 82.56 kB | 817.39 kB | | dc-polyfill | 0.1.10 | 26.73 kB | 26.73 kB |🤖 This report was automatically generated by heaviest-objects-in-the-universe |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #7925 +/- ##
==========================================
- Coverage 74.25% 74.07% -0.19%
==========================================
Files 769 771 +2
Lines 36068 36095 +27
==========================================
- Hits 26783 26737 -46
- Misses 9285 9358 +73 Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
✅ Tests 🎉 All green!❄️ No new flaky tests detected 🎯 Code Coverage (details) 🔗 Commit SHA: ac1a089 | Docs | Datadog PR Page | Was this helpful? React with 👍/👎 or give us feedback! |
BenchmarksBenchmark execution time: 2026-04-07 21:09:24 Comparing candidate commit ac1a089 in PR branch Found 0 performance improvements and 0 performance regressions! Performance is the same for 231 metrics, 29 unstable metrics. |
…writer Replaces the legacy shimmer-based mariadb plugin with an orchestrion AST-rewriter approach, enabling proper async context propagation and eliminating the need for manual module patching. Key changes: - Add orchestrion instrumentation entries for mariadb (v2 and v3+) covering createConnection, createPool, Pool.getConnection, and all query/execute methods across callback and promise APIs - Add thisPropertyName query type to the rewriter for arrow function and regular function instance properties set in constructors - Add noCallbackFallback option to wrapCallback for fire-and-forget queries - Fix ArrowFunctionExpression → FunctionExpression conversion in traceFunction so arguments and this bindings work correctly - New plugin split into connection.js (context/conf tracking) and query.js (span creation), replacing the monolithic MySQLPlugin extension - Properly clear async context during createPool/createConnection so pool-internal TCP connections don't leak into user traces - Restore parent span context in callback/promise completions via bindAsyncStart - Tag peer.service in asyncEnd (orchestrion never fires the finish channel) - Support PrepareResultPacket.execute for prepared statement tracing Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…trion-config Replaces custom rewriter instrumentations/mariadb.js with entries in orchestrion-config/index.js using the standard YAML format. thisPropertyName is expressed as object_name/property_name per nodejs/orchestrion-js#58. noCallbackFallback entries are marked with TODO comments pending nodejs/orchestrion-js support. Reverts rewriter changes to transformer.js, transforms.js, instrumentations/index.js, and associated tests.
0cc0256 to
7dfab81
Compare
orchestrion-config/index.js is consumed by the AppSec IAST wasm rewriter, not the APM orchestrion system. The mariadb entries broke AppSec tests because the wasm rewriter does not support kind: callback.
Adds mariadb hook definitions to the rewriter instrumentations for v2 and v3+, covering createConnection, createPool, Pool.getConnection, and all query/execute methods across callback and promise APIs. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
What does this PR do?
Migrates the mariadb plugin from shimmer to orchestrion AST rewriter instrumentation.
Motivation
mariadb v3.5.1 moved to pure ESM. While
esmFirst: true+import-in-the-middlehandles ESM live bindings, it can't solve thesuper()problem: shimmer instruments instances by wrapping the constructor, but moving a constructor body that callssuper()into a nested function is aSyntaxError. The AST rewriter transforms source before execution and can inject instrumentation aroundsuper()without relocating it.For v2, query methods (
_queryPromise,_queryCallback, etc.) are arrow functions assigned tothisinside constructors — shimmer can't reach per-instance properties set this way. The rewriter'sthisPropertyNamesupport targets thesethis.foo = ...assignments directly.Key changes
packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/— add mariadb orchestrion hook definitions for v2 and v3+:createConnection,createPool,Pool.getConnection, and allquery/executemethods across callback and promise APIspackages/datadog-plugin-mariadb/— new plugin split intoconnection.js(context/conf tracking) andquery.js(span creation), replacing the monolithicMySQLPluginextensioncreatePool/createConnectionso pool-internal TCP connections don't become children of user spansbindAsyncStartpeer.serviceinasyncEnd(orchestrion does not fire thefinishchannel)PrepareResultPacket.executefor prepared statement tracingAdditional Notes
noCallbackFallback(fires channels synchronously when no callback is provided) required rewriter changes — entries needing this are marked with TODOs pending upstream supportthisPropertyNamehooks useobject_name: this/property_nameper nodejs/orchestrion-js#58