@ai-sdk/otel 1.0.0-canary.98 → 1.0.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/CHANGELOG.md CHANGED
@@ -1,5 +1,318 @@
1
1
  # @ai-sdk/otel
2
2
 
3
+ ## 1.0.0
4
+
5
+ ### Major Changes
6
+
7
+ - 6542d93: feat(ai): change naming nomenclature for `*TelemetryIntegration` to `*Telemetry`
8
+ - cf93359: feat(ai): remove/refactor event data sent via callbacks
9
+ - 8284dfa: feat(otel): rename OpenTelemetry to LegacyOpenTelemetry
10
+ - ef992f8: Remove CommonJS exports from all packages. All packages are now ESM-only (`"type": "module"`). Consumers using `require()` must switch to ESM `import` syntax.
11
+ - 116c89f: feat(ai): remove telemetry data from the user-facing event data
12
+ - b3c9f6a: feat(ai): create new opentelemetry package (@ai-sdk/otel)
13
+
14
+ ### Patch Changes
15
+
16
+ - b94d22f: Sanitize OpenTelemetry span array attributes so they no longer emit invalid OTLP values (arrays containing `undefined`/`null`/objects, or arrays mixing primitive types). Such values previously failed telemetry ingestion with `deserializing message invalid value: map, expected map with a single key` and flooded function logs with errors.
17
+ - 19736ee: feat(ai): rename onStepFinish to onStepEnd
18
+ - 4757690: feat(ai): rename onObjectStepFinish to onObjectStepEnd
19
+ - 382d53b: refactoring: rename context to runtimeContext
20
+ - 7bf7d7f: feat(ai): enable:true for telemetry by default
21
+ - c025d60: feat(otel): add option for custom span attributes
22
+ - 1db29c8: feat(ai): break `CallSettings` apart into `LanguageModelCallOptions` and `RequestOptions`
23
+ - eea8d98: refactoring: rename tool execution events
24
+ - 5d0f18e: feat(ai): move opentelemetry to new package
25
+ - 1582efa: chore(ai): remove the metadata field from the telemetry settings
26
+ - 98627e5: feat(ai): remove onChunk event from telemetry
27
+ - 9f0e36c: trigger release for all packages after provenance setup
28
+ - 1e200eb: fix(otel): ensure nested context object creates separate attribute
29
+ - 29d8cf4: feat(ai): rename the core-event types
30
+ - 18651f6: feat(otel): add opt-in options for supplemental AI SDK attributes on OpenTelemetry spans
31
+ - e4182bd: chore: rm export of OutputInterface
32
+ - 1043274: feat(ai): add a ModelCall start/end event
33
+ - 476e1ca: feat(ai): remove telemetry dependency on onChunk callback
34
+ - 7fc6bd6: Raise minimum supported Node.js version to 22. Supported versions: 22, 24, and 26.
35
+ - 594029e: feat(ai): wrap the model call in telemetry context
36
+ - eaf849f: Rename rerank telemetry finish callback to `onRerankEnd`.
37
+ - 0c4c275: trigger initial canary release
38
+ - fc15550: feat(otel): add the genAI semantic otel integration
39
+ - 9bd6512: feat(provider): change file part data property to be tagged with a type and remove the image part type
40
+ - 258c093: chore: ensure consistent import handling and avoid import duplicates or cycles
41
+ - 8565dcb: fix: rename onEmbedFinish to onEmbedEnd
42
+ - 152c67c: feat(otel): add a step level span
43
+ - e1bfb9c: feat(ai): remove unnecessary data from events
44
+ - 334ae5d: Update step performance metrics with explicit effective, input, output, and total token throughput fields.
45
+ - b8396f0: trigger initial beta release
46
+ - d5cac7c: feat(otel): emit performance metrics via gen ai semantics
47
+ - c3d4019: chore(ai): rename 'TelemetrySettings' to 'TelemetryOptions'
48
+ - e92fc45: feat(ai): introduce onAbort hook to close telemetry spans
49
+ - 083947b: feat(ai): separate toolsContext from context
50
+ - 64de016: feat(otel): rename GenAIOpenTelemetry to OpenTelemetry
51
+ - 90e2d8a: chore: fix unused vars not being flagged by our lint tooling
52
+
53
+ ## 1.0.0-beta.133
54
+
55
+ ### Patch Changes
56
+
57
+ - ai@7.0.0-beta.187
58
+
59
+ ## 1.0.0-beta.132
60
+
61
+ ### Patch Changes
62
+
63
+ - ai@7.0.0-beta.186
64
+
65
+ ## 1.0.0-beta.131
66
+
67
+ ### Patch Changes
68
+
69
+ - Updated dependencies [75763b0]
70
+ - ai@7.0.0-beta.185
71
+
72
+ ## 1.0.0-beta.130
73
+
74
+ ### Patch Changes
75
+
76
+ - b94d22f: Sanitize OpenTelemetry span array attributes so they no longer emit invalid OTLP values (arrays containing `undefined`/`null`/objects, or arrays mixing primitive types). Such values previously failed telemetry ingestion with `deserializing message invalid value: map, expected map with a single key` and flooded function logs with errors.
77
+ - d5cac7c: feat(otel): emit performance metrics via gen ai semantics
78
+ - Updated dependencies [0416e3e]
79
+ - @ai-sdk/provider@4.0.0-beta.20
80
+ - ai@7.0.0-beta.184
81
+
82
+ ## 1.0.0-beta.129
83
+
84
+ ### Patch Changes
85
+
86
+ - ai@7.0.0-beta.183
87
+
88
+ ## 1.0.0-beta.128
89
+
90
+ ### Patch Changes
91
+
92
+ - Updated dependencies [cc6ab90]
93
+ - ai@7.0.0-beta.182
94
+
95
+ ## 1.0.0-beta.127
96
+
97
+ ### Patch Changes
98
+
99
+ - Updated dependencies [6a2caf9]
100
+ - ai@7.0.0-beta.181
101
+
102
+ ## 1.0.0-beta.126
103
+
104
+ ### Patch Changes
105
+
106
+ - Updated dependencies [81a284b]
107
+ - ai@7.0.0-beta.180
108
+
109
+ ## 1.0.0-beta.125
110
+
111
+ ### Patch Changes
112
+
113
+ - ai@7.0.0-beta.179
114
+
115
+ ## 1.0.0-beta.124
116
+
117
+ ### Patch Changes
118
+
119
+ - Updated dependencies [b097c52]
120
+ - ai@7.0.0-beta.178
121
+
122
+ ## 1.0.0-beta.123
123
+
124
+ ### Patch Changes
125
+
126
+ - b8396f0: trigger initial beta release
127
+ - Updated dependencies [b8396f0]
128
+ - @ai-sdk/provider@4.0.0-beta.19
129
+ - ai@7.0.0-beta.177
130
+
131
+ ## 1.0.0-canary.122
132
+
133
+ ### Patch Changes
134
+
135
+ - ai@7.0.0-canary.176
136
+
137
+ ## 1.0.0-canary.121
138
+
139
+ ### Patch Changes
140
+
141
+ - Updated dependencies [6ec57f5]
142
+ - ai@7.0.0-canary.175
143
+
144
+ ## 1.0.0-canary.120
145
+
146
+ ### Patch Changes
147
+
148
+ - ai@7.0.0-canary.174
149
+
150
+ ## 1.0.0-canary.119
151
+
152
+ ### Patch Changes
153
+
154
+ - ai@7.0.0-canary.173
155
+
156
+ ## 1.0.0-canary.118
157
+
158
+ ### Patch Changes
159
+
160
+ - Updated dependencies [25a64f8]
161
+ - Updated dependencies [375fdd7]
162
+ - Updated dependencies [f18b08f]
163
+ - Updated dependencies [b4507d5]
164
+ - ai@7.0.0-canary.172
165
+
166
+ ## 1.0.0-canary.117
167
+
168
+ ### Patch Changes
169
+
170
+ - Updated dependencies [89ad56f]
171
+ - Updated dependencies [f9a496f]
172
+ - Updated dependencies [3295831]
173
+ - ai@7.0.0-canary.171
174
+
175
+ ## 1.0.0-canary.116
176
+
177
+ ### Patch Changes
178
+
179
+ - Updated dependencies [bae5e2b]
180
+ - Updated dependencies [69d7128]
181
+ - ai@7.0.0-canary.170
182
+
183
+ ## 1.0.0-canary.115
184
+
185
+ ### Patch Changes
186
+
187
+ - Updated dependencies [a5018ab]
188
+ - Updated dependencies [21d3d60]
189
+ - Updated dependencies [426dbbb]
190
+ - Updated dependencies [7fd3360]
191
+ - ai@7.0.0-canary.169
192
+
193
+ ## 1.0.0-canary.114
194
+
195
+ ### Patch Changes
196
+
197
+ - Updated dependencies [1e4b350]
198
+ - ai@7.0.0-canary.168
199
+
200
+ ## 1.0.0-canary.113
201
+
202
+ ### Patch Changes
203
+
204
+ - 4757690: feat(ai): rename onObjectStepFinish to onObjectStepEnd
205
+ - Updated dependencies [4757690]
206
+ - Updated dependencies [eeefc3f]
207
+ - Updated dependencies [b79b6a8]
208
+ - ai@7.0.0-canary.167
209
+
210
+ ## 1.0.0-canary.112
211
+
212
+ ### Patch Changes
213
+
214
+ - 19736ee: feat(ai): rename onStepFinish to onStepEnd
215
+ - e4182bd: chore: rm export of OutputInterface
216
+ - Updated dependencies [19736ee]
217
+ - Updated dependencies [d66ae02]
218
+ - Updated dependencies [e4182bd]
219
+ - ai@7.0.0-canary.166
220
+
221
+ ## 1.0.0-canary.111
222
+
223
+ ### Patch Changes
224
+
225
+ - Updated dependencies [ce769dd]
226
+ - @ai-sdk/provider@4.0.0-canary.18
227
+ - ai@7.0.0-canary.165
228
+
229
+ ## 1.0.0-canary.110
230
+
231
+ ### Patch Changes
232
+
233
+ - ai@7.0.0-canary.164
234
+
235
+ ## 1.0.0-canary.109
236
+
237
+ ### Patch Changes
238
+
239
+ - Updated dependencies [ee798eb]
240
+ - Updated dependencies [c907622]
241
+ - ai@7.0.0-canary.163
242
+
243
+ ## 1.0.0-canary.108
244
+
245
+ ### Patch Changes
246
+
247
+ - ai@7.0.0-canary.162
248
+
249
+ ## 1.0.0-canary.107
250
+
251
+ ### Patch Changes
252
+
253
+ - ai@7.0.0-canary.161
254
+
255
+ ## 1.0.0-canary.106
256
+
257
+ ### Patch Changes
258
+
259
+ - ai@7.0.0-canary.160
260
+
261
+ ## 1.0.0-canary.105
262
+
263
+ ### Patch Changes
264
+
265
+ - Updated dependencies [b5092f5]
266
+ - ai@7.0.0-canary.159
267
+
268
+ ## 1.0.0-canary.104
269
+
270
+ ### Patch Changes
271
+
272
+ - Updated dependencies [bcce2dd]
273
+ - ai@7.0.0-canary.158
274
+
275
+ ## 1.0.0-canary.103
276
+
277
+ ### Patch Changes
278
+
279
+ - ai@7.0.0-canary.157
280
+
281
+ ## 1.0.0-canary.102
282
+
283
+ ### Patch Changes
284
+
285
+ - 1e200eb: fix(otel): ensure nested context object creates separate attribute
286
+ - e92fc45: feat(ai): introduce onAbort hook to close telemetry spans
287
+ - Updated dependencies [023550e]
288
+ - Updated dependencies [e92fc45]
289
+ - ai@7.0.0-canary.156
290
+
291
+ ## 1.0.0-canary.101
292
+
293
+ ### Patch Changes
294
+
295
+ - Updated dependencies [e67d80e]
296
+ - Updated dependencies [6cca112]
297
+ - Updated dependencies [82fc0ab]
298
+ - Updated dependencies [76fd58c]
299
+ - ai@7.0.0-canary.155
300
+
301
+ ## 1.0.0-canary.100
302
+
303
+ ### Patch Changes
304
+
305
+ - 594029e: feat(ai): wrap the model call in telemetry context
306
+ - Updated dependencies [594029e]
307
+ - ai@7.0.0-canary.154
308
+
309
+ ## 1.0.0-canary.99
310
+
311
+ ### Patch Changes
312
+
313
+ - Updated dependencies [6c93e36]
314
+ - ai@7.0.0-canary.153
315
+
3
316
  ## 1.0.0-canary.98
