@ai-sdk/otel 0.0.0-bf6e4b15-20260402200305
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 +100 -0
- package/LICENSE +13 -0
- package/dist/index.d.mts +52 -0
- package/dist/index.d.ts +52 -0
- package/dist/index.js +868 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +845 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +69 -0
- package/src/assemble-operation-name.ts +21 -0
- package/src/get-base-telemetry-attributes.ts +44 -0
- package/src/get-tracer.ts +20 -0
- package/src/index.ts +1 -0
- package/src/mock-tracer.ts +156 -0
- package/src/noop-tracer.ts +69 -0
- package/src/open-telemetry-integration.ts +1099 -0
- package/src/record-span.ts +75 -0
- package/src/select-telemetry-attributes.ts +78 -0
- package/src/stringify-for-telemetry.ts +33 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
# @ai-sdk/otel
|
|
2
|
+
|
|
3
|
+
## 0.0.0-bf6e4b15-20260402200305
|
|
4
|
+
|
|
5
|
+
### Major Changes
|
|
6
|
+
|
|
7
|
+
- b3c9f6a: feat(ai): create new opentelemetry package (@ai-sdk/otel)
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- 5d0f18e: feat(ai): move opentelemetry to new package
|
|
12
|
+
- Updated dependencies [b56301c]
|
|
13
|
+
- Updated dependencies [986c6fd]
|
|
14
|
+
- Updated dependencies [5ceed7d]
|
|
15
|
+
- Updated dependencies [ff9ce30]
|
|
16
|
+
- Updated dependencies [99bf941]
|
|
17
|
+
- Updated dependencies [6a3793e]
|
|
18
|
+
- Updated dependencies [31ee822]
|
|
19
|
+
- Updated dependencies [531251e]
|
|
20
|
+
- Updated dependencies [9b47dea]
|
|
21
|
+
- Updated dependencies [877bf12]
|
|
22
|
+
- Updated dependencies [5d0f18e]
|
|
23
|
+
- Updated dependencies [80d4dde]
|
|
24
|
+
- Updated dependencies [1f509d4]
|
|
25
|
+
- Updated dependencies [5c2a5a2]
|
|
26
|
+
- Updated dependencies [caf1b6f]
|
|
27
|
+
- Updated dependencies [f7d4f01]
|
|
28
|
+
- Updated dependencies [776b617]
|
|
29
|
+
- Updated dependencies [2e17091]
|
|
30
|
+
- Updated dependencies [210ed3d]
|
|
31
|
+
- Updated dependencies [a3fd75b]
|
|
32
|
+
- Updated dependencies [1fe058b]
|
|
33
|
+
- Updated dependencies [5c4d910]
|
|
34
|
+
- Updated dependencies [34fd051]
|
|
35
|
+
- Updated dependencies [3debdb7]
|
|
36
|
+
- Updated dependencies [493295c]
|
|
37
|
+
- Updated dependencies [c26ca8d]
|
|
38
|
+
- Updated dependencies [118b953]
|
|
39
|
+
- Updated dependencies [ebd4da2]
|
|
40
|
+
- Updated dependencies [bc67b4f]
|
|
41
|
+
- Updated dependencies [f0b0b20]
|
|
42
|
+
- Updated dependencies [3887c70]
|
|
43
|
+
- Updated dependencies [989d3d2]
|
|
44
|
+
- Updated dependencies [6abd098]
|
|
45
|
+
- Updated dependencies [4b46062]
|
|
46
|
+
- Updated dependencies [8359612]
|
|
47
|
+
- Updated dependencies [e79e644]
|
|
48
|
+
- Updated dependencies [b3c9f6a]
|
|
49
|
+
- Updated dependencies [b9cf502]
|
|
50
|
+
- Updated dependencies [f4cfccd]
|
|
51
|
+
- Updated dependencies [5b8c58f]
|
|
52
|
+
- Updated dependencies [f5a6f89]
|
|
53
|
+
- ai@0.0.0-bf6e4b15-20260402200305
|
|
54
|
+
- @ai-sdk/provider@0.0.0-bf6e4b15-20260402200305
|
|
55
|
+
|
|
56
|
+
## 1.0.0-beta.5
|
|
57
|
+
|
|
58
|
+
### Patch Changes
|
|
59
|
+
|
|
60
|
+
- ai@7.0.0-beta.59
|
|
61
|
+
|
|
62
|
+
## 1.0.0-beta.4
|
|
63
|
+
|
|
64
|
+
### Patch Changes
|
|
65
|
+
|
|
66
|
+
- Updated dependencies [2e17091]
|
|
67
|
+
- ai@7.0.0-beta.58
|
|
68
|
+
|
|
69
|
+
## 1.0.0-beta.3
|
|
70
|
+
|
|
71
|
+
### Patch Changes
|
|
72
|
+
|
|
73
|
+
- Updated dependencies [986c6fd]
|
|
74
|
+
- Updated dependencies [493295c]
|
|
75
|
+
- ai@7.0.0-beta.57
|
|
76
|
+
|
|
77
|
+
## 1.0.0-beta.2
|
|
78
|
+
|
|
79
|
+
### Patch Changes
|
|
80
|
+
|
|
81
|
+
- ai@7.0.0-beta.56
|
|
82
|
+
|
|
83
|
+
## 1.0.0-beta.1
|
|
84
|
+
|
|
85
|
+
### Major Changes
|
|
86
|
+
|
|
87
|
+
- b3c9f6a: feat(ai): create new opentelemetry package (@ai-sdk/otel)
|
|
88
|
+
|
|
89
|
+
### Patch Changes
|
|
90
|
+
|
|
91
|
+
- Updated dependencies [b3c9f6a]
|
|
92
|
+
- ai@7.0.0-beta.55
|
|
93
|
+
|
|
94
|
+
## 0.0.1-beta.0
|
|
95
|
+
|
|
96
|
+
### Patch Changes
|
|
97
|
+
|
|
98
|
+
- 5d0f18e: feat(ai): move opentelemetry to new package
|
|
99
|
+
- Updated dependencies [5d0f18e]
|
|
100
|
+
- ai@7.0.0-beta.54
|
package/LICENSE
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
Copyright 2023 Vercel, Inc.
|
|
2
|
+
|
|
3
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
you may not use this file except in compliance with the License.
|
|
5
|
+
You may obtain a copy of the License at
|
|
6
|
+
|
|
7
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
|
|
9
|
+
Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
See the License for the specific language governing permissions and
|
|
13
|
+
limitations under the License.
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { LanguageModelV4Prompt } from '@ai-sdk/provider';
|
|
2
|
+
import { Tracer } from '@opentelemetry/api';
|
|
3
|
+
import { TelemetryIntegration, OnStartEvent, ToolSet, OutputInterface, ObjectOnStartEvent, EmbedOnStartEvent, RerankOnStartEvent, ObjectOnStepStartEvent, ObjectOnStepFinishEvent, GenerationContext, OnStepStartEvent, OnToolCallStartEvent, OnToolCallFinishEvent, OnStepFinishEvent, OnFinishEvent, ObjectOnFinishEvent, EmbedOnFinishEvent, RerankOnFinishEvent, EmbedStartEvent, EmbedFinishEvent, RerankStartEvent, RerankFinishEvent, OnChunkEvent } from 'ai';
|
|
4
|
+
|
|
5
|
+
interface OtelStepStartEvent<TOOLS extends ToolSet = ToolSet, CONTEXT extends GenerationContext<TOOLS> = GenerationContext<TOOLS>, OUTPUT extends OutputInterface = OutputInterface> extends OnStepStartEvent<TOOLS, CONTEXT, OUTPUT> {
|
|
6
|
+
readonly promptMessages?: LanguageModelV4Prompt;
|
|
7
|
+
readonly stepTools?: ReadonlyArray<Record<string, unknown>>;
|
|
8
|
+
readonly stepToolChoice?: unknown;
|
|
9
|
+
}
|
|
10
|
+
declare class OpenTelemetryIntegration implements TelemetryIntegration {
|
|
11
|
+
private readonly callStates;
|
|
12
|
+
/**
|
|
13
|
+
* The tracer to use for the telemetry data.
|
|
14
|
+
*/
|
|
15
|
+
private readonly tracer;
|
|
16
|
+
constructor(options?: {
|
|
17
|
+
tracer?: Tracer;
|
|
18
|
+
});
|
|
19
|
+
private getCallState;
|
|
20
|
+
private cleanupCallState;
|
|
21
|
+
executeTool<T>({ callId, toolCallId, execute, }: {
|
|
22
|
+
callId: string;
|
|
23
|
+
toolCallId: string;
|
|
24
|
+
execute: () => PromiseLike<T>;
|
|
25
|
+
}): PromiseLike<T>;
|
|
26
|
+
onStart(event: OnStartEvent<ToolSet, OutputInterface> | ObjectOnStartEvent | EmbedOnStartEvent | RerankOnStartEvent): void;
|
|
27
|
+
private onGenerateStart;
|
|
28
|
+
private onObjectOperationStart;
|
|
29
|
+
/** @deprecated */
|
|
30
|
+
onObjectStepStart(event: ObjectOnStepStartEvent): void;
|
|
31
|
+
/** @deprecated */
|
|
32
|
+
onObjectStepFinish(event: ObjectOnStepFinishEvent): void;
|
|
33
|
+
private onEmbedOperationStart;
|
|
34
|
+
onStepStart(event: OtelStepStartEvent<ToolSet, OutputInterface>): void;
|
|
35
|
+
onToolCallStart(event: OnToolCallStartEvent<ToolSet>): void;
|
|
36
|
+
onToolCallFinish(event: OnToolCallFinishEvent<ToolSet>): void;
|
|
37
|
+
onStepFinish(event: OnStepFinishEvent<ToolSet>): void;
|
|
38
|
+
onFinish(event: OnFinishEvent<ToolSet> | ObjectOnFinishEvent<unknown> | EmbedOnFinishEvent | RerankOnFinishEvent): void;
|
|
39
|
+
private onGenerateFinish;
|
|
40
|
+
private onObjectOperationFinish;
|
|
41
|
+
private onEmbedOperationFinish;
|
|
42
|
+
onEmbedStart(event: EmbedStartEvent): void;
|
|
43
|
+
onEmbedFinish(event: EmbedFinishEvent): void;
|
|
44
|
+
private onRerankOperationStart;
|
|
45
|
+
private onRerankOperationFinish;
|
|
46
|
+
onRerankStart(event: RerankStartEvent): void;
|
|
47
|
+
onRerankFinish(event: RerankFinishEvent): void;
|
|
48
|
+
onChunk(event: OnChunkEvent<ToolSet>): void;
|
|
49
|
+
onError(error: unknown): void;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export { OpenTelemetryIntegration };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { LanguageModelV4Prompt } from '@ai-sdk/provider';
|
|
2
|
+
import { Tracer } from '@opentelemetry/api';
|
|
3
|
+
import { TelemetryIntegration, OnStartEvent, ToolSet, OutputInterface, ObjectOnStartEvent, EmbedOnStartEvent, RerankOnStartEvent, ObjectOnStepStartEvent, ObjectOnStepFinishEvent, GenerationContext, OnStepStartEvent, OnToolCallStartEvent, OnToolCallFinishEvent, OnStepFinishEvent, OnFinishEvent, ObjectOnFinishEvent, EmbedOnFinishEvent, RerankOnFinishEvent, EmbedStartEvent, EmbedFinishEvent, RerankStartEvent, RerankFinishEvent, OnChunkEvent } from 'ai';
|
|
4
|
+
|
|
5
|
+
interface OtelStepStartEvent<TOOLS extends ToolSet = ToolSet, CONTEXT extends GenerationContext<TOOLS> = GenerationContext<TOOLS>, OUTPUT extends OutputInterface = OutputInterface> extends OnStepStartEvent<TOOLS, CONTEXT, OUTPUT> {
|
|
6
|
+
readonly promptMessages?: LanguageModelV4Prompt;
|
|
7
|
+
readonly stepTools?: ReadonlyArray<Record<string, unknown>>;
|
|
8
|
+
readonly stepToolChoice?: unknown;
|
|
9
|
+
}
|
|
10
|
+
declare class OpenTelemetryIntegration implements TelemetryIntegration {
|
|
11
|
+
private readonly callStates;
|
|
12
|
+
/**
|
|
13
|
+
* The tracer to use for the telemetry data.
|
|
14
|
+
*/
|
|
15
|
+
private readonly tracer;
|
|
16
|
+
constructor(options?: {
|
|
17
|
+
tracer?: Tracer;
|
|
18
|
+
});
|
|
19
|
+
private getCallState;
|
|
20
|
+
private cleanupCallState;
|
|
21
|
+
executeTool<T>({ callId, toolCallId, execute, }: {
|
|
22
|
+
callId: string;
|
|
23
|
+
toolCallId: string;
|
|
24
|
+
execute: () => PromiseLike<T>;
|
|
25
|
+
}): PromiseLike<T>;
|
|
26
|
+
onStart(event: OnStartEvent<ToolSet, OutputInterface> | ObjectOnStartEvent | EmbedOnStartEvent | RerankOnStartEvent): void;
|
|
27
|
+
private onGenerateStart;
|
|
28
|
+
private onObjectOperationStart;
|
|
29
|
+
/** @deprecated */
|
|
30
|
+
onObjectStepStart(event: ObjectOnStepStartEvent): void;
|
|
31
|
+
/** @deprecated */
|
|
32
|
+
onObjectStepFinish(event: ObjectOnStepFinishEvent): void;
|
|
33
|
+
private onEmbedOperationStart;
|
|
34
|
+
onStepStart(event: OtelStepStartEvent<ToolSet, OutputInterface>): void;
|
|
35
|
+
onToolCallStart(event: OnToolCallStartEvent<ToolSet>): void;
|
|
36
|
+
onToolCallFinish(event: OnToolCallFinishEvent<ToolSet>): void;
|
|
37
|
+
onStepFinish(event: OnStepFinishEvent<ToolSet>): void;
|
|
38
|
+
onFinish(event: OnFinishEvent<ToolSet> | ObjectOnFinishEvent<unknown> | EmbedOnFinishEvent | RerankOnFinishEvent): void;
|
|
39
|
+
private onGenerateFinish;
|
|
40
|
+
private onObjectOperationFinish;
|
|
41
|
+
private onEmbedOperationFinish;
|
|
42
|
+
onEmbedStart(event: EmbedStartEvent): void;
|
|
43
|
+
onEmbedFinish(event: EmbedFinishEvent): void;
|
|
44
|
+
private onRerankOperationStart;
|
|
45
|
+
private onRerankOperationFinish;
|
|
46
|
+
onRerankStart(event: RerankStartEvent): void;
|
|
47
|
+
onRerankFinish(event: RerankFinishEvent): void;
|
|
48
|
+
onChunk(event: OnChunkEvent<ToolSet>): void;
|
|
49
|
+
onError(error: unknown): void;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export { OpenTelemetryIntegration };
|