@prisma/instrumentation-contract 7.9.0 → 7.10.0-dev.2

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/README.md CHANGED
@@ -44,8 +44,13 @@ const myTracingHelper: TracingHelper = {
44
44
  return '00-traceId-spanId-01'
45
45
  },
46
46
 
47
- dispatchEngineSpans(spans) {
47
+ dispatchEngineSpans(spans, events, emitLogEvent) {
48
48
  // Handle emulated remote spans. In Prisma 7, this is only used for Accelerate spans.
49
+ // Every event must be handed to `emitLogEvent`, ideally while the span it
50
+ // belongs to is active, or the client drops logs the user asked for.
51
+ for (const event of events) {
52
+ emitLogEvent(event)
53
+ }
49
54
  },
50
55
 
51
56
  getActiveContext() {
@@ -92,7 +97,11 @@ The main interface for tracing integration:
92
97
  interface TracingHelper {
93
98
  isEnabled(): boolean
94
99
  getTraceParent(context?: Context): string
95
- dispatchEngineSpans(spans: EngineSpan[]): void
100
+ dispatchEngineSpans(
101
+ spans: EngineSpan[],
102
+ events: EngineTraceEvent[],
103
+ emitLogEvent: (event: EngineTraceEvent) => void,
104
+ ): void
96
105
  getActiveContext(): Context | undefined
97
106
  runInChildSpan<R>(nameOrOptions: string | ExtendedSpanOptions, callback: SpanCallback<R>): R
98
107
  }
package/dist/index.d.mts CHANGED
@@ -76,7 +76,18 @@ export declare type SpanCallback<R> = (span?: Span, context?: Context) => R;
76
76
  export declare interface TracingHelper {
77
77
  isEnabled(): boolean;
78
78
  getTraceParent(context?: Context): string;
79
- dispatchEngineSpans(spans: EngineSpan[]): void;
79
+ /**
80
+ * Emits spans reported by a remote engine, together with the log events that
81
+ * were recorded while those spans were open.
82
+ *
83
+ * Implementations must call `emitLogEvent` exactly once for every entry in
84
+ * `events`, otherwise the client silently drops logs the user asked for. Each
85
+ * event should be emitted while the span identified by its `spanId` is the
86
+ * active one, so that handlers registered via `$on` observe the same context
87
+ * they would for a locally executed query. Events whose span is missing or
88
+ * not emitted must still be passed to `emitLogEvent`.
89
+ */
90
+ dispatchEngineSpans(spans: EngineSpan[], events: EngineTraceEvent[], emitLogEvent: (event: EngineTraceEvent) => void): void;
80
91
  getActiveContext(): Context | undefined;
81
92
  runInChildSpan<R>(nameOrOptions: string | ExtendedSpanOptions, callback: SpanCallback<R>): R;
82
93
  }
package/dist/index.d.ts CHANGED
@@ -76,7 +76,18 @@ export declare type SpanCallback<R> = (span?: Span, context?: Context) => R;
76
76
  export declare interface TracingHelper {
77
77
  isEnabled(): boolean;
78
78
  getTraceParent(context?: Context): string;
79
- dispatchEngineSpans(spans: EngineSpan[]): void;
79
+ /**
80
+ * Emits spans reported by a remote engine, together with the log events that
81
+ * were recorded while those spans were open.
82
+ *
83
+ * Implementations must call `emitLogEvent` exactly once for every entry in
84
+ * `events`, otherwise the client silently drops logs the user asked for. Each
85
+ * event should be emitted while the span identified by its `spanId` is the
86
+ * active one, so that handlers registered via `$on` observe the same context
87
+ * they would for a locally executed query. Events whose span is missing or
88
+ * not emitted must still be passed to `emitLogEvent`.
89
+ */
90
+ dispatchEngineSpans(spans: EngineSpan[], events: EngineTraceEvent[], emitLogEvent: (event: EngineTraceEvent) => void): void;
80
91
  getActiveContext(): Context | undefined;
81
92
  runInChildSpan<R>(nameOrOptions: string | ExtendedSpanOptions, callback: SpanCallback<R>): R;
82
93
  }
package/dist/index.js CHANGED
@@ -29,7 +29,7 @@ module.exports = __toCommonJS(index_exports);
29
29
  // package.json
30
30
  var package_default = {
31
31
  name: "@prisma/instrumentation-contract",
32
- version: "7.9.0",
32
+ version: "7.10.0-dev.2",
33
33
  description: "Shared types and utilities for Prisma instrumentation",
34
34
  main: "dist/index.js",
35
35
  module: "dist/index.mjs",
package/dist/index.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  // package.json
2
2
  var package_default = {
3
3
  name: "@prisma/instrumentation-contract",
4
- version: "7.9.0",
4
+ version: "7.10.0-dev.2",
5
5
  description: "Shared types and utilities for Prisma instrumentation",
6
6
  main: "dist/index.js",
7
7
  module: "dist/index.mjs",
@@ -42,7 +42,18 @@ export interface EngineTrace {
42
42
  export interface TracingHelper {
43
43
  isEnabled(): boolean;
44
44
  getTraceParent(context?: Context): string;
45
- dispatchEngineSpans(spans: EngineSpan[]): void;
45
+ /**
46
+ * Emits spans reported by a remote engine, together with the log events that
47
+ * were recorded while those spans were open.
48
+ *
49
+ * Implementations must call `emitLogEvent` exactly once for every entry in
50
+ * `events`, otherwise the client silently drops logs the user asked for. Each
51
+ * event should be emitted while the span identified by its `spanId` is the
52
+ * active one, so that handlers registered via `$on` observe the same context
53
+ * they would for a locally executed query. Events whose span is missing or
54
+ * not emitted must still be passed to `emitLogEvent`.
55
+ */
56
+ dispatchEngineSpans(spans: EngineSpan[], events: EngineTraceEvent[], emitLogEvent: (event: EngineTraceEvent) => void): void;
46
57
  getActiveContext(): Context | undefined;
47
58
  runInChildSpan<R>(nameOrOptions: string | ExtendedSpanOptions, callback: SpanCallback<R>): R;
48
59
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prisma/instrumentation-contract",
3
- "version": "7.9.0",
3
+ "version": "7.10.0-dev.2",
4
4
  "description": "Shared types and utilities for Prisma instrumentation",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",