@sentry/server-utils 10.58.0 → 10.60.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. package/build/cjs/integrations/tracing-channel/mysql.js +137 -0
  2. package/build/cjs/integrations/tracing-channel/mysql.js.map +1 -0
  3. package/build/cjs/orchestrion/bundler/vite.js +34 -0
  4. package/build/cjs/orchestrion/bundler/vite.js.map +1 -0
  5. package/build/cjs/orchestrion/channels.js +8 -0
  6. package/build/cjs/orchestrion/channels.js.map +1 -0
  7. package/build/cjs/orchestrion/config.js +38 -0
  8. package/build/cjs/orchestrion/config.js.map +1 -0
  9. package/build/cjs/orchestrion/detect.js +20 -0
  10. package/build/cjs/orchestrion/detect.js.map +1 -0
  11. package/build/cjs/orchestrion/index.js +10 -0
  12. package/build/cjs/orchestrion/index.js.map +1 -0
  13. package/build/cjs/orchestrion/runtime/register.js +50 -0
  14. package/build/cjs/orchestrion/runtime/register.js.map +1 -0
  15. package/build/cjs/redis/redis-dc-subscriber.js +12 -16
  16. package/build/cjs/redis/redis-dc-subscriber.js.map +1 -1
  17. package/build/esm/integrations/tracing-channel/mysql.js +135 -0
  18. package/build/esm/integrations/tracing-channel/mysql.js.map +1 -0
  19. package/build/esm/orchestrion/bundler/vite.js +32 -0
  20. package/build/esm/orchestrion/bundler/vite.js.map +1 -0
  21. package/build/esm/orchestrion/channels.js +6 -0
  22. package/build/esm/orchestrion/channels.js.map +1 -0
  23. package/build/esm/orchestrion/config.js +34 -0
  24. package/build/esm/orchestrion/config.js.map +1 -0
  25. package/build/esm/orchestrion/detect.js +18 -0
  26. package/build/esm/orchestrion/detect.js.map +1 -0
  27. package/build/esm/orchestrion/index.js +3 -0
  28. package/build/esm/orchestrion/index.js.map +1 -0
  29. package/build/esm/orchestrion/runtime/register.js +48 -0
  30. package/build/esm/orchestrion/runtime/register.js.map +1 -0
  31. package/build/esm/package.json +1 -1
  32. package/build/esm/redis/redis-dc-subscriber.js +12 -16
  33. package/build/esm/redis/redis-dc-subscriber.js.map +1 -1
  34. package/build/orchestrion/import-hook.mjs +19 -0
  35. package/build/types/integrations/tracing-channel/mysql.d.ts +10 -0
  36. package/build/types/integrations/tracing-channel/mysql.d.ts.map +1 -0
  37. package/build/types/orchestrion/bundler/vite.d.ts +31 -0
  38. package/build/types/orchestrion/bundler/vite.d.ts.map +1 -0
  39. package/build/types/orchestrion/channels.d.ts +18 -0
  40. package/build/types/orchestrion/channels.d.ts.map +1 -0
  41. package/build/types/orchestrion/config.d.ts +35 -0
  42. package/build/types/orchestrion/config.d.ts.map +1 -0
  43. package/build/types/orchestrion/detect.d.ts +23 -0
  44. package/build/types/orchestrion/detect.d.ts.map +1 -0
  45. package/build/types/orchestrion/index.d.ts +3 -0
  46. package/build/types/orchestrion/index.d.ts.map +1 -0
  47. package/build/types/orchestrion/runtime/register.d.ts +23 -0
  48. package/build/types/orchestrion/runtime/register.d.ts.map +1 -0
  49. package/build/types/redis/redis-dc-subscriber.d.ts.map +1 -1
  50. package/build/types-ts3.8/integrations/tracing-channel/mysql.d.ts +10 -0
  51. package/build/types-ts3.8/orchestrion/bundler/vite.d.ts +31 -0
  52. package/build/types-ts3.8/orchestrion/channels.d.ts +18 -0
  53. package/build/types-ts3.8/orchestrion/config.d.ts +35 -0
  54. package/build/types-ts3.8/orchestrion/detect.d.ts +23 -0
  55. package/build/types-ts3.8/orchestrion/index.d.ts +3 -0
  56. package/build/types-ts3.8/orchestrion/runtime/register.d.ts +23 -0
  57. package/package.json +76 -11
