@prisma/instrumentation 6.7.0-dev.21 → 6.7.0-dev.23

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.
package/dist/constants.js CHANGED
@@ -16,14 +16,80 @@ var __copyProps = (to, from, except, desc) => {
16
16
  return to;
17
17
  };
18
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/constants.ts
19
21
  var constants_exports = {};
20
22
  __export(constants_exports, {
21
- GLOBAL_INSTRUMENTATION_ACCESSOR_KEY: () => import_chunk_7BGZUL2Z.GLOBAL_INSTRUMENTATION_ACCESSOR_KEY,
22
- GLOBAL_VERSIONED_INSTRUMENTATION_ACCESSOR_KEY: () => import_chunk_7BGZUL2Z.GLOBAL_VERSIONED_INSTRUMENTATION_ACCESSOR_KEY,
23
- MODULE_NAME: () => import_chunk_7BGZUL2Z.MODULE_NAME,
24
- NAME: () => import_chunk_7BGZUL2Z.NAME,
25
- VERSION: () => import_chunk_7BGZUL2Z.VERSION
23
+ GLOBAL_INSTRUMENTATION_ACCESSOR_KEY: () => GLOBAL_INSTRUMENTATION_ACCESSOR_KEY,
24
+ GLOBAL_VERSIONED_INSTRUMENTATION_ACCESSOR_KEY: () => GLOBAL_VERSIONED_INSTRUMENTATION_ACCESSOR_KEY,
25
+ MODULE_NAME: () => MODULE_NAME,
26
+ NAME: () => NAME,
27
+ VERSION: () => VERSION
26
28
  });
27
29
  module.exports = __toCommonJS(constants_exports);