4
317
 
5
318
  ### Patch Changes
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Telemetry, InferTelemetryEvent, GenerateTextStartEvent, GenerateObjectStartEvent, EmbedStartEvent, RerankStartEvent, GenerateObjectStepStartEvent, GenerateObjectStepEndEvent, GenerateTextStepStartEvent, ToolSet, LanguageModelCallStartEvent, LanguageModelCallEndEvent, ToolExecutionStartEvent, ToolExecutionEndEvent, GenerateTextStepEndEvent, GenerateTextEndEvent, GenerateObjectEndEvent, EmbedEndEvent, RerankEndEvent, EmbeddingModelCallStartEvent, EmbeddingModelCallEndEvent, RerankingModelCallStartEvent, RerankingModelCallEndEvent, OutputInterface } from 'ai';
1
+ import { Telemetry, InferTelemetryEvent, GenerateTextStartEvent, GenerateObjectStartEvent, EmbedStartEvent, RerankStartEvent, GenerateObjectStepStartEvent, GenerateObjectStepEndEvent, GenerateTextStepStartEvent, ToolSet, LanguageModelCallStartEvent, LanguageModelCallEndEvent, ToolExecutionStartEvent, ToolExecutionEndEvent, GenerateTextStepEndEvent, GenerateTextEndEvent, GenerateObjectEndEvent, EmbedEndEvent, RerankEndEvent, EmbeddingModelCallStartEvent, EmbeddingModelCallEndEvent, RerankingModelCallStartEvent, RerankingModelCallEndEvent, GenerateTextAbortEvent, Output } from 'ai';
2
2
  import { Attributes, Tracer } from '@opentelemetry/api';
