@brizz/sdk 0.1.36 → 0.1.39

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 (102) hide show
  1. package/README.md +28 -125
  2. package/dist/{chunk-6OGRVH77.js → chunk-JBNWC4YN.js} +1 -1
  3. package/dist/{chunk-PXIW2K27.cjs → chunk-NMDPWJMU.cjs} +1 -1
  4. package/dist/index.cjs +2264 -15
  5. package/dist/index.js +2299 -50
  6. package/dist/{mcp-HAUJ3G4Q.cjs → mcp-3N3DAQGD.cjs} +2 -2
  7. package/dist/{mcp-ZCRMQV5L.js → mcp-EWOGAW4J.js} +1 -1
  8. package/dist/types/cjs/eve.d.ts +2 -0
  9. package/dist/types/cjs/google-genai.d.ts +1 -0
  10. package/dist/types/cjs/index.d.ts +15 -0
  11. package/dist/types/cjs/internal/config.d.ts +19 -0
  12. package/dist/types/cjs/internal/constants.d.ts +3 -0
  13. package/dist/types/cjs/internal/dsn.d.ts +13 -0
  14. package/dist/types/cjs/internal/instrumentation/auto-init.d.ts +8 -0
  15. package/dist/types/cjs/internal/instrumentation/google-genai.d.ts +13 -0
  16. package/dist/types/cjs/internal/instrumentation/index.d.ts +2 -0
  17. package/dist/types/cjs/internal/instrumentation/mcp/index.d.ts +2 -0
  18. package/dist/types/cjs/internal/instrumentation/mcp/instrumentation.d.ts +15 -0
  19. package/dist/types/cjs/internal/instrumentation/mcp/patches/attributes.d.ts +9 -0
  20. package/dist/types/cjs/internal/instrumentation/mcp/patches/protocol.d.ts +2 -0
  21. package/dist/types/cjs/internal/instrumentation/mcp/schemas.d.ts +2 -0
  22. package/dist/types/cjs/internal/instrumentation/mcp/semantic-conventions.d.ts +37 -0
  23. package/dist/types/cjs/internal/instrumentation/mcp/session.d.ts +6 -0
  24. package/dist/types/cjs/internal/instrumentation/mcp/types.d.ts +47 -0
  25. package/dist/types/cjs/internal/instrumentation/mcp/version.d.ts +2 -0
  26. package/dist/types/cjs/internal/instrumentation/registry.d.ts +29 -0
  27. package/dist/types/cjs/internal/instrumentation/vercel-ai/interrupt.d.ts +11 -0
  28. package/dist/types/cjs/internal/log/index.d.ts +1 -0
  29. package/dist/types/cjs/internal/log/logging.d.ts +21 -0
  30. package/dist/types/cjs/internal/log/processors/log-processor.d.ts +16 -0
  31. package/dist/types/cjs/internal/logger.d.ts +23 -0
  32. package/dist/types/cjs/internal/masking/index.d.ts +3 -0
  33. package/dist/types/cjs/internal/masking/patterns.d.ts +2 -0
  34. package/dist/types/cjs/internal/masking/types.d.ts +32 -0
  35. package/dist/types/cjs/internal/masking/utils.d.ts +5 -0
  36. package/dist/types/cjs/internal/metric/index.d.ts +1 -0
  37. package/dist/types/cjs/internal/metric/metrics.d.ts +17 -0
  38. package/dist/types/cjs/internal/sdk.d.ts +42 -0
  39. package/dist/types/cjs/internal/semantic-conventions.d.ts +54 -0
  40. package/dist/types/cjs/internal/trace/exporters/eve-trace-exporter.d.ts +18 -0
  41. package/dist/types/cjs/internal/trace/exporters/span-exporter.d.ts +12 -0
  42. package/dist/types/cjs/internal/trace/index.d.ts +4 -0
  43. package/dist/types/cjs/internal/trace/processors/eve-session-processor.d.ts +2 -0
  44. package/dist/types/cjs/internal/trace/processors/span-processor.d.ts +18 -0
  45. package/dist/types/cjs/internal/trace/session.d.ts +135 -0
  46. package/dist/types/cjs/internal/trace/tracing.d.ts +17 -0
  47. package/dist/types/cjs/internal/version.d.ts +1 -0
  48. package/dist/types/cjs/package.json +3 -0
  49. package/dist/types/esm/eve.d.ts +2 -0
  50. package/dist/types/esm/google-genai.d.ts +1 -0
  51. package/dist/types/esm/index.d.ts +15 -0
  52. package/dist/types/esm/internal/config.d.ts +19 -0
  53. package/dist/types/esm/internal/constants.d.ts +3 -0
  54. package/dist/types/esm/internal/dsn.d.ts +13 -0
  55. package/dist/types/esm/internal/instrumentation/auto-init.d.ts +8 -0
  56. package/dist/types/esm/internal/instrumentation/google-genai.d.ts +13 -0
  57. package/dist/types/esm/internal/instrumentation/index.d.ts +2 -0
  58. package/dist/types/esm/internal/instrumentation/mcp/index.d.ts +2 -0
  59. package/dist/types/esm/internal/instrumentation/mcp/instrumentation.d.ts +15 -0
  60. package/dist/types/esm/internal/instrumentation/mcp/patches/attributes.d.ts +9 -0
  61. package/dist/types/esm/internal/instrumentation/mcp/patches/protocol.d.ts +2 -0
  62. package/dist/types/esm/internal/instrumentation/mcp/schemas.d.ts +2 -0
  63. package/dist/types/esm/internal/instrumentation/mcp/semantic-conventions.d.ts +37 -0
  64. package/dist/types/esm/internal/instrumentation/mcp/session.d.ts +6 -0
  65. package/dist/types/esm/internal/instrumentation/mcp/types.d.ts +47 -0
  66. package/dist/types/esm/internal/instrumentation/mcp/version.d.ts +2 -0
  67. package/dist/types/esm/internal/instrumentation/registry.d.ts +29 -0
  68. package/dist/types/esm/internal/instrumentation/vercel-ai/interrupt.d.ts +11 -0
  69. package/dist/types/esm/internal/log/index.d.ts +1 -0
  70. package/dist/types/esm/internal/log/logging.d.ts +21 -0
  71. package/dist/types/esm/internal/log/processors/log-processor.d.ts +16 -0
  72. package/dist/types/esm/internal/logger.d.ts +23 -0
  73. package/dist/types/esm/internal/masking/index.d.ts +3 -0
  74. package/dist/types/esm/internal/masking/patterns.d.ts +2 -0
  75. package/dist/types/esm/internal/masking/types.d.ts +32 -0
  76. package/dist/types/esm/internal/masking/utils.d.ts +5 -0
  77. package/dist/types/esm/internal/metric/index.d.ts +1 -0
  78. package/dist/types/esm/internal/metric/metrics.d.ts +17 -0
  79. package/dist/types/esm/internal/sdk.d.ts +42 -0
  80. package/dist/types/esm/internal/semantic-conventions.d.ts +54 -0
  81. package/dist/types/esm/internal/trace/exporters/eve-trace-exporter.d.ts +18 -0
  82. package/dist/types/esm/internal/trace/exporters/span-exporter.d.ts +12 -0
  83. package/dist/types/esm/internal/trace/index.d.ts +4 -0
  84. package/dist/types/esm/internal/trace/processors/eve-session-processor.d.ts +2 -0
  85. package/dist/types/esm/internal/trace/processors/span-processor.d.ts +18 -0
  86. package/dist/types/esm/internal/trace/session.d.ts +135 -0
  87. package/dist/types/esm/internal/trace/tracing.d.ts +17 -0
  88. package/dist/types/esm/internal/version.d.ts +1 -0
  89. package/package.json +58 -58
  90. package/dist/chunk-CQDWK43A.cjs +0 -2368
  91. package/dist/chunk-YNCBWOHM.js +0 -2368
  92. package/dist/eve.d.cts +0 -19
  93. package/dist/eve.d.ts +0 -19
  94. package/dist/google-genai.d.cts +0 -7
  95. package/dist/google-genai.d.ts +0 -7
  96. package/dist/index.d.cts +0 -291
  97. package/dist/index.d.ts +0 -291
  98. package/dist/loader.mjs +0 -85
  99. package/dist/preload.cjs +0 -119
  100. package/dist/preload.d.cts +0 -2
  101. package/dist/preload.d.ts +0 -2
  102. package/dist/preload.js +0 -119
