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.
Files changed (44) hide show
  1. package/README.md +52 -67
  2. package/dev/dist/index.d.mts +53 -9
  3. package/dev/dist/index.d.ts +53 -9
  4. package/dev/dist/index.js +1839 -1298
  5. package/dev/dist/index.mjs +1503 -962
  6. package/dist/auto-instrumentations/bundler/esbuild.cjs +270 -23
  7. package/dist/auto-instrumentations/bundler/esbuild.mjs +2 -2
  8. package/dist/auto-instrumentations/bundler/rollup.cjs +270 -23
  9. package/dist/auto-instrumentations/bundler/rollup.mjs +2 -2
  10. package/dist/auto-instrumentations/bundler/vite.cjs +270 -23
  11. package/dist/auto-instrumentations/bundler/vite.mjs +2 -2
  12. package/dist/auto-instrumentations/bundler/webpack.cjs +270 -23
  13. package/dist/auto-instrumentations/bundler/webpack.mjs +2 -2
  14. package/dist/auto-instrumentations/{chunk-OLOPGWTJ.mjs → chunk-D5ZPIUEL.mjs} +1 -1
  15. package/dist/auto-instrumentations/chunk-LVWWLUMN.mjs +535 -0
  16. package/dist/auto-instrumentations/hook.mjs +306 -23
  17. package/dist/auto-instrumentations/index.cjs +270 -23
  18. package/dist/auto-instrumentations/index.d.mts +5 -5
  19. package/dist/auto-instrumentations/index.d.ts +5 -5
  20. package/dist/auto-instrumentations/index.mjs +1 -1
  21. package/dist/auto-instrumentations/loader/esm-hook.mjs +7 -8
  22. package/dist/browser.d.mts +474 -47
  23. package/dist/browser.d.ts +474 -47
  24. package/dist/browser.js +2258 -2095
  25. package/dist/browser.mjs +2258 -2095
  26. package/dist/cli.js +1817 -1232
  27. package/dist/edge-light.d.mts +1 -1
  28. package/dist/edge-light.d.ts +1 -1
  29. package/dist/edge-light.js +2188 -2027
  30. package/dist/edge-light.mjs +2188 -2027
  31. package/dist/index.d.mts +474 -47
  32. package/dist/index.d.ts +474 -47
  33. package/dist/index.js +2576 -2415
  34. package/dist/index.mjs +2259 -2098
  35. package/dist/instrumentation/index.d.mts +16 -22
  36. package/dist/instrumentation/index.d.ts +16 -22
  37. package/dist/instrumentation/index.js +1558 -1068
  38. package/dist/instrumentation/index.mjs +1558 -1068
  39. package/dist/workerd.d.mts +1 -1
  40. package/dist/workerd.d.ts +1 -1
  41. package/dist/workerd.js +2188 -2027
  42. package/dist/workerd.mjs +2188 -2027
  43. package/package.json +6 -3
  44. package/dist/auto-instrumentations/chunk-KVX7OFPD.mjs +0 -288
@@ -1,4 +1,10 @@
1
- import { ChannelHandlers as ChannelHandlers$1 } from 'dc-browser';
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: ChannelHandlers$1): void;
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
- extractMetrics: (result: any, startTime?: number) => Record<string, number>;
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
- extractMetrics: (result: any, startTime?: number) => Record<string, number>;
64
- aggregateChunks?: (chunks: any[]) => {
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
- import { ChannelHandlers as ChannelHandlers$1 } from 'dc-browser';
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: ChannelHandlers$1): void;
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
- extractMetrics: (result: any, startTime?: number) => Record<string, number>;
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
- extractMetrics: (result: any, startTime?: number) => Record<string, number>;
64
- aggregateChunks?: (chunks: any[]) => {
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
  /**