3
3
  import { LanguageModelV4Prompt } from '@ai-sdk/provider';
4
4
  import { Context } from '@ai-sdk/provider-utils';
@@ -71,19 +71,29 @@ declare class OpenTelemetry implements Telemetry {
71
71
  toolCallId: string;
72
72
  execute: () => PromiseLike<T>;
73
73
  }): PromiseLike<T>;
74
+ /**
75
+ * Runs the provider `doGenerate`/`doStream` call with the active model-call
76
+ * context.
77
+ */
78
+ executeLanguageModelCall<T>({ callId, execute, }: {
79
+ callId: string;
80
+ execute: () => PromiseLike<T>;
81
+ }): PromiseLike<T>;
74
82
  onStart(event: InferTelemetryEvent<GenerateTextStartEvent> | InferTelemetryEvent<GenerateObjectStartEvent> | InferTelemetryEvent<EmbedStartEvent> | InferTelemetryEvent<RerankStartEvent>): void;
75
83
  private onGenerateStart;
76
84
  private onObjectOperationStart;
77
85
  /** @deprecated */
78
86
  onObjectStepStart(event: GenerateObjectStepStartEvent): void;
79
87
  /** @deprecated */
80
- onObjectStepFinish(event: GenerateObjectStepEndEvent): void;
88
+ onObjectStepEnd(event: GenerateObjectStepEndEvent): void;
81
89
  private onEmbedOperationStart;