28
- var import_chunk_7BGZUL2Z = require("./chunk-7BGZUL2Z.js");
29
- var import_chunk_FTA5RKYX = require("./chunk-FTA5RKYX.js");
30
+
31
+ // package.json
32
+ var package_default = {
33
+ name: "@prisma/instrumentation",
34
+ version: "6.7.0-dev.23",
35
+ description: "OpenTelemetry compliant instrumentation for Prisma Client",
36
+ main: "dist/index.js",
37
+ module: "dist/index.mjs",
38
+ types: "dist/index.d.ts",
39
+ license: "Apache-2.0",
40
+ homepage: "https://www.prisma.io",
41
+ repository: {
42
+ type: "git",
43
+ url: "https://github.com/prisma/prisma.git",
44
+ directory: "packages/instrumentation"
45
+ },
46
+ bugs: "https://github.com/prisma/prisma/issues",
47
+ devDependencies: {
48
+ "@prisma/internals": "workspace:*",
49
+ "@swc/core": "1.11.5",
50
+ "@types/jest": "29.5.14",
51
+ "@types/node": "18.19.76",
52
+ "@opentelemetry/api": "1.9.0",
53
+ jest: "29.7.0",
54
+ "jest-junit": "16.0.0",
55
+ typescript: "5.4.5"
56
+ },
57
+ dependencies: {
58
+ "@opentelemetry/instrumentation": "^0.52.0 || ^0.53.0 || ^0.54.0 || ^0.55.0 || ^0.56.0 || ^0.57.0"
59
+ },
60
+ peerDependencies: {
61
+ "@opentelemetry/api": "^1.8"
62
+ },
63
+ files: [
64
+ "dist"
65
+ ],
66
+ keywords: [
67
+ "prisma",
68
+ "instrumentation",
69
+ "opentelemetry",
70
+ "otel"
71
+ ],
72
+ scripts: {
73
+ dev: "DEV=true tsx helpers/build.ts",
74
+ build: "tsx helpers/build.ts",
75
+ prepublishOnly: "pnpm run build",
76
+ test: "jest"
77
+ },
78
+ sideEffects: false
79
+ };
80
+
81
+ // src/constants.ts
82
+ var VERSION = package_default.version;
83
+ var majorVersion = VERSION.split(".")[0];
84
+ var GLOBAL_INSTRUMENTATION_ACCESSOR_KEY = "PRISMA_INSTRUMENTATION";
85
+ var GLOBAL_VERSIONED_INSTRUMENTATION_ACCESSOR_KEY = `V${majorVersion}_PRISMA_INSTRUMENTATION`;
86
+ var NAME = package_default.name;
87
+ var MODULE_NAME = "@prisma/client";
88
+ // Annotate the CommonJS export names for ESM import in node:
89
+ 0 && (module.exports = {
90
+ GLOBAL_INSTRUMENTATION_ACCESSOR_KEY,
91
+ GLOBAL_VERSIONED_INSTRUMENTATION_ACCESSOR_KEY,
92
+ MODULE_NAME,
93
+ NAME,
94
+ VERSION
95
+ });
@@ -0,0 +1,64 @@
1
+ // package.json
2
+ var package_default = {
3
+ name: "@prisma/instrumentation",
4
+ version: "6.7.0-dev.23",
5
+ description: "OpenTelemetry compliant instrumentation for Prisma Client",
6
+ main: "dist/index.js",
7
+ module: "dist/index.mjs",
8
+ types: "dist/index.d.ts",
9
+ license: "Apache-2.0",
10
+ homepage: "https://www.prisma.io",
11
+ repository: {
12
+ type: "git",
13
+ url: "https://github.com/prisma/prisma.git",
14
+ directory: "packages/instrumentation"
15
+ },
16
+ bugs: "https://github.com/prisma/prisma/issues",
17
+ devDependencies: {
18
+ "@prisma/internals": "workspace:*",
19
+ "@swc/core": "1.11.5",
20
+ "@types/jest": "29.5.14",
21
+ "@types/node": "18.19.76",
22
+ "@opentelemetry/api": "1.9.0",
23
+ jest: "29.7.0",
24
+ "jest-junit": "16.0.0",
25
+ typescript: "5.4.5"
26
+ },
27
+ dependencies: {
28
+ "@opentelemetry/instrumentation": "^0.52.0 || ^0.53.0 || ^0.54.0 || ^0.55.0 || ^0.56.0 || ^0.57.0"
29
+ },
30
+ peerDependencies: {
31
+ "@opentelemetry/api": "^1.8"
32
+ },
33
+ files: [
34
+ "dist"
35
+ ],
36
+ keywords: [
37
+ "prisma",
38
+ "instrumentation",
39
+ "opentelemetry",
40
+ "otel"
41
+ ],
42
+ scripts: {
43
+ dev: "DEV=true tsx helpers/build.ts",
44
+ build: "tsx helpers/build.ts",
45
+ prepublishOnly: "pnpm run build",
46
+ test: "jest"
47
+ },
48
+ sideEffects: false
49
+ };
50
+
51
+ // src/constants.ts
52
+ var VERSION = package_default.version;
53
+ var majorVersion = VERSION.split(".")[0];
54
+ var GLOBAL_INSTRUMENTATION_ACCESSOR_KEY = "PRISMA_INSTRUMENTATION";
55
+ var GLOBAL_VERSIONED_INSTRUMENTATION_ACCESSOR_KEY = `V${majorVersion}_PRISMA_INSTRUMENTATION`;
56
+ var NAME = package_default.name;
57
+ var MODULE_NAME = "@prisma/client";
58
+ export {
59
+ GLOBAL_INSTRUMENTATION_ACCESSOR_KEY,
60
+ GLOBAL_VERSIONED_INSTRUMENTATION_ACCESSOR_KEY,
61
+ MODULE_NAME,
62
+ NAME,
63
+ VERSION
64
+ };
package/dist/index.js CHANGED
@@ -16,14 +16,239 @@ var __copyProps = (to, from, except, desc) => {
16
16
  return to;
17
17
  };
18
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/index.ts
19
21
  var index_exports = {};
20
22
  __export(index_exports, {
21
- PrismaInstrumentation: () => import_chunk_6KXTRSZK.PrismaInstrumentation,
22
- registerInstrumentations: () => import_instrumentation.registerInstrumentations
23
+ PrismaInstrumentation: () => PrismaInstrumentation,
24
+ registerInstrumentations: () => import_instrumentation2.registerInstrumentations
23
25
  });
24
26
  module.exports = __toCommonJS(index_exports);
