braintrust 3.3.0 → 3.4.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.
- package/README.md +52 -67
- package/dev/dist/index.d.mts +53 -9
- package/dev/dist/index.d.ts +53 -9
- package/dev/dist/index.js +1839 -1298
- package/dev/dist/index.mjs +1503 -962
- package/dist/auto-instrumentations/bundler/esbuild.cjs +270 -23
- package/dist/auto-instrumentations/bundler/esbuild.mjs +2 -2
- package/dist/auto-instrumentations/bundler/rollup.cjs +270 -23
- package/dist/auto-instrumentations/bundler/rollup.mjs +2 -2
- package/dist/auto-instrumentations/bundler/vite.cjs +270 -23
- package/dist/auto-instrumentations/bundler/vite.mjs +2 -2
- package/dist/auto-instrumentations/bundler/webpack.cjs +270 -23
- package/dist/auto-instrumentations/bundler/webpack.mjs +2 -2
- package/dist/auto-instrumentations/{chunk-OLOPGWTJ.mjs → chunk-D5ZPIUEL.mjs} +1 -1
- package/dist/auto-instrumentations/chunk-LVWWLUMN.mjs +535 -0
- package/dist/auto-instrumentations/hook.mjs +306 -23
- package/dist/auto-instrumentations/index.cjs +270 -23
- package/dist/auto-instrumentations/index.d.mts +5 -5
- package/dist/auto-instrumentations/index.d.ts +5 -5
- package/dist/auto-instrumentations/index.mjs +1 -1
- package/dist/auto-instrumentations/loader/esm-hook.mjs +7 -8
- package/dist/browser.d.mts +474 -47
- package/dist/browser.d.ts +474 -47
- package/dist/browser.js +2258 -2095
- package/dist/browser.mjs +2258 -2095
- package/dist/cli.js +1817 -1232
- package/dist/edge-light.d.mts +1 -1
- package/dist/edge-light.d.ts +1 -1
- package/dist/edge-light.js +2188 -2027
- package/dist/edge-light.mjs +2188 -2027
- package/dist/index.d.mts +474 -47
- package/dist/index.d.ts +474 -47
- package/dist/index.js +2576 -2415
- package/dist/index.mjs +2259 -2098
- package/dist/instrumentation/index.d.mts +16 -22
- package/dist/instrumentation/index.d.ts +16 -22
- package/dist/instrumentation/index.js +1558 -1068
- package/dist/instrumentation/index.mjs +1558 -1068
- package/dist/workerd.d.mts +1 -1
- package/dist/workerd.d.ts +1 -1
- package/dist/workerd.js +2188 -2027
- package/dist/workerd.mjs +2188 -2027
- package/package.json +6 -3
- package/dist/auto-instrumentations/chunk-KVX7OFPD.mjs +0 -288
|
@@ -1,4 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
interface IsoChannelHandlers<M = any> {
|
|
2
|
+
start?: (context: M, name: string) => void;
|
|
3
|
+
end?: (context: M, name: string) => void;
|
|
4
|
+
asyncStart?: (context: M, name: string) => void;
|
|
5
|
+
asyncEnd?: (context: M, name: string) => void;
|
|
6
|
+
error?: (context: M, name: string) => void;
|
|
7
|
+
}
|
|
2
8
|
|
|
3
9
|
/**
|
|
4
10
|
* Base class for creating instrumentation plugins.
|
|
@@ -33,7 +39,7 @@ declare abstract class BasePlugin {
|
|
|
33
39
|
* @param channelName - The channel name to subscribe to
|
|
34
40
|
* @param handlers - Event handlers
|
|
35
41
|
*/
|
|
36
|
-
protected subscribe(channelName: string, handlers:
|
|
42
|
+
protected subscribe(channelName: string, handlers: IsoChannelHandlers): void;
|
|
37
43
|
/**
|
|
38
44
|
* Subscribe to a channel for async methods (non-streaming).
|
|
39
45
|
* Creates a span and logs input/output/metrics.
|
|
@@ -45,8 +51,9 @@ declare abstract class BasePlugin {
|
|
|
45
51
|
input: any;
|
|
46
52
|
metadata: any;
|
|
47
53
|
};
|
|
48
|
-
extractOutput: (result: any) => any;
|
|
49
|
-
|
|
54
|
+
extractOutput: (result: any, endEvent?: any) => any;
|
|
55
|
+
extractMetadata?: (result: any, endEvent?: any) => any;
|
|
56
|
+
extractMetrics: (result: any, startTime?: number, endEvent?: any) => Record<string, number>;
|
|
50
57
|
}): void;
|
|
51
58
|
/**
|
|
52
59
|
* Subscribe to a channel for async methods that may return streams.
|
|
@@ -59,11 +66,13 @@ declare abstract class BasePlugin {
|
|
|
59
66
|
input: any;
|
|
60
67
|
metadata: any;
|
|
61
68
|
};
|
|
62
|
-
extractOutput: (result: any) => any;
|
|
63
|
-
|
|
64
|
-
|
|
69
|
+
extractOutput: (result: any, endEvent?: any) => any;
|
|
70
|
+
extractMetadata?: (result: any, endEvent?: any) => any;
|
|
71
|
+
extractMetrics: (result: any, startTime?: number, endEvent?: any) => Record<string, number>;
|
|
72
|
+
aggregateChunks?: (chunks: any[], result?: any, endEvent?: any) => {
|
|
65
73
|
output: any;
|
|
66
74
|
metrics: Record<string, number>;
|
|
75
|
+
metadata?: any;
|
|
67
76
|
};
|
|
68
77
|
}): void;
|
|
69
78
|
/**
|
|
@@ -122,17 +131,6 @@ declare function parseChannelName(channelName: string): {
|
|
|
122
131
|
*/
|
|
123
132
|
declare function isValidChannelName(channelName: string): boolean;
|
|
124
133
|
|
|
125
|
-
/**
|
|
126
|
-
* Standard event types for diagnostics_channel-based instrumentation.
|
|
127
|
-
*
|
|
128
|
-
* These types follow the TracingChannel pattern from Node.js.
|
|
129
|
-
* For async functions (tracePromise):
|
|
130
|
-
* - start: Called before the synchronous portion executes
|
|
131
|
-
* - end: Called after the synchronous portion completes (promise returned)
|
|
132
|
-
* - asyncStart: Called when the promise begins to settle
|
|
133
|
-
* - asyncEnd: Called when the promise finishes settling (before user code continues)
|
|
134
|
-
* - error: Called if the function throws or the promise rejects
|
|
135
|
-
*/
|
|
136
134
|
/**
|
|
137
135
|
* Base context object shared across all events in a trace.
|
|
138
136
|
*/
|
|
@@ -186,10 +184,6 @@ interface ErrorEvent extends BaseContext {
|
|
|
186
184
|
*/
|
|
187
185
|
arguments?: unknown[];
|
|
188
186
|
}
|
|
189
|
-
/**
|
|
190
|
-
* Event emitted when a promise begins to settle.
|
|
191
|
-
* This fires after the synchronous portion and when the async continuation starts.
|
|
192
|
-
*/
|
|
193
187
|
interface AsyncStartEvent<TInput = unknown> extends StartEvent<TInput> {
|
|
194
188
|
}
|
|
195
189
|
/**
|
|
@@ -1,4 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
interface IsoChannelHandlers<M = any> {
|
|
2
|
+
start?: (context: M, name: string) => void;
|
|
3
|
+
end?: (context: M, name: string) => void;
|
|
4
|
+
asyncStart?: (context: M, name: string) => void;
|
|
5
|
+
asyncEnd?: (context: M, name: string) => void;
|
|
6
|
+
error?: (context: M, name: string) => void;
|
|
7
|
+
}
|
|
2
8
|
|
|
3
9
|
/**
|
|
4
10
|
* Base class for creating instrumentation plugins.
|
|
@@ -33,7 +39,7 @@ declare abstract class BasePlugin {
|
|
|
33
39
|
* @param channelName - The channel name to subscribe to
|
|
34
40
|
* @param handlers - Event handlers
|
|
35
41
|
*/
|
|
36
|
-
protected subscribe(channelName: string, handlers:
|
|
42
|
+
protected subscribe(channelName: string, handlers: IsoChannelHandlers): void;
|
|
37
43
|
/**
|
|
38
44
|
* Subscribe to a channel for async methods (non-streaming).
|
|
39
45
|
* Creates a span and logs input/output/metrics.
|
|
@@ -45,8 +51,9 @@ declare abstract class BasePlugin {
|
|
|
45
51
|
input: any;
|
|
46
52
|
metadata: any;
|
|
47
53
|
};
|
|
48
|
-
extractOutput: (result: any) => any;
|
|
49
|
-
|
|
54
|
+
extractOutput: (result: any, endEvent?: any) => any;
|
|
55
|
+
extractMetadata?: (result: any, endEvent?: any) => any;
|
|
56
|
+
extractMetrics: (result: any, startTime?: number, endEvent?: any) => Record<string, number>;
|
|
50
57
|
}): void;
|
|
51
58
|
/**
|
|
52
59
|
* Subscribe to a channel for async methods that may return streams.
|
|
@@ -59,11 +66,13 @@ declare abstract class BasePlugin {
|
|
|
59
66
|
input: any;
|
|
60
67
|
metadata: any;
|
|
61
68
|
};
|
|
62
|
-
extractOutput: (result: any) => any;
|
|
63
|
-
|
|
64
|
-
|
|
69
|
+
extractOutput: (result: any, endEvent?: any) => any;
|
|
70
|
+
extractMetadata?: (result: any, endEvent?: any) => any;
|
|
71
|
+
extractMetrics: (result: any, startTime?: number, endEvent?: any) => Record<string, number>;
|
|
72
|
+
aggregateChunks?: (chunks: any[], result?: any, endEvent?: any) => {
|
|
65
73
|
output: any;
|
|
66
74
|
metrics: Record<string, number>;
|
|
75
|
+
metadata?: any;
|
|
67
76
|
};
|
|
68
77
|
}): void;
|
|
69
78
|
/**
|
|
@@ -122,17 +131,6 @@ declare function parseChannelName(channelName: string): {
|
|
|
122
131
|
*/
|
|
123
132
|
declare function isValidChannelName(channelName: string): boolean;
|
|
124
133
|
|
|
125
|
-
/**
|
|
126
|
-
* Standard event types for diagnostics_channel-based instrumentation.
|
|
127
|
-
*
|
|
128
|
-
* These types follow the TracingChannel pattern from Node.js.
|
|
129
|
-
* For async functions (tracePromise):
|
|
130
|
-
* - start: Called before the synchronous portion executes
|
|
131
|
-
* - end: Called after the synchronous portion completes (promise returned)
|
|
132
|
-
* - asyncStart: Called when the promise begins to settle
|
|
133
|
-
* - asyncEnd: Called when the promise finishes settling (before user code continues)
|
|
134
|
-
* - error: Called if the function throws or the promise rejects
|
|
135
|
-
*/
|
|
136
134
|
/**
|
|
137
135
|
* Base context object shared across all events in a trace.
|
|
138
136
|
*/
|
|
@@ -186,10 +184,6 @@ interface ErrorEvent extends BaseContext {
|
|
|
186
184
|
*/
|
|
187
185
|
arguments?: unknown[];
|
|
188
186
|
}
|
|
189
|
-
/**
|
|
190
|
-
* Event emitted when a promise begins to settle.
|
|
191
|
-
* This fires after the synchronous portion and when the async continuation starts.
|
|
192
|
-
*/
|
|
193
187
|
interface AsyncStartEvent<TInput = unknown> extends StartEvent<TInput> {
|
|
194
188
|
}
|
|
195
189
|
/**
|