braintrust 3.3.0 → 3.5.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 (60) hide show
  1. package/README.md +52 -67
  2. package/dev/dist/index.d.mts +98 -14
  3. package/dev/dist/index.d.ts +98 -14
  4. package/dev/dist/index.js +2751 -1463
  5. package/dev/dist/index.mjs +2383 -1095
  6. package/dist/auto-instrumentations/bundler/esbuild.cjs +476 -31
  7. package/dist/auto-instrumentations/bundler/esbuild.d.mts +2 -2
  8. package/dist/auto-instrumentations/bundler/esbuild.d.ts +2 -2
  9. package/dist/auto-instrumentations/bundler/esbuild.mjs +2 -2
  10. package/dist/auto-instrumentations/bundler/rollup.cjs +476 -31
  11. package/dist/auto-instrumentations/bundler/rollup.mjs +2 -2
  12. package/dist/auto-instrumentations/bundler/vite.cjs +476 -31
  13. package/dist/auto-instrumentations/bundler/vite.d.mts +2 -2
  14. package/dist/auto-instrumentations/bundler/vite.d.ts +2 -2
  15. package/dist/auto-instrumentations/bundler/vite.mjs +2 -2
  16. package/dist/auto-instrumentations/bundler/webpack.cjs +476 -31
  17. package/dist/auto-instrumentations/bundler/webpack.d.mts +2 -2
  18. package/dist/auto-instrumentations/bundler/webpack.d.ts +2 -2
  19. package/dist/auto-instrumentations/bundler/webpack.mjs +2 -2
  20. package/dist/auto-instrumentations/chunk-DQTPSXJB.mjs +733 -0
  21. package/dist/auto-instrumentations/chunk-EVUKFMHG.mjs +41 -0
  22. package/dist/auto-instrumentations/{chunk-OLOPGWTJ.mjs → chunk-F3TJZ3Z2.mjs} +1 -1
  23. package/dist/auto-instrumentations/chunk-VLEJ5AEK.mjs +41 -0
  24. package/dist/auto-instrumentations/hook.mjs +540 -37
  25. package/dist/auto-instrumentations/index.cjs +476 -31
  26. package/dist/auto-instrumentations/index.d.mts +5 -5
  27. package/dist/auto-instrumentations/index.d.ts +5 -5
  28. package/dist/auto-instrumentations/index.mjs +1 -1
  29. package/dist/auto-instrumentations/loader/cjs-patch.cjs +32 -10
  30. package/dist/auto-instrumentations/loader/cjs-patch.mjs +10 -5
  31. package/dist/auto-instrumentations/loader/esm-hook.mjs +11 -12
  32. package/dist/auto-instrumentations/loader/get-package-version.cjs +28 -8
  33. package/dist/auto-instrumentations/loader/get-package-version.d.mts +2 -1
  34. package/dist/auto-instrumentations/loader/get-package-version.d.ts +2 -1
  35. package/dist/auto-instrumentations/loader/get-package-version.mjs +3 -1
  36. package/dist/browser.d.mts +806 -306
  37. package/dist/browser.d.ts +806 -306
  38. package/dist/browser.js +3235 -2317
  39. package/dist/browser.mjs +3235 -2317
  40. package/dist/cli.js +2672 -1347
  41. package/dist/edge-light.d.mts +1 -1
  42. package/dist/edge-light.d.ts +1 -1
  43. package/dist/edge-light.js +3035 -2087
  44. package/dist/edge-light.mjs +3035 -2087
  45. package/dist/index.d.mts +806 -306
  46. package/dist/index.d.ts +806 -306
  47. package/dist/index.js +3570 -2654
  48. package/dist/index.mjs +3235 -2319
  49. package/dist/instrumentation/index.d.mts +16 -22
  50. package/dist/instrumentation/index.d.ts +16 -22
  51. package/dist/instrumentation/index.js +2241 -1077
  52. package/dist/instrumentation/index.mjs +2241 -1077
  53. package/dist/workerd.d.mts +1 -1
  54. package/dist/workerd.d.ts +1 -1
  55. package/dist/workerd.js +3035 -2087
  56. package/dist/workerd.mjs +3035 -2087
  57. package/package.json +26 -7
  58. package/dist/auto-instrumentations/chunk-KVX7OFPD.mjs +0 -288
  59. package/dist/auto-instrumentations/chunk-XDBPUTVE.mjs +0 -22
  60. package/dist/auto-instrumentations/chunk-ZEC7BCL4.mjs +0 -22
@@ -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
  /**