82
90
  onStepStart(event: OtelStepStartEvent$1): void;
83
91
  onLanguageModelCallStart(event: LanguageModelCallStartEvent): void;
84
92
  onLanguageModelCallEnd(event: LanguageModelCallEndEvent<ToolSet>): void;
85
93
  onToolExecutionStart(event: ToolExecutionStartEvent<ToolSet>): void;
86
94
  onToolExecutionEnd(event: ToolExecutionEndEvent<ToolSet>): void;
95
+ onStepEnd(event: GenerateTextStepEndEvent<ToolSet>): void;
96
+ /** @deprecated Use `onStepEnd` instead. */
87
97
  onStepFinish(event: GenerateTextStepEndEvent<ToolSet>): void;
88
98
  onEnd(event: GenerateTextEndEvent<ToolSet> | GenerateObjectEndEvent<unknown> | EmbedEndEvent | RerankEndEvent): void;
89
99
  private onGenerateEnd;
@@ -95,10 +105,11 @@ declare class OpenTelemetry implements Telemetry {
95
105
  private onRerankOperationEnd;
96
106
  onRerankStart(event: RerankingModelCallStartEvent): void;
97
107
  onRerankEnd(event: RerankingModelCallEndEvent): void;
108
+ onAbort(event: GenerateTextAbortEvent<ToolSet>): void;
98
109
  onError(error: unknown): void;
99
110
  }