25
- var import_chunk_6KXTRSZK = require("./chunk-6KXTRSZK.js");
26
- var import_chunk_LJTRIVKN = require("./chunk-LJTRIVKN.js");
27
- var import_chunk_7BGZUL2Z = require("./chunk-7BGZUL2Z.js");
28
- var import_chunk_FTA5RKYX = require("./chunk-FTA5RKYX.js");
27
+
28
+ // src/PrismaInstrumentation.ts
29
+ var import_api2 = require("@opentelemetry/api");
29
30
  var import_instrumentation = require("@opentelemetry/instrumentation");
31
+
32
+ // src/ActiveTracingHelper.ts
33
+ var import_api = require("@opentelemetry/api");
34
+ var showAllTraces = process.env.PRISMA_SHOW_ALL_TRACES === "true";
35
+ var nonSampledTraceParent = `00-10-10-00`;
36
+ function engineSpanKindToOtelSpanKind(engineSpanKind) {
37
+ switch (engineSpanKind) {
38
+ case "client":
39
+ return import_api.SpanKind.CLIENT;
40
+ case "internal":
41
+ default:
42
+ return import_api.SpanKind.INTERNAL;
43
+ }
44
+ }
45
+ var ActiveTracingHelper = class {
46
+ traceMiddleware;
47
+ tracerProvider;
48
+ ignoreSpanTypes;
49
+ constructor({ traceMiddleware, tracerProvider, ignoreSpanTypes }) {
50
+ this.traceMiddleware = traceMiddleware;
51
+ this.tracerProvider = tracerProvider;
52
+ this.ignoreSpanTypes = ignoreSpanTypes;
53
+ }
54
+ isEnabled() {
55
+ return true;
56
+ }
57
+ getTraceParent(context) {
58
+ const span = import_api.trace.getSpanContext(context ?? import_api.context.active());
59
+ if (span) {
60
+ return `00-${span.traceId}-${span.spanId}-0${span.traceFlags}`;
61
+ }
62
+ return nonSampledTraceParent;
63
+ }
64
+ dispatchEngineSpans(spans) {
65
+ const tracer = this.tracerProvider.getTracer("prisma");
66
+ const linkIds = /* @__PURE__ */ new Map();
67
+ const roots = spans.filter((span) => span.parentId === null);
68
+ for (const root of roots) {
69
+ dispatchEngineSpan(tracer, root, spans, linkIds, this.ignoreSpanTypes);
70
+ }
71
+ }
72
+ getActiveContext() {
73
+ return import_api.context.active();
74
+ }
75
+ runInChildSpan(options, callback) {
76
+ if (typeof options === "string") {
77
+ options = { name: options };
78
+ }
79
+ if (options.internal && !showAllTraces) {
80
+ return callback();
81
+ }
82
+ if (options.middleware && !this.traceMiddleware) {
83
+ return callback();
84
+ }
85
+ const tracer = this.tracerProvider.getTracer("prisma");
86
+ const context = options.context ?? this.getActiveContext();
87
+ const name = `prisma:client:${options.name}`;
88
+ if (shouldIgnoreSpan(name, this.ignoreSpanTypes)) {
89
+ return callback();
90
+ }
91
+ if (options.active === false) {
92
+ const span = tracer.startSpan(name, options, context);
93
+ return endSpan(span, callback(span, context));
94
+ }
95
+ return tracer.startActiveSpan(name, options, (span) => endSpan(span, callback(span, context)));
96
+ }
97
+ };
98
+ function dispatchEngineSpan(tracer, engineSpan, allSpans, linkIds, ignoreSpanTypes) {
99
+ if (shouldIgnoreSpan(engineSpan.name, ignoreSpanTypes)) return;
100
+ const spanOptions = {
101
+ attributes: engineSpan.attributes,
102
+ kind: engineSpanKindToOtelSpanKind(engineSpan.kind),
103
+ startTime: engineSpan.startTime
104
+ };
105
+ tracer.startActiveSpan(engineSpan.name, spanOptions, (span) => {
106
+ linkIds.set(engineSpan.id, span.spanContext().spanId);
107
+ if (engineSpan.links) {
108
+ span.addLinks(
109
+ engineSpan.links.flatMap((link) => {
110
+ const linkedId = linkIds.get(link);
111
+ if (!linkedId) {
112
+ return [];
113
+ }
114
+ return {
115
+ context: {
116
+ spanId: linkedId,
117
+ traceId: span.spanContext().traceId,
118
+ traceFlags: span.spanContext().traceFlags
119
+ }
120
+ };
121
+ })
122
+ );
123
+ }
124
+ const children = allSpans.filter((s) => s.parentId === engineSpan.id);
125
+ for (const child of children) {
126
+ dispatchEngineSpan(tracer, child, allSpans, linkIds, ignoreSpanTypes);
127
+ }
128
+ span.end(engineSpan.endTime);
129
+ });
130
+ }
131
+ function endSpan(span, result) {
132
+ if (isPromiseLike(result)) {
133
+ return result.then(
134
+ (value) => {
135
+ span.end();
136
+ return value;
137
+ },
138
+ (reason) => {
139
+ span.end();
140
+ throw reason;
141
+ }
142
+ );
143
+ }
144
+ span.end();
145
+ return result;
146
+ }
147
+ function isPromiseLike(value) {
148
+ return value != null && typeof value["then"] === "function";
149
+ }
150
+ function shouldIgnoreSpan(spanName, ignoreSpanTypes) {
151
+ return ignoreSpanTypes.some(
152
+ (pattern) => typeof pattern === "string" ? pattern === spanName : pattern.test(spanName)
153
+ );
154
+ }
155
+
156
+ // package.json
157
+ var package_default = {
158
+ name: "@prisma/instrumentation",
159
+ version: "6.7.0-dev.23",
160
+ description: "OpenTelemetry compliant instrumentation for Prisma Client",
161
+ main: "dist/index.js",
162
+ module: "dist/index.mjs",
163
+ types: "dist/index.d.ts",
164
+ license: "Apache-2.0",
165
+ homepage: "https://www.prisma.io",
166
+ repository: {
167
+ type: "git",
168
+ url: "https://github.com/prisma/prisma.git",
169
+ directory: "packages/instrumentation"
170
+ },
171
+ bugs: "https://github.com/prisma/prisma/issues",
172
+ devDependencies: {
173
+ "@prisma/internals": "workspace:*",
174
+ "@swc/core": "1.11.5",
175
+ "@types/jest": "29.5.14",
176
+ "@types/node": "18.19.76",
177
+ "@opentelemetry/api": "1.9.0",
178
+ jest: "29.7.0",
179
+ "jest-junit": "16.0.0",
180
+ typescript: "5.4.5"
181
+ },
182
+ dependencies: {
183
+ "@opentelemetry/instrumentation": "^0.52.0 || ^0.53.0 || ^0.54.0 || ^0.55.0 || ^0.56.0 || ^0.57.0"
184
+ },
185
+ peerDependencies: {
186
+ "@opentelemetry/api": "^1.8"
187
+ },
188
+ files: [
189
+ "dist"
190
+ ],
191
+ keywords: [
192
+ "prisma",
193
+ "instrumentation",
194
+ "opentelemetry",
195
+ "otel"
196
+ ],
197
+ scripts: {
198
+ dev: "DEV=true tsx helpers/build.ts",
199
+ build: "tsx helpers/build.ts",
200
+ prepublishOnly: "pnpm run build",
201
+ test: "jest"
202
+ },
203
+ sideEffects: false
204
+ };
205
+
206
+ // src/constants.ts
207
+ var VERSION = package_default.version;
208
+ var majorVersion = VERSION.split(".")[0];
209
+ var GLOBAL_INSTRUMENTATION_ACCESSOR_KEY = "PRISMA_INSTRUMENTATION";
210
+ var GLOBAL_VERSIONED_INSTRUMENTATION_ACCESSOR_KEY = `V${majorVersion}_PRISMA_INSTRUMENTATION`;
211
+ var NAME = package_default.name;
212
+ var MODULE_NAME = "@prisma/client";
213
+
214
+ // src/PrismaInstrumentation.ts
215
+ var PrismaInstrumentation = class extends import_instrumentation.InstrumentationBase {
216
+ tracerProvider;
217
+ constructor(config = {}) {
218
+ super(NAME, VERSION, config);
219
+ }
220
+ setTracerProvider(tracerProvider) {
221
+ this.tracerProvider = tracerProvider;
222
+ }
223
+ init() {
224
+ const module2 = new import_instrumentation.InstrumentationNodeModuleDefinition(MODULE_NAME, [VERSION]);
225
+ return [module2];
226
+ }
227
+ enable() {
228
+ const config = this._config;
229
+ const globalValue = {
230
+ helper: new ActiveTracingHelper({
231
+ traceMiddleware: config.middleware ?? false,
232
+ tracerProvider: this.tracerProvider ?? import_api2.trace.getTracerProvider(),
233
+ ignoreSpanTypes: config.ignoreSpanTypes ?? []
234
+ })
235
+ };
236
+ global[GLOBAL_INSTRUMENTATION_ACCESSOR_KEY] = globalValue;
237
+ global[GLOBAL_VERSIONED_INSTRUMENTATION_ACCESSOR_KEY] = globalValue;
238
+ }
239
+ disable() {
240
+ delete global[GLOBAL_INSTRUMENTATION_ACCESSOR_KEY];
241
+ delete global[GLOBAL_VERSIONED_INSTRUMENTATION_ACCESSOR_KEY];
242
+ }
243
+ isEnabled() {
244
+ return Boolean(global[GLOBAL_VERSIONED_INSTRUMENTATION_ACCESSOR_KEY]);
245
+ }
246
+ };
247
+
248
+ // src/index.ts
249
+ var import_instrumentation2 = require("@opentelemetry/instrumentation");
250
+ // Annotate the CommonJS export names for ESM import in node:
251
+ 0 && (module.exports = {
252
+ PrismaInstrumentation,
253
+ registerInstrumentations
254
+ });
package/dist/index.mjs ADDED
@@ -0,0 +1,233 @@
1
+ // src/PrismaInstrumentation.ts
2
+ import { trace as trace2 } from "@opentelemetry/api";
3
+ import {
4
+ InstrumentationBase,
5
+ InstrumentationNodeModuleDefinition
6
+ } from "@opentelemetry/instrumentation";
7
+
8
+ // src/ActiveTracingHelper.ts
9
+ import {
10
+ context as _context,
11
+ SpanKind,
12
+ trace
13
+ } from "@opentelemetry/api";
14
+ var showAllTraces = process.env.PRISMA_SHOW_ALL_TRACES === "true";
15
+ var nonSampledTraceParent = `00-10-10-00`;
16
+ function engineSpanKindToOtelSpanKind(engineSpanKind) {
17
+ switch (engineSpanKind) {
18
+ case "client":
19
+ return SpanKind.CLIENT;
20
+ case "internal":
21
+ default:
22
+ return SpanKind.INTERNAL;
23
+ }
24
+ }
25
+ var ActiveTracingHelper = class {
26
+ traceMiddleware;
27
+ tracerProvider;
28
+ ignoreSpanTypes;
29
+ constructor({ traceMiddleware, tracerProvider, ignoreSpanTypes }) {
30
+ this.traceMiddleware = traceMiddleware;
31
+ this.tracerProvider = tracerProvider;
32
+ this.ignoreSpanTypes = ignoreSpanTypes;
33
+ }
34
+ isEnabled() {
35
+ return true;
36
+ }
37
+ getTraceParent(context) {
38
+ const span = trace.getSpanContext(context ?? _context.active());
39
+ if (span) {
40
+ return `00-${span.traceId}-${span.spanId}-0${span.traceFlags}`;
41
+ }
42
+ return nonSampledTraceParent;
43
+ }
44
+ dispatchEngineSpans(spans) {
45
+ const tracer = this.tracerProvider.getTracer("prisma");
46
+ const linkIds = /* @__PURE__ */ new Map();
47
+ const roots = spans.filter((span) => span.parentId === null);
48
+ for (const root of roots) {
49
+ dispatchEngineSpan(tracer, root, spans, linkIds, this.ignoreSpanTypes);
50
+ }
51
+ }
52
+ getActiveContext() {
53
+ return _context.active();
54
+ }
55
+ runInChildSpan(options, callback) {
56
+ if (typeof options === "string") {
57
+ options = { name: options };
58
+ }
59
+ if (options.internal && !showAllTraces) {
60
+ return callback();
61
+ }
62
+ if (options.middleware && !this.traceMiddleware) {
63
+ return callback();
64
+ }
65
+ const tracer = this.tracerProvider.getTracer("prisma");
66
+ const context = options.context ?? this.getActiveContext();
67
+ const name = `prisma:client:${options.name}`;
68
+ if (shouldIgnoreSpan(name, this.ignoreSpanTypes)) {
69
+ return callback();
70
+ }
71
+ if (options.active === false) {
72
+ const span = tracer.startSpan(name, options, context);
73
+ return endSpan(span, callback(span, context));
74
+ }
75
+ return tracer.startActiveSpan(name, options, (span) => endSpan(span, callback(span, context)));
76
+ }
77
+ };
78
+ function dispatchEngineSpan(tracer, engineSpan, allSpans, linkIds, ignoreSpanTypes) {
79
+ if (shouldIgnoreSpan(engineSpan.name, ignoreSpanTypes)) return;
80
+ const spanOptions = {
81
+ attributes: engineSpan.attributes,
82
+ kind: engineSpanKindToOtelSpanKind(engineSpan.kind),
83
+ startTime: engineSpan.startTime
84
+ };
85
+ tracer.startActiveSpan(engineSpan.name, spanOptions, (span) => {
86
+ linkIds.set(engineSpan.id, span.spanContext().spanId);
87
+ if (engineSpan.links) {
88
+ span.addLinks(
89
+ engineSpan.links.flatMap((link) => {
90
+ const linkedId = linkIds.get(link);
91
+ if (!linkedId) {
92
+ return [];
93
+ }
94
+ return {
95
+ context: {
96
+ spanId: linkedId,
97
+ traceId: span.spanContext().traceId,
98
+ traceFlags: span.spanContext().traceFlags
99
+ }
100
+ };
101
+ })
102
+ );
103
+ }
104
+ const children = allSpans.filter((s) => s.parentId === engineSpan.id);
105
+ for (const child of children) {
106
+ dispatchEngineSpan(tracer, child, allSpans, linkIds, ignoreSpanTypes);
107
+ }
108
+ span.end(engineSpan.endTime);
109
+ });
110
+ }
111
+ function endSpan(span, result) {
112
+ if (isPromiseLike(result)) {
113
+ return result.then(
114
+ (value) => {
115
+ span.end();
116
+ return value;
117
+ },
118
+ (reason) => {
119
+ span.end();
120
+ throw reason;
121
+ }
122
+ );
123
+ }
124
+ span.end();
125
+ return result;
126
+ }
127
+ function isPromiseLike(value) {
128
+ return value != null && typeof value["then"] === "function";
129
+ }
130
+ function shouldIgnoreSpan(spanName, ignoreSpanTypes) {
131
+ return ignoreSpanTypes.some(
132
+ (pattern) => typeof pattern === "string" ? pattern === spanName : pattern.test(spanName)
133
+ );
134
+ }
135
+
136
+ // package.json
137
+ var package_default = {
138
+ name: "@prisma/instrumentation",
139
+ version: "6.7.0-dev.23",
140
+ description: "OpenTelemetry compliant instrumentation for Prisma Client",
141
+ main: "dist/index.js",
142
+ module: "dist/index.mjs",
143
+ types: "dist/index.d.ts",
144
+ license: "Apache-2.0",
145
+ homepage: "https://www.prisma.io",
146
+ repository: {
147
+ type: "git",
148
+ url: "https://github.com/prisma/prisma.git",
149
+ directory: "packages/instrumentation"
150
+ },
151
+ bugs: "https://github.com/prisma/prisma/issues",
152
+ devDependencies: {
153
+ "@prisma/internals": "workspace:*",
154
+ "@swc/core": "1.11.5",
155
+ "@types/jest": "29.5.14",
156
+ "@types/node": "18.19.76",
157
+ "@opentelemetry/api": "1.9.0",
158
+ jest: "29.7.0",
159
+ "jest-junit": "16.0.0",
160
+ typescript: "5.4.5"
161
+ },
162
+ dependencies: {
163
+ "@opentelemetry/instrumentation": "^0.52.0 || ^0.53.0 || ^0.54.0 || ^0.55.0 || ^0.56.0 || ^0.57.0"
164
+ },
165
+ peerDependencies: {
166
+ "@opentelemetry/api": "^1.8"
167
+ },
168
+ files: [
169
+ "dist"
170
+ ],
171
+ keywords: [
172
+ "prisma",
173
+ "instrumentation",
174
+ "opentelemetry",
175
+ "otel"
176
+ ],
177
+ scripts: {
178
+ dev: "DEV=true tsx helpers/build.ts",
179
+ build: "tsx helpers/build.ts",
180
+ prepublishOnly: "pnpm run build",
181
+ test: "jest"
182
+ },
183
+ sideEffects: false
184
+ };
185
+
186
+ // src/constants.ts
187
+ var VERSION = package_default.version;
188
+ var majorVersion = VERSION.split(".")[0];
189
+ var GLOBAL_INSTRUMENTATION_ACCESSOR_KEY = "PRISMA_INSTRUMENTATION";
190
+ var GLOBAL_VERSIONED_INSTRUMENTATION_ACCESSOR_KEY = `V${majorVersion}_PRISMA_INSTRUMENTATION`;
191
+ var NAME = package_default.name;
192
+ var MODULE_NAME = "@prisma/client";
193
+
194
+ // src/PrismaInstrumentation.ts
195
+ var PrismaInstrumentation = class extends InstrumentationBase {
196
+ tracerProvider;
197
+ constructor(config = {}) {
198
+ super(NAME, VERSION, config);
199
+ }
200
+ setTracerProvider(tracerProvider) {
201
+ this.tracerProvider = tracerProvider;
202
+ }
203
+ init() {
204
+ const module = new InstrumentationNodeModuleDefinition(MODULE_NAME, [VERSION]);
205
+ return [module];
206
+ }
207
+ enable() {
208
+ const config = this._config;
209
+ const globalValue = {
210
+ helper: new ActiveTracingHelper({
211
+ traceMiddleware: config.middleware ?? false,
212
+ tracerProvider: this.tracerProvider ?? trace2.getTracerProvider(),
213
+ ignoreSpanTypes: config.ignoreSpanTypes ?? []
214
+ })
215
+ };
216
+ global[GLOBAL_INSTRUMENTATION_ACCESSOR_KEY] = globalValue;
217
+ global[GLOBAL_VERSIONED_INSTRUMENTATION_ACCESSOR_KEY] = globalValue;
218
+ }
219
+ disable() {
220
+ delete global[GLOBAL_INSTRUMENTATION_ACCESSOR_KEY];
221
+ delete global[GLOBAL_VERSIONED_INSTRUMENTATION_ACCESSOR_KEY];
222
+ }
223
+ isEnabled() {
224
+ return Boolean(global[GLOBAL_VERSIONED_INSTRUMENTATION_ACCESSOR_KEY]);
225
+ }
226
+ };
227
+
228
+ // src/index.ts
229
+ import { registerInstrumentations } from "@opentelemetry/instrumentation";
230
+ export {
231
+ PrismaInstrumentation,
232
+ registerInstrumentations
233
+ };
package/package.json CHANGED
@@ -1,8 +1,9 @@
1
1
  {
2
2
  "name": "@prisma/instrumentation",
3
- "version": "6.7.0-dev.21",
3
+ "version": "6.7.0-dev.23",
4
4
  "description": "OpenTelemetry compliant instrumentation for Prisma Client",
5
5
  "main": "dist/index.js",
6
+ "module": "dist/index.mjs",
6
7
  "types": "dist/index.d.ts",
7
8
  "license": "Apache-2.0",
8
9
  "homepage": "https://www.prisma.io",
@@ -20,7 +21,7 @@
20
21
  "jest": "29.7.0",
21
22
  "jest-junit": "16.0.0",
22
23
  "typescript": "5.4.5",
23
- "@prisma/internals": "6.7.0-dev.21"
24
+ "@prisma/internals": "6.7.0-dev.23"
24
25
  },
25
26
  "dependencies": {
26
27
  "@opentelemetry/instrumentation": "^0.52.0 || ^0.53.0 || ^0.54.0 || ^0.55.0 || ^0.56.0 || ^0.57.0"