package/README.md CHANGED
@@ -4,16 +4,14 @@
4
4
  [![License: Apache-2.0](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
5
5
  [![TypeScript](https://img.shields.io/badge/TypeScript-Ready-blue.svg)](https://www.typescriptlang.org/)
6
6
 
7
- OpenTelemetry-based observability SDK for AI applications. Automatically instruments popular AI
8
- libraries including OpenAI, Anthropic, Vercel AI SDK, and more.
7
+ OpenTelemetry-based observability SDK for AI applications. Traces popular AI libraries including
8
+ OpenAI, Anthropic, Vercel AI SDK, and more.
9
9
 
10
10
  ## Table of Contents
11
11
 
12
12
  - [Features](#features)
13
13
  - [Installation](#installation)
14
14
  - [Quick Start](#quick-start)
15
- - [CommonJS Projects](#commonjs-projects)
16
- - [ESM Projects](#esm-projects)
17
15
  - [Module System Support](#module-system-support)
18
16
  - [Supported Libraries](#supported-libraries)
19
17
  - [PII Masking](#pii-masking)
@@ -33,12 +31,11 @@ libraries including OpenAI, Anthropic, Vercel AI SDK, and more.
33
31
 
34
32
  ## Features
35
33
 
36
- - 🔍 **Automatic Instrumentation** - Zero-code setup for popular AI libraries
34
+ - 🔍 **One-Call Setup** - Pass your AI libraries to `Brizz.initialize()` and they're traced
37
35
  - 📊 **OpenTelemetry Native** - Standards-compliant tracing, metrics, and logs
38
36
  - 🛡️ **PII Masking** - Optional masking for sensitive data
39
37
  - 🔄 **Session Tracking** - Group related operations and traces
40
- - 📦 **Dual Module Support** - Works with both ESM and CommonJS
41
- - ⚡ **Multiple Initialization Methods** - Preload, ESM loader, or manual setup
38
+ - 📦 **Runs Anywhere** - ESM, CommonJS, bundlers, and `tsx`
42
39
 
43
40
  ## Installation
44
41
 
@@ -61,133 +58,52 @@ BRIZZ_APP_NAME=my-app # Optional
61
58
  BRIZZ_LOG_LEVEL=info # Optional: debug, info, warn, error, none
62
59
  ```
63
60
 
64
- ### CommonJS Projects
65
-
66
- **Option 1: Preload Only (Zero Config)**
67
-
68
- ```bash
69
- node --require @brizz/sdk/preload your-app.js
70
- ```
71
-
72
- ```javascript
73
- // your-app.js - No SDK setup needed!
74
- const { generateText } = require('ai');
75
- const { openai } = require('@ai-sdk/openai');
76
-
77
- // Libraries are automatically instrumented
78
- generateText({
79
- model: openai('gpt-3.5-turbo'),
80
- prompt: 'Hello, world!',
81
- experimental_telemetry: { isEnabled: true },
82
- }).then((result) => console.log(result.text));
83
- ```
84
-
85
- **Option 2: Preload + Initialize (Custom Config)**
86
-
87
- ```bash
88
- node --require @brizz/sdk/preload your-app.js
89
- ```
90
-
91
- ```javascript
92
- // your-app.js - Custom configuration
93
- const { Brizz } = require('@brizz/sdk');
94
-
95
- Brizz.initialize({
96
- apiKey: 'your-api-key',
97
- appName: 'my-app',
98
- // custom config here
99
- });
100
-
101
- const { generateText } = require('ai');
102
- // ... rest of your code
103
- ```
104
-
105
- **Option 3: Manual Import + Initialize**
106
-
107
- ```javascript
108
- // Must be first import
109
- const { Brizz } = require('@brizz/sdk');
110
-
111
- Brizz.initialize({
112
- apiKey: 'your-api-key',
113
- appName: 'my-app',
114
- });
115
-
116
- // Import AI libraries after initialization
117
- const { generateText } = require('ai');
118
- const { openai } = require('@ai-sdk/openai');
119
- ```
120
-
121
- ### ESM Projects
122
-
123
- > ⚠️ **ESM Requirement**: ESM projects **must** use the `--import @brizz/sdk/loader` flag for
124
- > instrumentation to work. Manual import without the loader will not instrument AI libraries.
125
-
126
- **Loader + Initialize (Required for ESM)**
127
-
128
- ```bash
129
- node --import @brizz/sdk/loader your-app.mjs
130
- ```
61
+ Then initialize the SDK in your application, passing the libraries you want to trace:
131
62
 
132
63
  ```typescript
133
- // your-app.mjs
134
64
  import { Brizz } from '@brizz/sdk';
65
+ import OpenAI from 'openai';
135
66
 
136
- // Must initialize SDK manually in ESM
137
67
  Brizz.initialize({
138
- apiKey: 'your-api-key',
139
- appName: 'my-app',
140
- });
141
-
142
- // Import AI libraries after initialization
143
- import { generateText } from 'ai';
144
- import { openai } from '@ai-sdk/openai';
145
-
146
- const result = await generateText({
147
- model: openai('gpt-3.5-turbo'),
148
- prompt: 'Hello, world!',
149
- experimental_telemetry: { isEnabled: true },
68
+ apiKey: process.env.BRIZZ_API_KEY,
69
+ appName: 'my-ai-app',
70
+ instrumentModules: { openAI: OpenAI },
150
71
  });
151
72
  ```
152
73
 
153
- > **Important**: Initialize Brizz before importing any libraries you want to instrument. If using
154
- > `dotenv`, use `import "dotenv/config"` before importing `@brizz/sdk`.
155
-
156
- ## Module System Support
157
-
158
- ### CommonJS
74
+ Run your app the way you already do — `node app.js`, `tsx app.ts`, or your own start script.
159
75
 
160
- - **Preload**: `node --require @brizz/sdk/preload app.js` ⭐ (with optional `Brizz.initialize()`)
161
- - **Manual**: Require `@brizz/sdk` first, then `Brizz.initialize()`, then AI libraries
76
+ > **Important**: Call `Brizz.initialize()` before making any AI calls. If using `dotenv`, use
77
+ > `import "dotenv/config"` before importing `@brizz/sdk`.
162
78
 
163
- ### ESM (ES Modules)
79
+ ## Module System Support
164
80
 
165
- - **Loader**: `node --import @brizz/sdk/loader app.mjs` + `Brizz.initialize()` ⭐
166
- - **Manual**: Import `@brizz/sdk` first, then `Brizz.initialize()`, then AI libraries
81
+ The same setup works in ESM, CommonJS, bundlers, and `tsx` — import `@brizz/sdk` and call
82
+ `Brizz.initialize()`.
167
83
 
168
- For Next.js and Webpack environments that don't support automatic instrumentation, use manual
169
- instrumentation:
84
+ Bundlers that inline modules (Next.js, Webpack) may need a dynamic import so you can hand the
85
+ resolved module to `instrumentModules`:
170
86
 
171
87
  ```typescript
172
88
  // For problematic bundlers
173
- const aiModule = await import('ai');
89
+ const { default: OpenAI } = await import('openai');
174
90
 
175
91
  Brizz.initialize({
176
92
  apiKey: 'your-api-key',
177
93
  instrumentModules: {
178
- vercelAI: aiModule, // Manual instrumentation
94
+ openAI: OpenAI,
179
95
  },
180
96
  });
181
97
  ```
182
98
 
183
99
  ## Supported Libraries
184
100
 
185
- The SDK automatically instruments:
101
+ Pass the libraries you use to `instrumentModules` and the SDK traces them:
186
102
 
187
103
  - **OpenAI** - `openai` package
188
104
  - **Anthropic** - `@anthropic-ai/sdk` package
189
105
  - **Vercel AI SDK** - `ai` package (generateText, streamText, etc.)
190
- - Requires `experimental_telemetry: { isEnabled: true }` in function calls
106
+ - Captured through `experimental_telemetry: { isEnabled: true }` on each call, not `instrumentModules`
191
107
  - **LangChain** - `langchain` and `@langchain/*` packages
192
108
  - **LlamaIndex** - `llamaindex` package
193
109
  - **AWS Bedrock** - `@aws-sdk/client-bedrock-runtime`
@@ -848,26 +764,14 @@ expect(spans[0].name).toBe('openai.chat');
848
764
 
849
765
  ## Package.json Examples
850
766
 
851
- **CommonJS Projects:**
852
-
853
- ```json
854
- {
855
- "scripts": {
856
- "start": "node --require @brizz/sdk/preload src/index.js",
857
- "dev": "node --require @brizz/sdk/preload --watch src/index.js",
858
- "debug": "node --require @brizz/sdk/preload --inspect src/index.js"
859
- }
860
- }
861
- ```
862
-
863
- **ESM Projects:**
767
+ The SDK is initialized from your application code, so your scripts stay as they are:
864
768
 
865
769
  ```json
866
770
  {
867
- "type": "module",
868
771
  "scripts": {
869
- "start": "node --import @brizz/sdk/loader src/index.js",
870
- "dev": "node --import @brizz/sdk/loader --watch src/index.js"
772
+ "start": "node src/index.js",
773
+ "dev": "node --watch src/index.js",
774
+ "debug": "node --inspect src/index.js"
871
775
  }
872
776
  }
873
777
  ```
@@ -893,9 +797,8 @@ Check out the [examples](./examples/) directory for complete working examples:
893
797
 
894
798
  **Instrumentation not working**
895
799
 
896
- - Ensure SDK is initialized before importing AI libraries
897
- - For ESM, use loader + `Brizz.initialize()`
898
- - For CommonJS, use preload (with optional `Brizz.initialize()`)
800
+ - Ensure `Brizz.initialize()` runs before any AI calls
801
+ - Pass the libraries you want to trace via `instrumentModules`
899
802
  - Check that `BRIZZ_API_KEY` is set
900
803
  - For Vercel AI SDK: Add `experimental_telemetry: { isEnabled: true }` to function calls
901
804
 
@@ -909,7 +812,7 @@ Check out the [examples](./examples/) directory for complete working examples:
909
812
  Enable debug logging to troubleshoot issues:
910
813
 
911
814
  ```bash
912
- BRIZZ_LOG_LEVEL=debug node --import @brizz/sdk/preload your-app.js
815
+ BRIZZ_LOG_LEVEL=debug node your-app.js
913
816
  ```
914
817
 
915
818
  ## Contributing
@@ -1,6 +1,6 @@
1
1
  // src/internal/version.ts
2
2
  function getSDKVersion() {
3
- return "0.1.36";
3
+ return "0.1.39";
4
4
  }
5
5
 
6
6
  export {
@@ -1,6 +1,6 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});// src/internal/version.ts
2
2
  function getSDKVersion() {
3
- return "0.1.36";
3
+ return "0.1.39";
4
4
  }
5
5
 
6
6