100
111
 
101
- interface OtelStepStartEvent<TOOLS extends ToolSet = ToolSet, RUNTIME_CONTEXT extends Context = Context, OUTPUT extends OutputInterface = OutputInterface> extends GenerateTextStepStartEvent<TOOLS, RUNTIME_CONTEXT, OUTPUT> {
112
+ interface OtelStepStartEvent<TOOLS extends ToolSet = ToolSet, RUNTIME_CONTEXT extends Context = Context, OUTPUT extends Output.Output = Output.Output> extends GenerateTextStepStartEvent<TOOLS, RUNTIME_CONTEXT, OUTPUT> {
102
113
  readonly promptMessages?: LanguageModelV4Prompt;
103
114
  readonly stepTools?: ReadonlyArray<Record<string, unknown>>;
104
115
  readonly stepToolChoice?: unknown;
@@ -119,17 +130,27 @@ declare class LegacyOpenTelemetry implements Telemetry {
119
130
  toolCallId: string;
120
131
  execute: () => PromiseLike<T>;
121
132
  }): PromiseLike<T>;
133
+ /**
134
+ * Runs the provider `doGenerate`/`doStream` call with the active legacy
135
+ * model-call context.
136
+ */
137
+ executeLanguageModelCall<T>({ callId, execute, }: {
138
+ callId: string;
139
+ execute: () => PromiseLike<T>;
140
+ }): PromiseLike<T>;
122
141
  onStart(event: InferTelemetryEvent<GenerateTextStartEvent> | InferTelemetryEvent<GenerateObjectStartEvent> | InferTelemetryEvent<EmbedStartEvent> | InferTelemetryEvent<RerankStartEvent>): void;
123
142
  private onGenerateStart;
124
143
  private onObjectOperationStart;
125
144
  /** @deprecated */
126
145
  onObjectStepStart(event: GenerateObjectStepStartEvent): void;
127
146
  /** @deprecated */
128
- onObjectStepFinish(event: GenerateObjectStepEndEvent): void;
147
+ onObjectStepEnd(event: GenerateObjectStepEndEvent): void;
129
148
  private onEmbedOperationStart;
130
149
  onStepStart(event: OtelStepStartEvent): void;
131
150
  onToolExecutionStart(event: ToolExecutionStartEvent<ToolSet>): void;
132
151
  onToolExecutionEnd(event: ToolExecutionEndEvent<ToolSet>): void;
152
+ onStepEnd(event: GenerateTextStepEndEvent<ToolSet>): void;
153
+ /** @deprecated Use `onStepEnd` instead. */
133
154
  onStepFinish(event: GenerateTextStepEndEvent<ToolSet>): void;
134
155
  onEnd(event: GenerateTextEndEvent<ToolSet> | GenerateObjectEndEvent<unknown> | EmbedEndEvent | RerankEndEvent): void;
135
156
  private onGenerateEnd;
@@ -141,6 +162,7 @@ declare class LegacyOpenTelemetry implements Telemetry {
141
162
  private onRerankOperationEnd;
142
163
  onRerankStart(event: RerankingModelCallStartEvent): void;
143
164
  onRerankEnd(event: RerankingModelCallEndEvent): void;
165
+ onAbort(event: GenerateTextAbortEvent<ToolSet>): void;
144
166
  onError(error: unknown): void;
145
167
  }
146
168