@@ -0,0 +1,135 @@
1
+ import * as diagnosticsChannel from 'node:diagnostics_channel';
2
+ import { defineIntegration, debug, SPAN_STATUS_ERROR, startInactiveSpan, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, getActiveSpan, withActiveSpan } from '@sentry/core';
3
+ import { DEBUG_BUILD } from '../../debug-build.js';
4
+ import { CHANNELS } from '../../orchestrion/channels.js';
5
+
6
+ const INTEGRATION_NAME = "Mysql";
7
+ const ATTR_DB_SYSTEM = "db.system";
8
+ const ATTR_DB_CONNECTION_STRING = "db.connection_string";
9
+ const ATTR_DB_NAME = "db.name";
10
+ const ATTR_DB_USER = "db.user";
11
+ const ATTR_DB_STATEMENT = "db.statement";
12
+ const ATTR_NET_PEER_NAME = "net.peer.name";
13
+ const ATTR_NET_PEER_PORT = "net.peer.port";
14
+ const _mysqlChannelIntegration = (() => {
15
+ return {
16
+ name: INTEGRATION_NAME,
17
+ setupOnce() {
18
+ DEBUG_BUILD && debug.log(`[orchestrion:mysql] subscribing to channel "${CHANNELS.MYSQL_QUERY}"`);
19
+ const queryCh = diagnosticsChannel.tracingChannel(CHANNELS.MYSQL_QUERY);
20
+ const spans = /* @__PURE__ */ new WeakMap();
21
+ queryCh.subscribe({
22
+ start(rawCtx) {
23
+ const ctx = rawCtx;
24
+ const sql = extractSql(ctx.arguments[0]);
25
+ const { host, port, database, user } = getConnectionConfig(ctx.self);
26
+ const portNumber = typeof port === "string" ? parseInt(port, 10) : port;
27
+ const portIsNumber = typeof portNumber === "number" && !isNaN(portNumber);
28
+ const span = startInactiveSpan({
29
+ name: sql ?? "mysql.query",
30
+ op: "db",
31
+ attributes: {
32
+ [ATTR_DB_SYSTEM]: "mysql",
33
+ [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: "auto.db.orchestrion.mysql",
34
+ [ATTR_DB_CONNECTION_STRING]: getJDBCString(host, portIsNumber ? portNumber : void 0, database),
35
+ ...database ? { [ATTR_DB_NAME]: database } : {},
36
+ ...user ? { [ATTR_DB_USER]: user } : {},
37
+ ...sql ? { [ATTR_DB_STATEMENT]: sql } : {},
38
+ ...host ? { [ATTR_NET_PEER_NAME]: host } : {},
39
+ ...portIsNumber ? { [ATTR_NET_PEER_PORT]: portNumber } : {}
40
+ }
41
+ });
42
+ spans.set(rawCtx, span);
43
+ const parentSpan = getActiveSpan();
44
+ if (parentSpan && ctx.arguments.length > 0) {
45
+ const cbIdx = ctx.arguments.length - 1;
46
+ const orchestrionWrappedCb = ctx.arguments[cbIdx];
47
+ if (typeof orchestrionWrappedCb === "function") {
48
+ const wrapped = orchestrionWrappedCb;
49
+ ctx.arguments[cbIdx] = function(...args) {
50
+ return withActiveSpan(parentSpan, () => wrapped.apply(this, args));
51
+ };
52
+ }
53
+ }
54
+ },
55
+ end(rawCtx) {
56
+ const ctx = rawCtx;
57
+ if (ctx.error !== void 0) {
58
+ finishSpan(rawCtx);
59
+ return;
60
+ }
61
+ const result = ctx.result;
62
+ if (result && typeof result === "object" && hasOnMethod(result)) {
63
+ const span = spans.get(rawCtx);
64
+ if (!span) return;
65
+ result.on("error", (err) => {
66
+ span.setStatus({
67
+ code: SPAN_STATUS_ERROR,
68
+ message: err instanceof Error ? err.message : "unknown_error"
69
+ });
70
+ finishSpan(rawCtx);
71
+ });
72
+ result.on("end", () => finishSpan(rawCtx));
73
+ return;
74
+ }
75
+ },
76
+ error(rawCtx) {
77
+ const ctx = rawCtx;
78
+ const span = spans.get(rawCtx);
79
+ if (!span) return;
80
+ span.setStatus({
81
+ code: SPAN_STATUS_ERROR,
82
+ message: ctx.error instanceof Error ? ctx.error.message : "unknown_error"
83
+ });
84
+ },
85
+ asyncStart() {
86
+ },
87
+ asyncEnd(rawCtx) {
88
+ finishSpan(rawCtx);
89
+ }
90
+ });
91
+ function finishSpan(rawCtx) {
92
+ const span = spans.get(rawCtx);
93
+ if (!span) return;
94
+ span.end();
95
+ spans.delete(rawCtx);
96
+ }
97
+ }
98
+ };
99
+ });
100
+ function hasOnMethod(obj) {
101
+ return "on" in obj && typeof obj.on === "function";
102
+ }
103
+ function extractSql(firstArg) {
104
+ if (typeof firstArg === "string") {
105
+ return firstArg;
106
+ }
107
+ if (firstArg && typeof firstArg === "object" && "sql" in firstArg) {
108
+ const sql = firstArg.sql;
109
+ return typeof sql === "string" ? sql : void 0;
110
+ }
111
+ return void 0;
112
+ }
113
+ function getConnectionConfig(connection) {
114
+ const config = connection?.config?.connectionConfig ?? connection?.config ?? {};
115
+ return {
116
+ host: config.host,
117
+ port: config.port,
118
+ database: config.database,
119
+ user: config.user
120
+ };
121
+ }
122
+ function getJDBCString(host, port, database) {
123
+ let s = `jdbc:mysql://${host || "localhost"}`;
124
+ if (typeof port === "number") {
125
+ s += `:${port}`;
126
+ }
127
+ if (database) {
128
+ s += `/${database}`;
129
+ }
130
+ return s;
131
+ }
132
+ const mysqlChannelIntegration = defineIntegration(_mysqlChannelIntegration);
133
+
134
+ export { mysqlChannelIntegration };
135
+ //# sourceMappingURL=mysql.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mysql.js","sources":["../../../../src/integrations/tracing-channel/mysql.ts"],"sourcesContent":["import * as diagnosticsChannel from 'node:diagnostics_channel';\nimport type { IntegrationFn, Span } from '@sentry/core';\nimport {\n debug,\n defineIntegration,\n getActiveSpan,\n SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,\n SPAN_STATUS_ERROR,\n startInactiveSpan,\n withActiveSpan,\n} from '@sentry/core';\nimport { DEBUG_BUILD } from '../../debug-build';\nimport { CHANNELS } from '../../orchestrion/channels';\n\n// NOTE: this uses the same name as the OTel integration by design.\n// When enabled, OTel 'Mysql' integration is omitted from the default set.\nconst INTEGRATION_NAME = 'Mysql';\n\n// OpenTelemetry \"OLD\" db/net semantic-conventions. We inline them rather than\n// importing `@opentelemetry/semantic-conventions` to keep this integration's\n// dependency surface free of OTel — orchestrion's whole point is to step away\n// from the OTel auto-instrumentation stack.\n//\n// We emit the OLD conventions to match `@opentelemetry/instrumentation-mysql`'s\n// default (it only emits the stable `db.system.name` / `db.query.text` set when\n// `OTEL_SEMCONV_STABILITY_OPT_IN=database` is opted into) and the rest of the\n// Sentry JS SDK, whose `inferDbSpanData` processor renames spans based on\n// `db.statement`.\nconst ATTR_DB_SYSTEM = 'db.system';\nconst ATTR_DB_CONNECTION_STRING = 'db.connection_string';\nconst ATTR_DB_NAME = 'db.name';\nconst ATTR_DB_USER = 'db.user';\nconst ATTR_DB_STATEMENT = 'db.statement';\nconst ATTR_NET_PEER_NAME = 'net.peer.name';\nconst ATTR_NET_PEER_PORT = 'net.peer.port';\n\n/**\n * The shape orchestrion's wrapCallback transform attaches to the tracing-channel\n * `context` object. Documented here rather than imported because orchestrion's\n * runtime doesn't export it — see `node_modules/@apm-js-collab/code-transformer/lib/transforms.js`.\n *\n * `arguments` is the *live* args array the wrapper passes to the wrapped function:\n * orchestrion splices the user's callback out and inserts its own wrapper at\n * the same index before publishing `start`. We mutate that last entry again in\n * our `start` hook so the callback (and any nested `connection.query(...)`)\n * runs inside `withActiveSpan(parent, …)` — mysql v2 loses ALS state when it\n * dispatches callbacks from its socket handler, which would otherwise cause\n * nested queries to begin a fresh root trace.\n */\ninterface MysqlQueryChannelContext {\n arguments: unknown[];\n self?: MysqlConnection;\n moduleVersion?: string;\n result?: unknown;\n error?: unknown;\n}\n\ninterface MysqlConnectionConfig {\n host?: string;\n port?: number | string;\n database?: string;\n user?: string;\n // Pool connections nest the real config one level deeper.\n connectionConfig?: MysqlConnectionConfig;\n}\n\ninterface MysqlConnection {\n config?: MysqlConnectionConfig;\n}\n\nconst _mysqlChannelIntegration = (() => {\n return {\n name: INTEGRATION_NAME,\n setupOnce() {\n DEBUG_BUILD && debug.log(`[orchestrion:mysql] subscribing to channel \"${CHANNELS.MYSQL_QUERY}\"`);\n const queryCh = diagnosticsChannel.tracingChannel(CHANNELS.MYSQL_QUERY);\n\n // Each `context` object is shared across start/end/asyncStart/asyncEnd/error\n // for one call (orchestrion creates one per invocation). We key the span\n // off the same identity. WeakMap so we don't leak if a path never reaches\n // asyncEnd for some reason.\n const spans = new WeakMap<object, Span>();\n\n // `subscribe()` requires all five lifecycle hooks. The orchestrion\n // `wrapAuto` transform fires events in one of four orders depending on\n // call shape:\n // - sync throw : start → error → end\n // (NO asyncEnd)\n // - async-callback error : start → end → error →\n // asyncStart → asyncEnd\n // - async-callback success : start → end → asyncStart →\n // asyncEnd\n // - no-callback (streamable Query) : start → end\n // (ctx.result is the Query\n // emitter, no async events)\n //\n // We end the span on `asyncEnd` for the two callback paths (so the span\n // covers the full network round-trip + callback duration). For the\n // sync-throw path, `end` finishes the span because `ctx.error` is set\n // there. For the streamable no-callback path, `end` finishes by\n // attaching `'end'`/`'error'` listeners to `ctx.result` (the returned\n // `Query` emitter).\n //\n // The discriminator between \"end fired before any error\" and \"end fired\n // after a sync throw\" is whether `ctx.error` is set when `end` runs —\n // orchestrion populates it before publishing `error`. The discriminator\n // between callback and no-callback is whether `ctx.result` is set — only\n // the `wrapPromise` (no-callback) path stores it.\n queryCh.subscribe({\n start(rawCtx) {\n const ctx = rawCtx as MysqlQueryChannelContext;\n const sql = extractSql(ctx.arguments[0]);\n const { host, port, database, user } = getConnectionConfig(ctx.self);\n const portNumber = typeof port === 'string' ? parseInt(port, 10) : port;\n const portIsNumber = typeof portNumber === 'number' && !isNaN(portNumber);\n\n const span = startInactiveSpan({\n name: sql ?? 'mysql.query',\n op: 'db',\n attributes: {\n [ATTR_DB_SYSTEM]: 'mysql',\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.db.orchestrion.mysql',\n [ATTR_DB_CONNECTION_STRING]: getJDBCString(host, portIsNumber ? portNumber : undefined, database),\n ...(database ? { [ATTR_DB_NAME]: database } : {}),\n ...(user ? { [ATTR_DB_USER]: user } : {}),\n ...(sql ? { [ATTR_DB_STATEMENT]: sql } : {}),\n ...(host ? { [ATTR_NET_PEER_NAME]: host } : {}),\n ...(portIsNumber ? { [ATTR_NET_PEER_PORT]: portNumber } : {}),\n },\n });\n spans.set(rawCtx, span);\n\n // Restore the Sentry/OTel context across mysql's internal callback\n // dispatch. The orchestrion transform has already spliced the user's\n // callback out of `ctx.arguments` and put its own wrapper\n // (`__apm$wrappedCb`) at the same index. mysql v2 drains callbacks\n // from a socket data handler — by the time the response arrives, the\n // AsyncLocalStorage store backing `getActiveSpan()` no longer\n // reflects the caller's context. We re-wrap orchestrion's wrapper so\n // the user's callback (and any nested `connection.query(...)` inside\n // it) runs with the parent span active again.\n //\n // This must happen at `start` (we're synchronously inside the\n // caller's `connection.query` call, so OTel context is still\n // correct). `asyncStart`/`asyncEnd` fire from the same lost context\n // as the callback itself, so they're too late.\n const parentSpan = getActiveSpan();\n if (parentSpan && ctx.arguments.length > 0) {\n const cbIdx = ctx.arguments.length - 1;\n const orchestrionWrappedCb = ctx.arguments[cbIdx];\n if (typeof orchestrionWrappedCb === 'function') {\n const wrapped = orchestrionWrappedCb as (...a: unknown[]) => unknown;\n ctx.arguments[cbIdx] = function (this: unknown, ...args: unknown[]): unknown {\n return withActiveSpan(parentSpan, () => wrapped.apply(this, args));\n };\n }\n }\n },\n\n end(rawCtx) {\n const ctx = rawCtx as MysqlQueryChannelContext;\n\n // Sync throw: `end` fires AFTER `error` (both inside the wrapper's\n // `try/catch/finally`), so `ctx.error` is already set. Close the\n // span now since no `asyncEnd` will fire.\n if (ctx.error !== undefined) {\n finishSpan(rawCtx);\n return;\n }\n\n // No-callback (streamable Query) path: orchestrion's `wrapPromise`\n // stores the synchronous return value on `ctx.result` and never\n // fires `asyncStart`/`asyncEnd`. The returned `Query` is an\n // `EventEmitter` that emits `'end'` on success and `'error'` on\n // failure — hook those to close the span.\n // TODO: streaming spans aren't finished on `connection.destroy()` —\n // mysql guarantees no further events/callbacks for a destroyed\n // connection, so neither `'end'` nor `'error'` fires and the span\n // never ends (it's dropped, never reported). Closing this gap needs\n // connection-level lifecycle hooks, which the per-query channel\n // context doesn't expose here. The `WeakMap` still prevents a leak.\n const result = ctx.result;\n if (result && typeof result === 'object' && hasOnMethod(result)) {\n const span = spans.get(rawCtx);\n if (!span) return;\n result.on('error', err => {\n span.setStatus({\n code: SPAN_STATUS_ERROR,\n message: err instanceof Error ? err.message : 'unknown_error',\n });\n // Defensive: end the span here too in case `'end'` never fires\n // (e.g. abrupt socket destruction). `finishSpan` is idempotent —\n // `spans.delete` makes the subsequent `'end'` listener a no-op.\n finishSpan(rawCtx);\n });\n result.on('end', () => finishSpan(rawCtx));\n return;\n }\n\n // Callback path: `asyncEnd` will close the span. Nothing to do here.\n },\n\n error(rawCtx) {\n const ctx = rawCtx as MysqlQueryChannelContext;\n const span = spans.get(rawCtx);\n if (!span) return;\n span.setStatus({\n code: SPAN_STATUS_ERROR,\n message: ctx.error instanceof Error ? ctx.error.message : 'unknown_error',\n });\n },\n\n asyncStart() {\n // No-op: we end on `asyncEnd` so the span covers the full callback duration.\n },\n\n asyncEnd(rawCtx) {\n finishSpan(rawCtx);\n },\n });\n\n function finishSpan(rawCtx: object): void {\n const span = spans.get(rawCtx);\n if (!span) return;\n span.end();\n spans.delete(rawCtx);\n }\n },\n };\n}) satisfies IntegrationFn;\n\nfunction hasOnMethod(obj: object): obj is { on: (event: string, listener: (arg?: unknown) => void) => unknown } {\n return 'on' in obj && typeof (obj as { on?: unknown }).on === 'function';\n}\n\nfunction extractSql(firstArg: unknown): string | undefined {\n if (typeof firstArg === 'string') {\n return firstArg;\n }\n if (firstArg && typeof firstArg === 'object' && 'sql' in firstArg) {\n const sql = (firstArg as { sql?: unknown }).sql;\n return typeof sql === 'string' ? sql : undefined;\n }\n return undefined;\n}\n\nfunction getConnectionConfig(connection: MysqlConnection | undefined): {\n host?: string;\n port?: number | string;\n database?: string;\n user?: string;\n} {\n // Pool connections nest the real config under `.connectionConfig`; single\n // connections expose it directly. Matches `@opentelemetry/instrumentation-mysql`.\n const config = connection?.config?.connectionConfig ?? connection?.config ?? {};\n return {\n host: config.host,\n port: config.port,\n database: config.database,\n user: config.user,\n };\n}\n\nfunction getJDBCString(host: string | undefined, port: number | undefined, database: string | undefined): string {\n let s = `jdbc:mysql://${host || 'localhost'}`;\n if (typeof port === 'number') {\n s += `:${port}`;\n }\n if (database) {\n s += `/${database}`;\n }\n return s;\n}\n\n/**\n * EXPERIMENTAL — orchestrion-driven mysql integration.\n *\n * Subscribes to the `orchestrion:mysql:query` diagnostics_channel that the\n * orchestrion code transform injects into `mysql/lib/Connection.js`'s\n * `Connection.prototype.query`. Requires the orchestrion runtime hook or\n * bundler plugin to be active — wire that up via `_experimentalSetupOrchestrion`.\n */\nexport const mysqlChannelIntegration = defineIntegration(_mysqlChannelIntegration);\n"],"names":[],"mappings":";;;;;AAgBA,MAAM,gBAAA,GAAmB,OAAA;AAYzB,MAAM,cAAA,GAAiB,WAAA;AACvB,MAAM,yBAAA,GAA4B,sBAAA;AAClC,MAAM,YAAA,GAAe,SAAA;AACrB,MAAM,YAAA,GAAe,SAAA;AACrB,MAAM,iBAAA,GAAoB,cAAA;AAC1B,MAAM,kBAAA,GAAqB,eAAA;AAC3B,MAAM,kBAAA,GAAqB,eAAA;AAoC3B,MAAM,4BAA4B,MAAM;AACtC,EAAA,OAAO;AAAA,IACL,IAAA,EAAM,gBAAA;AAAA,IACN,SAAA,GAAY;AACV,MAAA,WAAA,IAAe,KAAA,CAAM,GAAA,CAAI,CAAA,4CAAA,EAA+C,QAAA,CAAS,WAAW,CAAA,CAAA,CAAG,CAAA;AAC/F,MAAA,MAAM,OAAA,GAAU,kBAAA,CAAmB,cAAA,CAAe,QAAA,CAAS,WAAW,CAAA;AAMtE,MAAA,MAAM,KAAA,uBAAY,OAAA,EAAsB;AA2BxC,MAAA,OAAA,CAAQ,SAAA,CAAU;AAAA,QAChB,MAAM,MAAA,EAAQ;AACZ,UAAA,MAAM,GAAA,GAAM,MAAA;AACZ,UAAA,MAAM,GAAA,GAAM,UAAA,CAAW,GAAA,CAAI,SAAA,CAAU,CAAC,CAAC,CAAA;AACvC,UAAA,MAAM,EAAE,MAAM,IAAA,EAAM,QAAA,EAAU,MAAK,GAAI,mBAAA,CAAoB,IAAI,IAAI,CAAA;AACnE,UAAA,MAAM,aAAa,OAAO,IAAA,KAAS,WAAW,QAAA,CAAS,IAAA,EAAM,EAAE,CAAA,GAAI,IAAA;AACnE,UAAA,MAAM,eAAe,OAAO,UAAA,KAAe,QAAA,IAAY,CAAC,MAAM,UAAU,CAAA;AAExE,UAAA,MAAM,OAAO,iBAAA,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Q,WAAW,CAAA,CAAA;AAC3C,EAAA,IAAI,OAAO,SAAS,QAAA,EAAU;AAC5B,IAAA,CAAA,IAAK,IAAI,IAAI,CAAA,CAAA;AAAA,EACf;AACA,EAAA,IAAI,QAAA,EAAU;AACZ,IAAA,CAAA,IAAK,IAAI,QAAQ,CAAA,CAAA;AAAA,EACnB;AACA,EAAA,OAAO,CAAA;AACT;AAUO,MAAM,uBAAA,GAA0B,kBAAkB,wBAAwB;;;;"}
@@ -0,0 +1,32 @@
1
+ import codeTransformer from '@apm-js-collab/code-transformer-bundler-plugins/vite';
2
+ import MagicString from 'magic-string';
3
+ import { SENTRY_INSTRUMENTATIONS, INSTRUMENTED_MODULE_NAMES } from '../config.js';
4
+
5
+ function sentryOrchestrionPlugin() {
6
+ const codeTransformerPlugins = codeTransformer({ instrumentations: SENTRY_INSTRUMENTATIONS });
7
+ const codeTransformerArray = Array.isArray(codeTransformerPlugins) ? codeTransformerPlugins : [codeTransformerPlugins];
8
+ return [bundlerMarkerPlugin(), ...codeTransformerArray];
9
+ }
10
+ function bundlerMarkerPlugin() {
11
+ const banner = [
12
+ "globalThis.__SENTRY_ORCHESTRION__ = (globalThis.__SENTRY_ORCHESTRION__ || {});",
13
+ "globalThis.__SENTRY_ORCHESTRION__.bundler = true;",
14
+ ""
15
+ ].join("\n");
16
+ return {
17
+ name: "sentry-orchestrion-marker",
18
+ enforce: "pre",
19
+ config() {
20
+ return { ssr: { noExternal: INSTRUMENTED_MODULE_NAMES } };
21
+ },
22
+ renderChunk(code, chunk) {
23
+ if (!chunk.isEntry) return null;
24
+ const ms = new MagicString(code);
25
+ ms.prepend(banner);
26
+ return { code: ms.toString(), map: ms.generateMap({ hires: true }) };
27
+ }
28
+ };
29
+ }
30
+
31
+ export { sentryOrchestrionPlugin };
32
+ //# sourceMappingURL=vite.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vite.js","sources":["../../../../src/orchestrion/bundler/vite.ts"],"sourcesContent":["// EXPERIMENTAL — Vite plugin that runs the orchestrion code transform at build\n// time, injecting `diagnostics_channel.tracingChannel` calls into the libraries\n// listed in `SENTRY_INSTRUMENTATIONS`.\n//\n// This file is published ESM-only via the `@sentry/server-utils/orchestrion/vite`\n// subpath export. `@apm-js-collab/code-transformer-bundler-plugins` is\n// `\"type\": \"module\"`, so consuming it from a CJS build is intentionally\n// unsupported — vite.config.ts is almost always ESM in practice. The CJS\n// rollup variant still emits this file, but `package.json` only exposes the\n// ESM entry, so attempts to `require('@sentry/server-utils/orchestrion/vite')` will\n// fail at resolution time rather than producing a half-broken plugin.\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype UnknownPlugin = any;\n\nimport codeTransformer from '@apm-js-collab/code-transformer-bundler-plugins/vite';\nimport MagicString from 'magic-string';\nimport { INSTRUMENTED_MODULE_NAMES, SENTRY_INSTRUMENTATIONS } from '../config';\n\n// `vite` types live in the package's ESM-only subpath; under Node16 module\n// resolution with TS treating @sentry/server-utils as CJS, importing them produces a\n// false positive. We don't need the runtime value for typing — `UnknownPlugin`\n// is sufficient — so we omit the import entirely.\n\n/**\n * Vite plugin that runs the orchestrion code transform on the bundled output.\n *\n * Use when bundling a Node app with Vite (e.g. Vite SSR builds, Nuxt's Nitro\n * pipeline, SvelteKit). For unbundled Node processes use the runtime hook\n * instead (`node --import @sentry/node/orchestrion app.js`).\n *\n * Returns two plugins:\n * 1. `sentry-orchestrion-marker` — a `renderChunk` hook that prepends a\n * single-line banner to entry chunks. The banner sets\n * `globalThis.__SENTRY_ORCHESTRION__.bundler = true` at app boot, so the\n * `_experimentalSetupOrchestrion()` detector can confirm the bundler path\n * ran (rather than relying on a build-time flag that wouldn't be visible\n * to the runtime).\n * Also injects every instrumented package name into `ssr.noExternal` via\n * the `config` hook, since externalized deps are `require()`d at runtime\n * from `node_modules` and never pass through the transform.\n * 2. The upstream `@apm-js-collab/code-transformer-bundler-plugins/vite`\n * plugin, fed our central `SENTRY_INSTRUMENTATIONS` config.\n *\n * @example\n * ```ts\n * // vite.config.ts\n * import { sentryOrchestrionPlugin } from '@sentry/node/orchestrion/vite';\n * export default { plugins: [sentryOrchestrionPlugin()] };\n * ```\n */\nexport function sentryOrchestrionPlugin(): UnknownPlugin[] {\n const codeTransformerPlugins = codeTransformer({ instrumentations: SENTRY_INSTRUMENTATIONS });\n const codeTransformerArray: UnknownPlugin[] = Array.isArray(codeTransformerPlugins)\n ? codeTransformerPlugins\n : [codeTransformerPlugins];\n return [bundlerMarkerPlugin(), ...codeTransformerArray];\n}\n\nfunction bundlerMarkerPlugin(): UnknownPlugin {\n const banner = [\n 'globalThis.__SENTRY_ORCHESTRION__ = (globalThis.__SENTRY_ORCHESTRION__ || {});',\n 'globalThis.__SENTRY_ORCHESTRION__.bundler = true;',\n '',\n ].join('\\n');\n\n return {\n name: 'sentry-orchestrion-marker',\n enforce: 'pre' as const,\n config(): { ssr: { noExternal: string[] } } {\n // Force-bundle every instrumented package so the code transform actually\n // sees its source. Vite externalizes dependencies in SSR builds by\n // default, leaving them as bare `require()`/`import` calls resolved from\n // `node_modules` at runtime — those copies are untouched and the\n // diagnostics_channel calls never get injected. Vite merges array\n // `noExternal` entries with the user's config, so we don't overwrite\n // their additions.\n return { ssr: { noExternal: INSTRUMENTED_MODULE_NAMES } };\n },\n renderChunk(code: string, chunk: { isEntry: boolean }): { code: string; map: unknown } | null {\n if (!chunk.isEntry) return null;\n // Prepend via magic-string so the entry chunk's sourcemap stays aligned —\n // returning `map: null` here would shift every mapping by the banner's\n // line count and misattribute server stack traces.\n const ms = new MagicString(code);\n ms.prepend(banner);\n return { code: ms.toString(), map: ms.generateMap({ hires: true }) };\n },\n };\n}\n"],"names":[],"mappings":";;;;AAmDO,SAAS,uBAAA,GAA2C;AACzD,EAAA,MAAM,sBAAA,GAAyB,eAAA,CAAgB,EAAE,gBAAA,EAAkB,yBAAyB,CAAA;AAC5F,EAAA,MAAM,uBAAwC,KAAA,CAAM,OAAA,CAAQ,sBAAsB,CAAA,GAC9E,sBAAA,GACA,CAAC,sBAAsB,CAAA;AAC3B,EAAA,OAAO,CAAC,mBAAA,EAAoB,EAAG,GAAG,oBAAoB,CAAA;AACxD;AAEA,SAAS,mBAAA,GAAqC;AAC5C,EAAA,MAAM,MAAA,GAAS;AAAA,IACb,gFAAA;AAAA,IACA,mDAAA;AAAA,IACA;AAAA,GACF,CAAE,KAAK,IAAI,CAAA;AAEX,EAAA,OAAO;AAAA,IACL,IAAA,EAAM,2BAAA;AAAA,IACN,OAAA,EAAS,KAAA;AAAA,IACT,MAAA,GAA4C;AAQ1C,MAAA,OAAO,EAAE,GAAA,EAAK,EAAE,UAAA,EAAY,2BAA0B,EAAE;AAAA,IAC1D,CAAA;AAAA,IACA,WAAA,CAAY,MAAc,KAAA,EAAoE;AAC5F,MAAA,IAAI,CAAC,KAAA,CAAM,OAAA,EAAS,OAAO,IAAA;AAI3B,MAAA,MAAM,EAAA,GAAK,IAAI,WAAA,CAAY,IAAI,CAAA;AAC/B,MAAA,EAAA,CAAG,QAAQ,MAAM,CAAA;AACjB,MAAA,OAAO,EAAE,IAAA,EAAM,EAAA,CAAG,QAAA,EAAS,EAAG,GAAA,EAAK,EAAA,CAAG,WAAA,CAAY,EAAE,KAAA,EAAO,IAAA,EAAM,CAAA,EAAE;AAAA,IACrE;AAAA,GACF;AACF;;;;"}
@@ -0,0 +1,6 @@
1
+ const CHANNELS = {
2
+ MYSQL_QUERY: "orchestrion:mysql:query"
3
+ };
4
+
5
+ export { CHANNELS };
6
+ //# sourceMappingURL=channels.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"channels.js","sources":["../../../src/orchestrion/channels.ts"],"sourcesContent":["/**\n * Fully-qualified `diagnostics_channel` names that orchestrion publishes to.\n *\n * Orchestrion's transform always prefixes the configured `channelName` with\n * `orchestrion:${module.name}:`. So a config of\n * `{ channelName: 'query', module: { name: 'mysql' } }`\n * publishes to `orchestrion:mysql:query`.\n *\n * Subscribers (`integrations/<lib>/tracing-channel.ts`) consume the full\n * prefixed string from this map; the config files set only the unprefixed\n * suffix in `channelName`. Keeping both pieces in one file is what guarantees\n * they don't drift apart and silently stop firing.\n */\nexport const CHANNELS = {\n MYSQL_QUERY: 'orchestrion:mysql:query',\n} as const;\n\nexport type ChannelName = (typeof CHANNELS)[keyof typeof CHANNELS];\n"],"names":[],"mappings":"AAaO,MAAM,QAAA,GAAW;AAAA,EACtB,WAAA,EAAa;AACf;;;;"}
@@ -0,0 +1,34 @@
1
+ const SENTRY_INSTRUMENTATIONS = [
2
+ {
3
+ channelName: "query",
4
+ module: { name: "mysql", versionRange: ">=2.0.0 <3", filePath: "lib/Connection.js" },
5
+ // `Connection` in mysql v2 is a constructor function (NOT a class):
6
+ // `function Connection(options) { ... }`
7
+ // `Connection.prototype.query = function query(sql, values, cb) { ... }`
8
+ // orchestrion's `className`+`methodName` query only matches `class` declarations.
9
+ // The named function expression on the right-hand side of the prototype
10
+ // assignment is what we want — that's matched by `expressionName: 'query'`,
11
+ // which produces the esquery selector
12
+ // `AssignmentExpression[left.property.name="query"] > FunctionExpression[async]`.
13
+ // `Auto` so both `connection.query(sql, cb)` and `connection.query(sql)`
14
+ // (streamable, no callback) get channel events. The transform picks
15
+ // `wrapCallback` when the last arg is a function and `wrapPromise`
16
+ // otherwise — for mysql's no-callback path the latter publishes
17
+ // `start`/`end` synchronously around the original call and stores the
18
+ // returned `Query` emitter on `ctx.result`, which the integration uses to
19
+ // attach `'end'`/`'error'` listeners that finish the span.
20
+ functionQuery: { expressionName: "query", kind: "Auto" }
21
+ }
22
+ ];
23
+ const INSTRUMENTED_MODULE_NAMES = Array.from(new Set(SENTRY_INSTRUMENTATIONS.map((i) => i.module.name)));
24
+ function withoutInstrumentedExternals(external) {
25
+ if (!external) {
26
+ return void 0;
27
+ }
28
+ return external.filter(
29
+ (entry) => !INSTRUMENTED_MODULE_NAMES.some((name) => entry === name || entry.startsWith(`${name}/`))
30
+ );
31
+ }
32
+
33
+ export { INSTRUMENTED_MODULE_NAMES, SENTRY_INSTRUMENTATIONS, withoutInstrumentedExternals };
34
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.js","sources":["../../../src/orchestrion/config.ts"],"sourcesContent":["import type { InstrumentationConfig } from '@apm-js-collab/code-transformer';\n\n/**\n * The central list of channel injections orchestrion should perform.\n *\n * This module has NO side effects — it's the only thing both the runtime hook\n * (`runtime/import-hook.mjs`) and the bundler plugins (`bundler/vite.ts`, …)\n * import from. Adding a new instrumented method is one entry here plus one\n * subscriber in `integrations/<lib>/tracing-channel.ts`.\n *\n * `channelName` here is the unprefixed suffix; the actual diagnostics_channel\n * name is `orchestrion:${module.name}:${channelName}` (see `channels.ts`).\n */\nexport const SENTRY_INSTRUMENTATIONS: InstrumentationConfig[] = [\n {\n channelName: 'query',\n module: { name: 'mysql', versionRange: '>=2.0.0 <3', filePath: 'lib/Connection.js' },\n // `Connection` in mysql v2 is a constructor function (NOT a class):\n // `function Connection(options) { ... }`\n // `Connection.prototype.query = function query(sql, values, cb) { ... }`\n // orchestrion's `className`+`methodName` query only matches `class` declarations.\n // The named function expression on the right-hand side of the prototype\n // assignment is what we want — that's matched by `expressionName: 'query'`,\n // which produces the esquery selector\n // `AssignmentExpression[left.property.name=\"query\"] > FunctionExpression[async]`.\n // `Auto` so both `connection.query(sql, cb)` and `connection.query(sql)`\n // (streamable, no callback) get channel events. The transform picks\n // `wrapCallback` when the last arg is a function and `wrapPromise`\n // otherwise — for mysql's no-callback path the latter publishes\n // `start`/`end` synchronously around the original call and stores the\n // returned `Query` emitter on `ctx.result`, which the integration uses to\n // attach `'end'`/`'error'` listeners that finish the span.\n functionQuery: { expressionName: 'query', kind: 'Auto' },\n },\n];\n\n/**\n * The unique set of package names instrumented by `SENTRY_INSTRUMENTATIONS`\n * (e.g. `['mysql']`).\n *\n * Bundler plugins MUST ensure these are actually bundled rather than\n * externalized: an externalized dependency is resolved from `node_modules` at\n * runtime and never passes through the code transform's `onLoad`, so its\n * diagnostics_channel calls are silently never injected.\n */\nexport const INSTRUMENTED_MODULE_NAMES: string[] = Array.from(new Set(SENTRY_INSTRUMENTATIONS.map(i => i.module.name)));\n\n/**\n * Returns `external` with any instrumented packages removed, so a bundler that\n * uses an \"external\" denylist (esbuild, Bun, Rollup) still bundles — and thus\n * transforms — them. Matches an exact package name (`'mysql'`) or a subpath\n * (`'mysql/lib/...'`); wildcard/other patterns are left untouched. `undefined`\n * is returned unchanged.\n *\n * (Vite uses an `ssr.noExternal` allowlist instead, so it consumes\n * `INSTRUMENTED_MODULE_NAMES` directly rather than this helper.)\n */\nexport function withoutInstrumentedExternals(external: readonly string[] | undefined): string[] | undefined {\n if (!external) {\n return undefined;\n }\n return external.filter(\n entry => !INSTRUMENTED_MODULE_NAMES.some(name => entry === name || entry.startsWith(`${name}/`)),\n );\n}\n"],"names":[],"mappings":"AAaO,MAAM,uBAAA,GAAmD;AAAA,EAC9D;AAAA,IACE,WAAA,EAAa,OAAA;AAAA,IACb,QAAQ,EAAE,IAAA,EAAM,SAAS,YAAA,EAAc,YAAA,EAAc,UAAU,mBAAA,EAAoB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAgBnF,aAAA,EAAe,EAAE,cAAA,EAAgB,OAAA,EAAS,MAAM,MAAA;AAAO;AAE3D;AAWO,MAAM,yBAAA,GAAsC,KAAA,CAAM,IAAA,CAAK,IAAI,GAAA,CAAI,uBAAA,CAAwB,GAAA,CAAI,CAAA,CAAA,KAAK,CAAA,CAAE,MAAA,CAAO,IAAI,CAAC,CAAC;AAY/G,SAAS,6BAA6B,QAAA,EAA+D;AAC1G,EAAA,IAAI,CAAC,QAAA,EAAU;AACb,IAAA,OAAO,MAAA;AAAA,EACT;AACA,EAAA,OAAO,QAAA,CAAS,MAAA;AAAA,IACd,CAAA,KAAA,KAAS,CAAC,yBAAA,CAA0B,IAAA,CAAK,CAAA,IAAA,KAAQ,KAAA,KAAU,IAAA,IAAQ,KAAA,CAAM,UAAA,CAAW,CAAA,EAAG,IAAI,CAAA,CAAA,CAAG,CAAC;AAAA,GACjG;AACF;;;;"}
@@ -0,0 +1,18 @@
1
+ import { debug } from '@sentry/core';
2
+ import { DEBUG_BUILD } from '../debug-build.js';
3
+
4
+ function detectOrchestrionSetup() {
5
+ if (!DEBUG_BUILD) return;
6
+ const marker = globalThis.__SENTRY_ORCHESTRION__;
7
+ const runtime = !!marker?.runtime;
8
+ const bundler = !!marker?.bundler;
9
+ DEBUG_BUILD && debug.log(`[orchestrion] detect: runtime=${runtime} bundler=${bundler}`);
10
+ if (!runtime && !bundler) {
11
+ DEBUG_BUILD && debug.warn(
12
+ "[Sentry] No diagnostics-channel injection detected. Channel-based integrations (mysql, \u2026) will not record spans. Make sure the diagnostics channels are injected via the runtime `--import` hook or a bundler plugin before the instrumented modules load."
13
+ );
14
+ }
15
+ }
16
+
17
+ export { detectOrchestrionSetup };
18
+ //# sourceMappingURL=detect.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"detect.js","sources":["../../../src/orchestrion/detect.ts"],"sourcesContent":["import { debug } from '@sentry/core';\nimport { DEBUG_BUILD } from '../debug-build';\n\ndeclare global {\n // eslint-disable-next-line no-var\n var __SENTRY_ORCHESTRION__: { runtime?: boolean; bundler?: boolean } | undefined;\n}\n\n/**\n * Verifies that the diagnostics channels have been injected either by the\n * runtime `--import` hook (or init-time registration), a bundler plugin, or\n * both, and warns if not.\n *\n * Both injectors being active at once is fine: they operate on disjoint module\n * sets (a module is either loaded through Node's loader and transformed by the\n * runtime hook, or inlined by the bundler and transformed by the plugin), so\n * a single module can't be double-wrapped. A hybrid setup, with some deps\n * external and runtime-instrumented, others bundled and plugin-instrumented,\n * is fine.\n *\n * Note: intentionally does NOT warn in production, only in debug builds,\n * because production warnings are reserved for truly critical issues.\n */\nexport function detectOrchestrionSetup(): void {\n if (!DEBUG_BUILD) return;\n\n const marker = globalThis.__SENTRY_ORCHESTRION__;\n const runtime = !!marker?.runtime;\n const bundler = !!marker?.bundler;\n\n DEBUG_BUILD && debug.log(`[orchestrion] detect: runtime=${runtime} bundler=${bundler}`);\n\n if (!runtime && !bundler) {\n DEBUG_BUILD &&\n debug.warn(\n '[Sentry] No diagnostics-channel injection detected. Channel-based integrations ' +\n '(mysql, …) will not record spans. Make sure the diagnostics channels are injected ' +\n 'via the runtime `--import` hook or a bundler plugin before the instrumented modules load.',\n );\n }\n}\n"],"names":[],"mappings":";;;AAuBO,SAAS,sBAAA,GAA+B;AAC7C,EAAA,IAAI,CAAC,WAAA,EAAa;AAElB,EAAA,MAAM,SAAS,UAAA,CAAW,sBAAA;AAC1B,EAAA,MAAM,OAAA,GAAU,CAAC,CAAC,MAAA,EAAQ,OAAA;AAC1B,EAAA,MAAM,OAAA,GAAU,CAAC,CAAC,MAAA,EAAQ,OAAA;AAE1B,EAAA,WAAA,IAAe,MAAM,GAAA,CAAI,CAAA,8BAAA,EAAiC,OAAO,CAAA,SAAA,EAAY,OAAO,CAAA,CAAE,CAAA;AAEtF,EAAA,IAAI,CAAC,OAAA,IAAW,CAAC,OAAA,EAAS;AACxB,IAAA,WAAA,IACE,KAAA,CAAM,IAAA;AAAA,MACJ;AAAA,KAGF;AAAA,EACJ;AACF;;;;"}
@@ -0,0 +1,3 @@
1
+ export { detectOrchestrionSetup } from './detect.js';
2
+ export { mysqlChannelIntegration } from '../integrations/tracing-channel/mysql.js';
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
@@ -0,0 +1,48 @@
1
+ import { debug } from '@sentry/core';
2
+ import * as Module from 'node:module';
3
+ import { createRequire } from 'node:module';
4
+ import { pathToFileURL } from 'node:url';
5
+ import { DEBUG_BUILD } from '../../debug-build.js';
6
+ import { SENTRY_INSTRUMENTATIONS } from '../config.js';
7
+
8
+ function registerDiagnosticsChannelInjection() {
9
+ const g = globalThis.__SENTRY_ORCHESTRION__ ?? (globalThis.__SENTRY_ORCHESTRION__ = {});
10
+ if (g.runtime || g.bundler) {
11
+ return;
12
+ }
13
+ const globalAny = globalThis;
14
+ const parseVersion = (v) => v.split(".").map((n) => parseInt(n, 10));
15
+ const nodeVersion = parseVersion(process.versions.node ?? "0.0.0");
16
+ const denoVersion = parseVersion(globalAny.Deno?.version?.deno ?? "0.0.0");
17
+ const stableSyncHooks = (nodeVersion[0] ?? 0) > 25 || nodeVersion[0] === 25 && (nodeVersion[1] ?? 0) >= 1 || nodeVersion[0] === 24 && (nodeVersion[1] ?? 0) >= 13 || (denoVersion[0] ?? 0) > 2 || denoVersion[0] === 2 && (denoVersion[1] ?? 0) >= 8;
18
+ const nodeRequire = typeof require === "function" ? require : createRequire(import.meta.url);
19
+ const mod = Module;
20
+ try {
21
+ if (typeof mod.registerHooks === "function" && stableSyncHooks) {
22
+ const { initialize, resolve, load } = nodeRequire("@apm-js-collab/tracing-hooks/hook-sync.mjs");
23
+ initialize({ instrumentations: SENTRY_INSTRUMENTATIONS });
24
+ mod.registerHooks({ resolve, load });
25
+ DEBUG_BUILD && debug.log("[orchestrion] registered diagnostics-channel injection via Module.registerHooks()");
26
+ } else if (typeof mod.register === "function" && !globalAny.Bun && !globalAny.Deno) {
27
+ mod.register(pathToFileURL(nodeRequire.resolve("@apm-js-collab/tracing-hooks/hook.mjs")).href, {
28
+ data: { instrumentations: SENTRY_INSTRUMENTATIONS }
29
+ });
30
+ const ModulePatch = nodeRequire("@apm-js-collab/tracing-hooks");
31
+ new ModulePatch({ instrumentations: SENTRY_INSTRUMENTATIONS }).patch();
32
+ DEBUG_BUILD && debug.log("[orchestrion] registered diagnostics-channel injection via Module.register()");
33
+ } else {
34
+ DEBUG_BUILD && debug.warn("[Sentry] No available Node API to register diagnostics-channel injection hooks; skipping.");
35
+ return;
36
+ }
37
+ } catch (error) {
38
+ DEBUG_BUILD && debug.warn(
39
+ "[Sentry] Failed to register diagnostics-channel injection hooks; channel-based integrations will not record spans.",
40
+ error
41
+ );
42
+ return;
43
+ }
44
+ g.runtime = true;
45
+ }
46
+
47
+ export { registerDiagnosticsChannelInjection };
48
+ //# sourceMappingURL=register.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"register.js","sources":["../../../../src/orchestrion/runtime/register.ts"],"sourcesContent":["import { debug } from '@sentry/core';\nimport { createRequire } from 'node:module';\nimport * as Module from 'node:module';\nimport { pathToFileURL } from 'node:url';\nimport { DEBUG_BUILD } from '../../debug-build';\nimport { SENTRY_INSTRUMENTATIONS } from '../config';\n\ndeclare global {\n // eslint-disable-next-line no-var\n var __SENTRY_ORCHESTRION__: { runtime?: boolean; bundler?: boolean } | undefined;\n}\n\n/**\n * Synchronously register the diagnostics-channel injection module hooks.\n *\n * This is the single source of truth for the registration logic. It is used by:\n * - `Sentry.init()` (the Node SDK calls it directly — that's why this module\n * must be CJS-compatible / dual-built, so it can be `require()`d synchronously\n * before the app's `import`s resolve), and\n * - `import-hook.mjs`, the side-effecting `--import` entry, which just calls it.\n *\n * Libraries imported *after* this call publish the `tracingChannel` events that\n * the channel-based integrations subscribe to.\n *\n * Idempotent via `globalThis.__SENTRY_ORCHESTRION__` — a no-op if the runtime\n * `--import` hook or a bundler plugin already injected the channels.\n */\nexport function registerDiagnosticsChannelInjection(): void {\n const g = (globalThis.__SENTRY_ORCHESTRION__ ??= {});\n\n // Already injected (runtime --import hook or bundler plugin) — nothing to do.\n if (g.runtime || g.bundler) {\n return;\n }\n\n const globalAny = globalThis as { Bun?: unknown; Deno?: { version?: { deno?: string } } };\n const parseVersion = (v: string): number[] => v.split('.').map(n => parseInt(n, 10));\n const nodeVersion = parseVersion(process.versions.node ?? '0.0.0');\n const denoVersion = parseVersion(globalAny.Deno?.version?.deno ?? '0.0.0');\n // `Module.registerHooks` only became stable in Node 24.13 / 25.1 and Deno 2.8.\n const stableSyncHooks =\n (nodeVersion[0] ?? 0) > 25 ||\n (nodeVersion[0] === 25 && (nodeVersion[1] ?? 0) >= 1) ||\n (nodeVersion[0] === 24 && (nodeVersion[1] ?? 0) >= 13) ||\n (denoVersion[0] ?? 0) > 2 ||\n (denoVersion[0] === 2 && (denoVersion[1] ?? 0) >= 8);\n\n // Prefer the builtin `require` if possible. This is present in CommonJS,\n // including a bundler's CJS output, so no need to ever have to evaluate\n // `import.meta.url` there.\n //\n // esbuild and friends rewrite `import.meta.url` to `{}` for CJS output,\n // which would make `createRequire(undefined)` throw.\n // Only use `import.meta.url` in true ESM, where there's no `require`\n const nodeRequire = typeof require === 'function' ? require : createRequire(import.meta.url);\n\n // `Module.registerHooks` / `Module.register` are newer than the @types/node\n // we build against, hence the cast.\n const mod = Module as unknown as {\n registerHooks?: (hooks: unknown) => void;\n register?: (specifier: string, options: unknown) => void;\n };\n\n // runs both at `--import` time and (synchronously) inside `Sentry.init()`,\n // so an unguarded throw would either abort startup or make `init()` throw.\n // On any failure (e.g. dep resolution, `require(esm)` / Node-compat\n // incompatibility) we warn (DEBUG only) and continue without channel\n // injection\n try {\n if (typeof mod.registerHooks === 'function' && stableSyncHooks) {\n // Sync hooks cover CJS and ESM, no separate `_compile` patch needed.\n // We require() the module here so that we can synchronously load it,\n // including from a CommonJS Sentry build, without bundlers pulling in.\n // All versions in stableSyncHooks support this.\n const { initialize, resolve, load } = nodeRequire('@apm-js-collab/tracing-hooks/hook-sync.mjs') as {\n initialize: (opts: { instrumentations: unknown }) => void;\n resolve: unknown;\n load: unknown;\n };\n initialize({ instrumentations: SENTRY_INSTRUMENTATIONS });\n mod.registerHooks({ resolve, load });\n DEBUG_BUILD && debug.log('[orchestrion] registered diagnostics-channel injection via Module.registerHooks()');\n } else if (typeof mod.register === 'function' && !globalAny.Bun && !globalAny.Deno) {\n // `Module.register` + the `_compile` patch is Node 18.19–24.12 / 25.0\n // path. Bun/Deno are excluded: they don't support this combination and\n // must use the stable `registerHooks` path above (or none at all).\n // Resolve the hook to an absolute file URL ourselves so\n // `Module.register` needs no `parentURL`, so no need for\n // `import.meta.url` polyfilling\n mod.register(pathToFileURL(nodeRequire.resolve('@apm-js-collab/tracing-hooks/hook.mjs')).href, {\n data: { instrumentations: SENTRY_INSTRUMENTATIONS },\n });\n\n // ALSO patch `Module.prototype._compile` for the CJS side: when an ESM\n // file `import`s a CJS package, the package's internal `require()` calls\n // are resolved through the CJS machinery and never reach the ESM\n // register hook, so without this patch the file we want to instrument\n // loads untransformed.\n const ModulePatch = nodeRequire('@apm-js-collab/tracing-hooks') as new (opts: { instrumentations: unknown }) => {\n patch: () => void;\n };\n new ModulePatch({ instrumentations: SENTRY_INSTRUMENTATIONS }).patch();\n DEBUG_BUILD && debug.log('[orchestrion] registered diagnostics-channel injection via Module.register()');\n } else {\n DEBUG_BUILD &&\n debug.warn('[Sentry] No available Node API to register diagnostics-channel injection hooks; skipping.');\n return;\n }\n } catch (error) {\n DEBUG_BUILD &&\n debug.warn(\n '[Sentry] Failed to register diagnostics-channel injection hooks; channel-based integrations ' +\n 'will not record spans.',\n error,\n );\n return;\n }\n\n g.runtime = true;\n}\n"],"names":[],"mappings":";;;;;;;AA2BO,SAAS,mCAAA,GAA4C;AAC1D,EAAA,MAAM,CAAA,GAAK,UAAA,CAAW,sBAAA,KAAX,UAAA,CAAW,yBAA2B,EAAC,CAAA;AAGlD,EAAA,IAAI,CAAA,CAAE,OAAA,IAAW,CAAA,CAAE,OAAA,EAAS;AAC1B,IAAA;AAAA,EACF;AAEA,EAAA,MAAM,SAAA,GAAY,UAAA;AAClB,EAAA,MAAM,YAAA,GAAe,CAAC,CAAA,KAAwB,CAAA,CAAE,KAAA,CAAM,GAAG,CAAA,CAAE,GAAA,CAAI,CAAA,CAAA,KAAK,QAAA,CAAS,CAAA,EAAG,EAAE,CAAC,CAAA;AACnF,EAAA,MAAM,WAAA,GAAc,YAAA,CAAa,OAAA,CAAQ,QAAA,CAAS,QAAQ,OAAO,CAAA;AACjE,EAAA,MAAM,cAAc,YAAA,CAAa,SAAA,CAAU,IAAA,EAAM,OAAA,EAA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nD,CAAA;AAOD,MAAA,MAAM,WAAA,GAAc,YAAY,8BAA8B,CAAA;AAG9D,MAAA,IAAI,YAAY,EAAE,gBAAA,EAAkB,uBAAA,EAAyB,EAAE,KAAA,EAAM;AACrE,MAAA,WAAA,IAAe,KAAA,CAAM,IAAI,8EAA8E,CAAA;AAAA,IACzG,CAAA,MAAO;AACL,MAAA,WAAA,IACE,KAAA,CAAM,KAAK,2FAA2F,CAAA;AACxG,MAAA;AAAA,IACF;AAAA,EACF,SAAS,KAAA,EAAO;AACd,IAAA,WAAA,IACE,KAAA,CAAM,IAAA;AAAA,MACJ,oHAAA;AAAA,MAEA;AAAA,KACF;AACF,IAAA;AAAA,EACF;AAEA,EAAA,CAAA,CAAE,OAAA,GAAU,IAAA;AACd;;;;"}
@@ -1 +1 @@
1
- {"type":"module","version":"10.58.0","sideEffects":false}
1
+ {"type":"module","version":"10.60.0","sideEffects":false}
@@ -1,3 +1,4 @@
1
+ import { SERVER_PORT, SERVER_ADDRESS, DB_QUERY_TEXT, DB_SYSTEM_NAME, DB_OPERATION_BATCH_SIZE } from '@sentry/conventions/attributes';
1
2
  import { debug, startSpanManual, SEMANTIC_ATTRIBUTE_SENTRY_OP, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, SPAN_STATUS_ERROR } from '@sentry/core';
2
3
  import { DEBUG_BUILD } from '../debug-build.js';
3
4
 
@@ -7,11 +8,6 @@ const REDIS_DC_CHANNEL_CONNECT = "node-redis:connect";
7
8
  const IOREDIS_DC_CHANNEL_COMMAND = "ioredis:command";
8
9
  const IOREDIS_DC_CHANNEL_CONNECT = "ioredis:connect";
9
10
  const ORIGIN = "auto.db.redis.diagnostic_channel";
10
- const ATTR_DB_QUERY_TEXT = "db.query.text";
11
- const ATTR_DB_SYSTEM_NAME = "db.system.name";
12
- const ATTR_DB_OPERATION_BATCH_SIZE = "db.operation.batch.size";
13
- const ATTR_SERVER_ADDRESS = "server.address";
14
- const ATTR_SERVER_PORT = "server.port";
15
11
  const DB_SYSTEM_NAME_VALUE_REDIS = "redis";
16
12
  const NOOP = () => {
17
13
  };
@@ -45,10 +41,10 @@ function setupCommandChannel(tracingChannel, channelName, getCommandArgs) {
45
41
  attributes: {
46
42
  [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: ORIGIN,
47
43
  [SEMANTIC_ATTRIBUTE_SENTRY_OP]: "db.redis",
48
- [ATTR_DB_SYSTEM_NAME]: DB_SYSTEM_NAME_VALUE_REDIS,
49
- [ATTR_DB_QUERY_TEXT]: statement,
50
- ...data.serverAddress != null ? { [ATTR_SERVER_ADDRESS]: data.serverAddress } : {},
51
- ...data.serverPort != null ? { [ATTR_SERVER_PORT]: data.serverPort } : {}
44
+ [DB_SYSTEM_NAME]: DB_SYSTEM_NAME_VALUE_REDIS,
45
+ [DB_QUERY_TEXT]: statement,
46
+ ...data.serverAddress != null ? { [SERVER_ADDRESS]: data.serverAddress } : {},
47
+ ...data.serverPort != null ? { [SERVER_PORT]: data.serverPort } : {}
52
48
  }
53
49
  },
54
50
  (span) => span
@@ -82,12 +78,12 @@ function setupBatchChannel(tracingChannel, channelName, getOperationName) {
82
78
  attributes: {
83
79
  [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: ORIGIN,
84
80
  [SEMANTIC_ATTRIBUTE_SENTRY_OP]: "db.redis",
85
- [ATTR_DB_SYSTEM_NAME]: DB_SYSTEM_NAME_VALUE_REDIS,
81
+ [DB_SYSTEM_NAME]: DB_SYSTEM_NAME_VALUE_REDIS,
86
82
  // should only include batch size greater than 1,
87
83
  // or else it isn't properly considered a "batch"
88
- ...Number(data.batchSize) > 1 ? { [ATTR_DB_OPERATION_BATCH_SIZE]: data.batchSize } : {},
89
- ...data.serverAddress != null ? { [ATTR_SERVER_ADDRESS]: data.serverAddress } : {},
90
- ...data.serverPort != null ? { [ATTR_SERVER_PORT]: data.serverPort } : {}
84
+ ...Number(data.batchSize) > 1 ? { [DB_OPERATION_BATCH_SIZE]: data.batchSize } : {},
85
+ ...data.serverAddress != null ? { [SERVER_ADDRESS]: data.serverAddress } : {},
86
+ ...data.serverPort != null ? { [SERVER_PORT]: data.serverPort } : {}
91
87
  }
92
88
  },
93
89
  (span) => span
@@ -118,9 +114,9 @@ function setupConnectChannel(tracingChannel, channelName) {
118
114
  attributes: {
119
115
  [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: ORIGIN,
120
116
  [SEMANTIC_ATTRIBUTE_SENTRY_OP]: "db.redis.connect",
121
- [ATTR_DB_SYSTEM_NAME]: DB_SYSTEM_NAME_VALUE_REDIS,
122
- ...data.serverAddress != null ? { [ATTR_SERVER_ADDRESS]: data.serverAddress } : {},
123
- ...data.serverPort != null ? { [ATTR_SERVER_PORT]: data.serverPort } : {}
117
+ [DB_SYSTEM_NAME]: DB_SYSTEM_NAME_VALUE_REDIS,
118
+ ...data.serverAddress != null ? { [SERVER_ADDRESS]: data.serverAddress } : {},
119
+ ...data.serverPort != null ? { [SERVER_PORT]: data.serverPort } : {}
124
120
  }
125
121
  },
126
122
  (span) => span
@@ -1 +1 @@
1
- {"version":3,"file":"redis-dc-subscriber.js","sources":["../../../src/redis/redis-dc-subscriber.ts"],"sourcesContent":["import type { Span } from '@sentry/core';\nimport {\n debug,\n SEMANTIC_ATTRIBUTE_SENTRY_OP,\n SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,\n SPAN_STATUS_ERROR,\n startSpanManual,\n} from '@sentry/core';\nimport { DEBUG_BUILD } from '../debug-build';\n\n// Channel names published by node-redis >= 5.12.0 and ioredis >= 5.11.0.\n// Hardcoded so the subscriber does not have to import either library — the\n// channels just have to be subscribed to before the user's redis code\n// publishes.\nexport const REDIS_DC_CHANNEL_COMMAND = 'node-redis:command';\nexport const REDIS_DC_CHANNEL_BATCH = 'node-redis:batch';\nexport const REDIS_DC_CHANNEL_CONNECT = 'node-redis:connect';\nexport const IOREDIS_DC_CHANNEL_COMMAND = 'ioredis:command';\nexport const IOREDIS_DC_CHANNEL_CONNECT = 'ioredis:connect';\n\nconst ORIGIN = 'auto.db.redis.diagnostic_channel';\n\n// Inlined stable semconv attribute keys — these are plain strings, no need to\n// depend on @opentelemetry/semantic-conventions for them. We use the stable\n// OTel names (matching `@sentry/core`'s postgresjs integration) rather than the\n// deprecated `db.statement`/`db.system`/`net.peer.*` forms.\nconst ATTR_DB_QUERY_TEXT = 'db.query.text';\nconst ATTR_DB_SYSTEM_NAME = 'db.system.name';\nconst ATTR_DB_OPERATION_BATCH_SIZE = 'db.operation.batch.size';\nconst ATTR_SERVER_ADDRESS = 'server.address';\nconst ATTR_SERVER_PORT = 'server.port';\nconst DB_SYSTEM_NAME_VALUE_REDIS = 'redis';\n\nconst NOOP = (): void => {};\n\n/**\n * Shape of the `node-redis:command` channel payload published by node-redis.\n *\n * Both `command` and `args` are already redacted by node-redis itself (see\n * `sanitizeArgs` in @redis/client) using the OTel `redis-common` rules. The\n * arg array is `[<command>, <safe arg>, ..., '?', ...]` — `?` replaces any\n * value the library considers sensitive. Subscribers can emit `args` directly\n * as `db.query.text` without further serialization.\n */\nexport interface RedisCommandData {\n command: string;\n /** First arg is the command name itself; consumers should slice it off. */\n args: string[];\n database?: number;\n serverAddress?: string;\n serverPort?: number;\n result?: unknown;\n error?: Error;\n}\n\n/**\n * Shape of the `ioredis:command` channel payload published by ioredis >= 5.11.0.\n *\n * As with node-redis, args are already sanitized by ioredis (`sanitizeArgs` in\n * `lib/tracing.ts`) before publishing. Unlike node-redis, the command name is\n * NOT prepended to `args`.\n */\nexport interface IORedisCommandData {\n command: string;\n args: string[];\n batchMode?: 'MULTI';\n batchSize?: number;\n database?: number;\n serverAddress?: string;\n serverPort?: number;\n result?: unknown;\n error?: Error;\n}\n\n/** Shape of the `node-redis:batch` channel payload published by node-redis. */\nexport interface RedisBatchData {\n batchMode?: 'MULTI' | 'PIPELINE';\n batchSize?: number;\n database?: number;\n clientId?: string | number;\n serverAddress?: string;\n serverPort?: number;\n result?: unknown[];\n error?: Error;\n}\n\n/** Shape of the `*:connect` channel payload published by node-redis and ioredis. */\nexport interface RedisConnectData {\n serverAddress?: string;\n serverPort?: number;\n url?: string;\n error?: Error;\n}\n\n/**\n * Optional callback invoked once the redis command response arrives. Useful\n * for attaching response-derived attributes (e.g. cache hit/miss, payload size).\n *\n * Mirrors `@opentelemetry/instrumentation-ioredis`' response hook so existing\n * Sentry node code (`cacheResponseHook`) can be reused unchanged.\n */\nexport type RedisDiagnosticChannelResponseHook = (\n span: Span,\n cmdName: string,\n cmdArgs: string[],\n result: unknown,\n) => void;\n\n/**\n * Payload type observed by tracing-channel subscribers — the channel payload\n * with `_sentrySpan` stamped on it by the start handler so async/error\n * handlers downstream can read it back.\n */\nexport type RedisTracingChannelContextWithSpan<T> = T & { _sentrySpan?: Span };\n\n/** Subscriber object accepted by {@link RedisTracingChannel.subscribe}. */\nexport interface RedisTracingChannelSubscribers<T> {\n start: (data: RedisTracingChannelContextWithSpan<T>) => void;\n asyncStart: (data: RedisTracingChannelContextWithSpan<T>) => void;\n asyncEnd: (data: RedisTracingChannelContextWithSpan<T>) => void;\n end: (data: RedisTracingChannelContextWithSpan<T>) => void;\n error: (data: RedisTracingChannelContextWithSpan<T>) => void;\n}\n\n/** Minimal tracing-channel surface the subscriber depends on. */\nexport interface RedisTracingChannel<T extends object> {\n subscribe(subs: Partial<RedisTracingChannelSubscribers<T>>): void;\n}\n\n/**\n * Platform-provided factory that returns a tracing channel for the given\n * channel name. Implementations are responsible for ensuring that, when the\n * channel's `start` event fires, the span returned by `transformStart(data)`\n * ends up stored on `data._sentrySpan` so the subscriber's `asyncEnd`/`error`\n * handlers can read it.\n *\n * - Node passes `@sentry/opentelemetry/tracing-channel` which uses\n * `bindStore` to also propagate the span as the active OTel context.\n * - Deno (and other non-OTel runtimes) pass a portable wrapper around\n * `node:diagnostics_channel.tracingChannel` that just stamps\n * `data._sentrySpan` in `start` without `bindStore`.\n */\nexport type RedisTracingChannelFactory = <T extends object>(\n name: string,\n transformStart: (data: T) => Span,\n) => RedisTracingChannel<T>;\n\nlet subscribed = false;\nlet currentResponseHook: RedisDiagnosticChannelResponseHook | undefined;\n\n/**\n * Subscribe Sentry span handlers to node-redis and ioredis diagnostics-channel\n * events: `node-redis:command`/`:batch`/`:connect` (published by node-redis\n * >= 5.12.0) and `ioredis:command`/`:connect` (published by ioredis >= 5.11.0).\n *\n * On older client versions the channels are never published to, so subscribers\n * are inert — there is no double-instrumentation against any IITM-based\n * patcher gated to those older versions.\n *\n * Idempotent: subsequent calls update the response hook but do not\n * re-subscribe.\n */\nexport function subscribeRedisDiagnosticChannels(\n tracingChannel: RedisTracingChannelFactory,\n responseHook?: RedisDiagnosticChannelResponseHook,\n): void {\n currentResponseHook = responseHook;\n if (subscribed) return;\n subscribed = true;\n\n try {\n // node-redis: command name appears as args[0] in the channel payload, so\n // strip it before the statement and response hook see it.\n setupCommandChannel<RedisCommandData>(tracingChannel, REDIS_DC_CHANNEL_COMMAND, data => data.args.slice(1));\n setupBatchChannel(tracingChannel, REDIS_DC_CHANNEL_BATCH, data =>\n data.batchMode === 'PIPELINE' ? 'PIPELINE' : 'MULTI',\n );\n setupConnectChannel(tracingChannel, REDIS_DC_CHANNEL_CONNECT);\n\n // ioredis: args already exclude the command name; no slicing needed. And\n // ioredis has no separate batch channel — pipeline/MULTI metadata rides\n // on the per-command payload via `batchMode`/`batchSize`.\n setupCommandChannel<IORedisCommandData>(tracingChannel, IOREDIS_DC_CHANNEL_COMMAND, data => data.args);\n setupConnectChannel(tracingChannel, IOREDIS_DC_CHANNEL_CONNECT);\n } catch {\n // The factory may rely on `node:diagnostics_channel`, which isn't always\n // available. Fail closed; the SDK simply won't emit redis spans here.\n DEBUG_BUILD && debug.log('Redis node:diagnostics_channel subscription failed.');\n }\n}\n\nfunction setupCommandChannel<T extends RedisCommandData | IORedisCommandData>(\n tracingChannel: RedisTracingChannelFactory,\n channelName: string,\n getCommandArgs: (data: T) => string[],\n): void {\n const channel = tracingChannel<T>(channelName, data => {\n // `args` is already sanitized by the publishing library (node-redis /\n // ioredis call their own `sanitizeArgs` before publishing). Join with\n // spaces to mirror the format the libraries themselves intend.\n const args = getCommandArgs(data);\n const statement = args.length ? `${data.command} ${args.join(' ')}` : data.command;\n return startSpanManual(\n {\n name: `redis-${data.command}`,\n attributes: {\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: ORIGIN,\n [SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'db.redis',\n [ATTR_DB_SYSTEM_NAME]: DB_SYSTEM_NAME_VALUE_REDIS,\n [ATTR_DB_QUERY_TEXT]: statement,\n ...(data.serverAddress != null ? { [ATTR_SERVER_ADDRESS]: data.serverAddress } : {}),\n ...(data.serverPort != null ? { [ATTR_SERVER_PORT]: data.serverPort } : {}),\n },\n },\n span => span,\n );\n });\n\n channel.subscribe({\n start: NOOP,\n asyncStart: NOOP,\n end: NOOP,\n asyncEnd: data => {\n const span = data._sentrySpan;\n // Only end here if the error handler isn't going to.\n if (!span || data.error) return;\n runResponseHook(span, data.command, getCommandArgs(data), data.result);\n span.end();\n },\n error: data => {\n const span = data._sentrySpan;\n if (!span) return;\n if (data.error) {\n span.setStatus({ code: SPAN_STATUS_ERROR, message: data.error.message });\n }\n span.end();\n },\n });\n}\n\nfunction setupBatchChannel(\n tracingChannel: RedisTracingChannelFactory,\n channelName: string,\n getOperationName: (data: RedisBatchData) => string,\n): void {\n const channel = tracingChannel<RedisBatchData>(channelName, data => {\n return startSpanManual(\n {\n name: getOperationName(data),\n attributes: {\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: ORIGIN,\n [SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'db.redis',\n [ATTR_DB_SYSTEM_NAME]: DB_SYSTEM_NAME_VALUE_REDIS,\n // should only include batch size greater than 1,\n // or else it isn't properly considered a \"batch\"\n ...(Number(data.batchSize) > 1 ? { [ATTR_DB_OPERATION_BATCH_SIZE]: data.batchSize } : {}),\n ...(data.serverAddress != null ? { [ATTR_SERVER_ADDRESS]: data.serverAddress } : {}),\n ...(data.serverPort != null ? { [ATTR_SERVER_PORT]: data.serverPort } : {}),\n },\n },\n span => span,\n );\n });\n\n channel.subscribe({\n start: NOOP,\n asyncStart: NOOP,\n end: NOOP,\n asyncEnd: data => {\n if (!data.error) data._sentrySpan?.end();\n },\n error: data => {\n const span = data._sentrySpan;\n if (!span) return;\n if (data.error) {\n span.setStatus({ code: SPAN_STATUS_ERROR, message: data.error.message });\n }\n span.end();\n },\n });\n}\n\nfunction setupConnectChannel(tracingChannel: RedisTracingChannelFactory, channelName: string): void {\n const channel = tracingChannel<RedisConnectData>(channelName, data => {\n return startSpanManual(\n {\n name: 'redis-connect',\n attributes: {\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: ORIGIN,\n [SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'db.redis.connect',\n [ATTR_DB_SYSTEM_NAME]: DB_SYSTEM_NAME_VALUE_REDIS,\n ...(data.serverAddress != null ? { [ATTR_SERVER_ADDRESS]: data.serverAddress } : {}),\n ...(data.serverPort != null ? { [ATTR_SERVER_PORT]: data.serverPort } : {}),\n },\n },\n span => span,\n );\n });\n\n channel.subscribe({\n start: NOOP,\n asyncStart: NOOP,\n end: NOOP,\n asyncEnd: data => {\n if (!data.error) data._sentrySpan?.end();\n },\n error: data => {\n const span = data._sentrySpan;\n if (!span) return;\n if (data.error) {\n span.setStatus({ code: SPAN_STATUS_ERROR, message: data.error.message });\n }\n span.end();\n },\n });\n}\n\nfunction runResponseHook(span: Span, command: string, args: string[], result: unknown): void {\n const hook = currentResponseHook;\n if (!hook) return;\n try {\n hook(span, command, args, result);\n } catch {\n // never let user hooks break instrumentation\n }\n}\n\n/** Test-only: reset module-local subscribe state. */\nexport function _resetRedisDiagnosticChannelsForTesting(): void {\n subscribed = false;\n currentResponseHook = undefined;\n}\n"],"names":[],"mappings":";;;AAcO,MAAM,wBAAA,GAA2B;AACjC,MAAM,sBAAA,GAAyB;AAC/B,MAAM,wBAAA,G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IAAA;AAAA,IACZ,GAAA,EAAK,IAAA;AAAA,IACL,UAAU,CAAA,IAAA,KAAQ;AAChB,MAAA,IAAI,CAAC,IAAA,CAAK,KAAA,EAAO,IAAA,CAAK,aAAa,GAAA,EAAI;AAAA,IACzC,CAAA;AAAA,IACA,OAAO,CAAA,IAAA,KAAQ;AACb,MAAA,MAAM,OAAO,IAAA,CAAK,WAAA;AAClB,MAAA,IAAI,CAAC,IAAA,EAAM;AACX,MAAA,IAAI,KAAK,KAAA,EAAO;AACd,QAAA,IAAA,CAAK,SAAA,CAAU,EAAE,IAAA,EAAM,iBAAA,EAAmB,SAAS,IAAA,CAAK,KAAA,CAAM,SAAS,CAAA;AAAA,MACzE;AACA,MAAA,IAAA,CAAK,GAAA,EAAI;AAAA,IACX;AAAA,GACD,CAAA;AACH;AAEA,SAAS,eAAA,CAAgB,IAAA,EAAY,OAAA,EAAiB,IAAA,EAAgB,MAAA,EAAuB;AAC3F,EAAA,MAAM,IAAA,GAAO,mBAAA;AACb,EAAA,IAAI,CAAC,IAAA,EAAM;AACX,EAAA,IAAI;AACF,IAAA,IAAA,CAAK,IAAA,EAAM,OAAA,EAAS,IAAA,EAAM,MAAM,CAAA;AAAA,EAClC,CAAA,CAAA,MAAQ;AAAA,EAER;AACF;;;;"}
1
+ {"version":3,"file":"redis-dc-subscriber.js","sources":["../../../src/redis/redis-dc-subscriber.ts"],"sourcesContent":["import {\n DB_OPERATION_BATCH_SIZE,\n DB_QUERY_TEXT,\n DB_SYSTEM_NAME,\n SERVER_ADDRESS,\n SERVER_PORT,\n} from '@sentry/conventions/attributes';\nimport type { Span } from '@sentry/core';\nimport {\n debug,\n SEMANTIC_ATTRIBUTE_SENTRY_OP,\n SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,\n SPAN_STATUS_ERROR,\n startSpanManual,\n} from '@sentry/core';\nimport { DEBUG_BUILD } from '../debug-build';\n\n// Channel names published by node-redis >= 5.12.0 and ioredis >= 5.11.0.\n// Hardcoded so the subscriber does not have to import either library — the\n// channels just have to be subscribed to before the user's redis code\n// publishes.\nexport const REDIS_DC_CHANNEL_COMMAND = 'node-redis:command';\nexport const REDIS_DC_CHANNEL_BATCH = 'node-redis:batch';\nexport const REDIS_DC_CHANNEL_CONNECT = 'node-redis:connect';\nexport const IOREDIS_DC_CHANNEL_COMMAND = 'ioredis:command';\nexport const IOREDIS_DC_CHANNEL_CONNECT = 'ioredis:connect';\n\nconst ORIGIN = 'auto.db.redis.diagnostic_channel';\nconst DB_SYSTEM_NAME_VALUE_REDIS = 'redis';\n\nconst NOOP = (): void => {};\n\n/**\n * Shape of the `node-redis:command` channel payload published by node-redis.\n *\n * Both `command` and `args` are already redacted by node-redis itself (see\n * `sanitizeArgs` in @redis/client) using the OTel `redis-common` rules. The\n * arg array is `[<command>, <safe arg>, ..., '?', ...]` — `?` replaces any\n * value the library considers sensitive. Subscribers can emit `args` directly\n * as `db.query.text` without further serialization.\n */\nexport interface RedisCommandData {\n command: string;\n /** First arg is the command name itself; consumers should slice it off. */\n args: string[];\n database?: number;\n serverAddress?: string;\n serverPort?: number;\n result?: unknown;\n error?: Error;\n}\n\n/**\n * Shape of the `ioredis:command` channel payload published by ioredis >= 5.11.0.\n *\n * As with node-redis, args are already sanitized by ioredis (`sanitizeArgs` in\n * `lib/tracing.ts`) before publishing. Unlike node-redis, the command name is\n * NOT prepended to `args`.\n */\nexport interface IORedisCommandData {\n command: string;\n args: string[];\n batchMode?: 'MULTI';\n batchSize?: number;\n database?: number;\n serverAddress?: string;\n serverPort?: number;\n result?: unknown;\n error?: Error;\n}\n\n/** Shape of the `node-redis:batch` channel payload published by node-redis. */\nexport interface RedisBatchData {\n batchMode?: 'MULTI' | 'PIPELINE';\n batchSize?: number;\n database?: number;\n clientId?: string | number;\n serverAddress?: string;\n serverPort?: number;\n result?: unknown[];\n error?: Error;\n}\n\n/** Shape of the `*:connect` channel payload published by node-redis and ioredis. */\nexport interface RedisConnectData {\n serverAddress?: string;\n serverPort?: number;\n url?: string;\n error?: Error;\n}\n\n/**\n * Optional callback invoked once the redis command response arrives. Useful\n * for attaching response-derived attributes (e.g. cache hit/miss, payload size).\n *\n * Mirrors `@opentelemetry/instrumentation-ioredis`' response hook so existing\n * Sentry node code (`cacheResponseHook`) can be reused unchanged.\n */\nexport type RedisDiagnosticChannelResponseHook = (\n span: Span,\n cmdName: string,\n cmdArgs: string[],\n result: unknown,\n) => void;\n\n/**\n * Payload type observed by tracing-channel subscribers — the channel payload\n * with `_sentrySpan` stamped on it by the start handler so async/error\n * handlers downstream can read it back.\n */\nexport type RedisTracingChannelContextWithSpan<T> = T & { _sentrySpan?: Span };\n\n/** Subscriber object accepted by {@link RedisTracingChannel.subscribe}. */\nexport interface RedisTracingChannelSubscribers<T> {\n start: (data: RedisTracingChannelContextWithSpan<T>) => void;\n asyncStart: (data: RedisTracingChannelContextWithSpan<T>) => void;\n asyncEnd: (data: RedisTracingChannelContextWithSpan<T>) => void;\n end: (data: RedisTracingChannelContextWithSpan<T>) => void;\n error: (data: RedisTracingChannelContextWithSpan<T>) => void;\n}\n\n/** Minimal tracing-channel surface the subscriber depends on. */\nexport interface RedisTracingChannel<T extends object> {\n subscribe(subs: Partial<RedisTracingChannelSubscribers<T>>): void;\n}\n\n/**\n * Platform-provided factory that returns a tracing channel for the given\n * channel name. Implementations are responsible for ensuring that, when the\n * channel's `start` event fires, the span returned by `transformStart(data)`\n * ends up stored on `data._sentrySpan` so the subscriber's `asyncEnd`/`error`\n * handlers can read it.\n *\n * - Node passes `@sentry/opentelemetry/tracing-channel` which uses\n * `bindStore` to also propagate the span as the active OTel context.\n * - Deno (and other non-OTel runtimes) pass a portable wrapper around\n * `node:diagnostics_channel.tracingChannel` that just stamps\n * `data._sentrySpan` in `start` without `bindStore`.\n */\nexport type RedisTracingChannelFactory = <T extends object>(\n name: string,\n transformStart: (data: T) => Span,\n) => RedisTracingChannel<T>;\n\nlet subscribed = false;\nlet currentResponseHook: RedisDiagnosticChannelResponseHook | undefined;\n\n/**\n * Subscribe Sentry span handlers to node-redis and ioredis diagnostics-channel\n * events: `node-redis:command`/`:batch`/`:connect` (published by node-redis\n * >= 5.12.0) and `ioredis:command`/`:connect` (published by ioredis >= 5.11.0).\n *\n * On older client versions the channels are never published to, so subscribers\n * are inert — there is no double-instrumentation against any IITM-based\n * patcher gated to those older versions.\n *\n * Idempotent: subsequent calls update the response hook but do not\n * re-subscribe.\n */\nexport function subscribeRedisDiagnosticChannels(\n tracingChannel: RedisTracingChannelFactory,\n responseHook?: RedisDiagnosticChannelResponseHook,\n): void {\n currentResponseHook = responseHook;\n if (subscribed) return;\n subscribed = true;\n\n try {\n // node-redis: command name appears as args[0] in the channel payload, so\n // strip it before the statement and response hook see it.\n setupCommandChannel<RedisCommandData>(tracingChannel, REDIS_DC_CHANNEL_COMMAND, data => data.args.slice(1));\n setupBatchChannel(tracingChannel, REDIS_DC_CHANNEL_BATCH, data =>\n data.batchMode === 'PIPELINE' ? 'PIPELINE' : 'MULTI',\n );\n setupConnectChannel(tracingChannel, REDIS_DC_CHANNEL_CONNECT);\n\n // ioredis: args already exclude the command name; no slicing needed. And\n // ioredis has no separate batch channel — pipeline/MULTI metadata rides\n // on the per-command payload via `batchMode`/`batchSize`.\n setupCommandChannel<IORedisCommandData>(tracingChannel, IOREDIS_DC_CHANNEL_COMMAND, data => data.args);\n setupConnectChannel(tracingChannel, IOREDIS_DC_CHANNEL_CONNECT);\n } catch {\n // The factory may rely on `node:diagnostics_channel`, which isn't always\n // available. Fail closed; the SDK simply won't emit redis spans here.\n DEBUG_BUILD && debug.log('Redis node:diagnostics_channel subscription failed.');\n }\n}\n\nfunction setupCommandChannel<T extends RedisCommandData | IORedisCommandData>(\n tracingChannel: RedisTracingChannelFactory,\n channelName: string,\n getCommandArgs: (data: T) => string[],\n): void {\n const channel = tracingChannel<T>(channelName, data => {\n // `args` is already sanitized by the publishing library (node-redis /\n // ioredis call their own `sanitizeArgs` before publishing). Join with\n // spaces to mirror the format the libraries themselves intend.\n const args = getCommandArgs(data);\n const statement = args.length ? `${data.command} ${args.join(' ')}` : data.command;\n return startSpanManual(\n {\n name: `redis-${data.command}`,\n attributes: {\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: ORIGIN,\n [SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'db.redis',\n [DB_SYSTEM_NAME]: DB_SYSTEM_NAME_VALUE_REDIS,\n [DB_QUERY_TEXT]: statement,\n ...(data.serverAddress != null ? { [SERVER_ADDRESS]: data.serverAddress } : {}),\n ...(data.serverPort != null ? { [SERVER_PORT]: data.serverPort } : {}),\n },\n },\n span => span,\n );\n });\n\n channel.subscribe({\n start: NOOP,\n asyncStart: NOOP,\n end: NOOP,\n asyncEnd: data => {\n const span = data._sentrySpan;\n // Only end here if the error handler isn't going to.\n if (!span || data.error) return;\n runResponseHook(span, data.command, getCommandArgs(data), data.result);\n span.end();\n },\n error: data => {\n const span = data._sentrySpan;\n if (!span) return;\n if (data.error) {\n span.setStatus({ code: SPAN_STATUS_ERROR, message: data.error.message });\n }\n span.end();\n },\n });\n}\n\nfunction setupBatchChannel(\n tracingChannel: RedisTracingChannelFactory,\n channelName: string,\n getOperationName: (data: RedisBatchData) => string,\n): void {\n const channel = tracingChannel<RedisBatchData>(channelName, data => {\n return startSpanManual(\n {\n name: getOperationName(data),\n attributes: {\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: ORIGIN,\n [SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'db.redis',\n [DB_SYSTEM_NAME]: DB_SYSTEM_NAME_VALUE_REDIS,\n // should only include batch size greater than 1,\n // or else it isn't properly considered a \"batch\"\n ...(Number(data.batchSize) > 1 ? { [DB_OPERATION_BATCH_SIZE]: data.batchSize } : {}),\n ...(data.serverAddress != null ? { [SERVER_ADDRESS]: data.serverAddress } : {}),\n ...(data.serverPort != null ? { [SERVER_PORT]: data.serverPort } : {}),\n },\n },\n span => span,\n );\n });\n\n channel.subscribe({\n start: NOOP,\n asyncStart: NOOP,\n end: NOOP,\n asyncEnd: data => {\n if (!data.error) data._sentrySpan?.end();\n },\n error: data => {\n const span = data._sentrySpan;\n if (!span) return;\n if (data.error) {\n span.setStatus({ code: SPAN_STATUS_ERROR, message: data.error.message });\n }\n span.end();\n },\n });\n}\n\nfunction setupConnectChannel(tracingChannel: RedisTracingChannelFactory, channelName: string): void {\n const channel = tracingChannel<RedisConnectData>(channelName, data => {\n return startSpanManual(\n {\n name: 'redis-connect',\n attributes: {\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: ORIGIN,\n [SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'db.redis.connect',\n [DB_SYSTEM_NAME]: DB_SYSTEM_NAME_VALUE_REDIS,\n ...(data.serverAddress != null ? { [SERVER_ADDRESS]: data.serverAddress } : {}),\n ...(data.serverPort != null ? { [SERVER_PORT]: data.serverPort } : {}),\n },\n },\n span => span,\n );\n });\n\n channel.subscribe({\n start: NOOP,\n asyncStart: NOOP,\n end: NOOP,\n asyncEnd: data => {\n if (!data.error) data._sentrySpan?.end();\n },\n error: data => {\n const span = data._sentrySpan;\n if (!span) return;\n if (data.error) {\n span.setStatus({ code: SPAN_STATUS_ERROR, message: data.error.message });\n }\n span.end();\n },\n });\n}\n\nfunction runResponseHook(span: Span, command: string, args: string[], result: unknown): void {\n const hook = currentResponseHook;\n if (!hook) return;\n try {\n hook(span, command, args, result);\n } catch {\n // never let user hooks break instrumentation\n }\n}\n\n/** Test-only: reset module-local subscribe state. */\nexport function _resetRedisDiagnosticChannelsForTesting(): void {\n subscribed = false;\n currentResponseHook = undefined;\n}\n"],"names":[],"mappings":";;;;AAqBO,MAAM,wBAAA,GAA2B;AACjC,MAAM,sBAAA,GAAyB;AAC/B,MAAM,wBAAA,GAA2B;AACjC,MAAM,0BAAA,GAA6B;AACnC,MAAM,0BAAA,GAA6B;AAE1C,MAAM,MAAA,GAAS,kCAAA;AACf,MAAM,0BAAA,GAA6B,OAAA;AAEnC,MAAM,OA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CAAK,SAAA,CAAU,EAAE,IAAA,EAAM,iBAAA,EAAmB,SAAS,IAAA,CAAK,KAAA,CAAM,SAAS,CAAA;AAAA,MACzE;AACA,MAAA,IAAA,CAAK,GAAA,EAAI;AAAA,IACX;AAAA,GACD,CAAA;AACH;AAEA,SAAS,eAAA,CAAgB,IAAA,EAAY,OAAA,EAAiB,IAAA,EAAgB,MAAA,EAAuB;AAC3F,EAAA,MAAM,IAAA,GAAO,mBAAA;AACb,EAAA,IAAI,CAAC,IAAA,EAAM;AACX,EAAA,IAAI;AACF,IAAA,IAAA,CAAK,IAAA,EAAM,OAAA,EAAS,IAAA,EAAM,MAAM,CAAA;AAAA,EAClC,CAAA,CAAA,MAAQ;AAAA,EAER;AACF;;;;"}
@@ -0,0 +1,19 @@
1
+ import { registerDiagnosticsChannelInjection } from '@sentry/server-utils/orchestrion/register';
2
+
3
+ // EXPERIMENTAL — diagnostics-channel injection runtime hook. The side-effecting
4
+ // `--import` entry (e.g. `node --import @sentry/node/import app.js`) that injects
5
+ // the channels unconditionally before the app loads.
6
+ //
7
+ // All of the registration logic lives in `register.ts` — it has to be a
8
+ // CJS-compatible, dual-built module so `Sentry.init()` can `require()` it
9
+ // synchronously, and keeping a single source of truth means the `--import` path
10
+ // and the `init()` path can never drift apart. This file is just the
11
+ // side-effecting wrapper that invokes it.
12
+ //
13
+ // This file is shipped as-is to `build/orchestrion/import-hook.mjs`. Keep it a
14
+ // single self-contained `.mjs` file with no relative-path imports — `--import`
15
+ // resolves it (and the bare specifier below) via Node's module resolution
16
+ // against the installed package.
17
+
18
+
19
+ registerDiagnosticsChannelInjection();
@@ -0,0 +1,10 @@
1
+ /**
2
+ * EXPERIMENTAL — orchestrion-driven mysql integration.
3
+ *
4
+ * Subscribes to the `orchestrion:mysql:query` diagnostics_channel that the
5
+ * orchestrion code transform injects into `mysql/lib/Connection.js`'s
6
+ * `Connection.prototype.query`. Requires the orchestrion runtime hook or
7
+ * bundler plugin to be active — wire that up via `_experimentalSetupOrchestrion`.
8
+ */
9
+ export declare const mysqlChannelIntegration: () => import("@sentry/core").Integration;
10
+ //# sourceMappingURL=mysql.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mysql.d.ts","sourceRoot":"","sources":["../../../../src/integrations/tracing-channel/mysql.ts"],"names":[],"mappings":"AAkRA;;;;;;;GAOG;AACH,eAAO,MAAM,uBAAuB,0CAA8C,CAAC"}
@@ -0,0 +1,31 @@
1
+ type UnknownPlugin = any;
2
+ /**
3
+ * Vite plugin that runs the orchestrion code transform on the bundled output.
4
+ *
5
+ * Use when bundling a Node app with Vite (e.g. Vite SSR builds, Nuxt's Nitro
6
+ * pipeline, SvelteKit). For unbundled Node processes use the runtime hook
7
+ * instead (`node --import @sentry/node/orchestrion app.js`).
8
+ *
9
+ * Returns two plugins:
10
+ * 1. `sentry-orchestrion-marker` — a `renderChunk` hook that prepends a
11
+ * single-line banner to entry chunks. The banner sets
12
+ * `globalThis.__SENTRY_ORCHESTRION__.bundler = true` at app boot, so the
13
+ * `_experimentalSetupOrchestrion()` detector can confirm the bundler path
14
+ * ran (rather than relying on a build-time flag that wouldn't be visible
15
+ * to the runtime).
16
+ * Also injects every instrumented package name into `ssr.noExternal` via
17
+ * the `config` hook, since externalized deps are `require()`d at runtime
18
+ * from `node_modules` and never pass through the transform.
19
+ * 2. The upstream `@apm-js-collab/code-transformer-bundler-plugins/vite`
20
+ * plugin, fed our central `SENTRY_INSTRUMENTATIONS` config.
21
+ *
22
+ * @example
23
+ * ```ts
24
+ * // vite.config.ts
25
+ * import { sentryOrchestrionPlugin } from '@sentry/node/orchestrion/vite';
26
+ * export default { plugins: [sentryOrchestrionPlugin()] };
27
+ * ```
28
+ */
29
+ export declare function sentryOrchestrionPlugin(): UnknownPlugin[];
30
+ export {};
31
+ //# sourceMappingURL=vite.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vite.d.ts","sourceRoot":"","sources":["../../../../src/orchestrion/bundler/vite.ts"],"names":[],"mappings":"AAaA,KAAK,aAAa,GAAG,GAAG,CAAC;AAWzB;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,uBAAuB,IAAI,aAAa,EAAE,CAMzD"}