@sentry/server-utils 10.61.0 → 10.62.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/build/cjs/index.js +2 -0
- package/build/cjs/index.js.map +1 -1
- package/build/cjs/integrations/tracing-channel/mysql.js +2 -2
- package/build/cjs/integrations/tracing-channel/mysql.js.map +1 -1
- package/build/cjs/vercel-ai/index.js +21 -0
- package/build/cjs/vercel-ai/index.js.map +1 -0
- package/build/cjs/vercel-ai/vercel-ai-dc-subscriber.js +362 -0
- package/build/cjs/vercel-ai/vercel-ai-dc-subscriber.js.map +1 -0
- package/build/esm/index.js +1 -0
- package/build/esm/index.js.map +1 -1
- package/build/esm/integrations/tracing-channel/mysql.js +2 -2
- package/build/esm/integrations/tracing-channel/mysql.js.map +1 -1
- package/build/esm/package.json +1 -1
- package/build/esm/vercel-ai/index.js +19 -0
- package/build/esm/vercel-ai/index.js.map +1 -0
- package/build/esm/vercel-ai/vercel-ai-dc-subscriber.js +357 -0
- package/build/esm/vercel-ai/vercel-ai-dc-subscriber.js.map +1 -0
- package/build/types/index.d.ts +1 -0
- package/build/types/index.d.ts.map +1 -1
- package/build/types/vercel-ai/index.d.ts +25 -0
- package/build/types/vercel-ai/index.d.ts.map +1 -0
- package/build/types/vercel-ai/vercel-ai-dc-subscriber.d.ts +62 -0
- package/build/types/vercel-ai/vercel-ai-dc-subscriber.d.ts.map +1 -0
- package/build/types-ts3.8/index.d.ts +1 -0
- package/build/types-ts3.8/vercel-ai/index.d.ts +25 -0
- package/build/types-ts3.8/vercel-ai/vercel-ai-dc-subscriber.d.ts +62 -0
- package/package.json +2 -2
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import type { Span } from '@sentry/core';
|
|
2
|
+
import type { TracingChannel } from 'node:diagnostics_channel';
|
|
3
|
+
/** Drop the per-operation `callId` maps once the owning top-level operation settles (success or error). */
|
|
4
|
+
export declare function clearOperationId(data: VercelAiChannelMessage): void;
|
|
5
|
+
/** The lifecycle event types the `ai:telemetry` channel can carry. */
|
|
6
|
+
export type ChannelEventType = 'generateText' | 'streamText' | 'step' | 'languageModelCall' | 'executeTool' | 'embed' | 'rerank';
|
|
7
|
+
/**
|
|
8
|
+
* The context object the AI SDK passes through one tracing-channel call. It is the same object
|
|
9
|
+
* identity across `start`/`end`/`asyncEnd`/`error`, and Node's `tracingChannel` attaches
|
|
10
|
+
* `result`/`error` to it as the traced promise settles.
|
|
11
|
+
*/
|
|
12
|
+
export interface VercelAiChannelMessage {
|
|
13
|
+
type: ChannelEventType;
|
|
14
|
+
event: Record<string, unknown>;
|
|
15
|
+
result?: unknown;
|
|
16
|
+
error?: unknown;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Platform-provided factory that returns a tracing channel for the given channel name. The factory
|
|
20
|
+
* is responsible for, when `start` fires, calling `transformStart(data)` and storing the returned
|
|
21
|
+
* span on `data._sentrySpan` so the subscriber's `asyncEnd`/`error` handlers can read it.
|
|
22
|
+
*
|
|
23
|
+
* Node passes `@sentry/opentelemetry/tracing-channel`, which uses `bindStore` to additionally make
|
|
24
|
+
* the span the active OTel context for the duration of the traced operation. That is what makes
|
|
25
|
+
* nested AI SDK operations (model calls, tool calls) become children of the enclosing span without
|
|
26
|
+
* any manual parent bookkeeping here.
|
|
27
|
+
*/
|
|
28
|
+
type VercelAiTracingChannelFactory = <T extends object>(name: string) => TracingChannel<T, T>;
|
|
29
|
+
/** Integration-level recording options, pinned at subscribe time so we never look the integration up per event. */
|
|
30
|
+
interface VercelAiChannelOptions {
|
|
31
|
+
recordInputs?: boolean;
|
|
32
|
+
recordOutputs?: boolean;
|
|
33
|
+
enableTruncation?: boolean;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Subscribe Sentry span handlers to the `ai` SDK's native telemetry tracing channel (`ai:telemetry`,
|
|
37
|
+
* available in `ai` >= 7) and emit fully-formed `gen_ai.*` spans directly — no OpenTelemetry span
|
|
38
|
+
* post-processing involved.
|
|
39
|
+
*
|
|
40
|
+
* The integration passes its options in directly (rather than us looking the integration up on every
|
|
41
|
+
* event); the global `dataCollection.genAI` default is still read from the client per event.
|
|
42
|
+
*
|
|
43
|
+
* Safe to always call: on `ai` versions that don't publish to the channel (e.g. < 7) nothing is
|
|
44
|
+
* ever emitted and this is inert, so there is no double-instrumentation against the OTel-based
|
|
45
|
+
* patcher. Idempotent.
|
|
46
|
+
*/
|
|
47
|
+
export declare function subscribeVercelAiTracingChannel(tracingChannel: VercelAiTracingChannelFactory, options?: VercelAiChannelOptions): void;
|
|
48
|
+
/**
|
|
49
|
+
* Transform a channel `start` payload into the span that should be active for the operation. For
|
|
50
|
+
* `step` we deliberately don't open a span (model calls and tool calls are siblings under the
|
|
51
|
+
* invoke_agent span, matching the OTel-based output), so we reuse the active span and mark the
|
|
52
|
+
* payload to skip ending it.
|
|
53
|
+
*/
|
|
54
|
+
export declare function createSpanFromMessage(data: VercelAiChannelMessage, channelOptions: VercelAiChannelOptions): Span | undefined;
|
|
55
|
+
/**
|
|
56
|
+
* Best-effort enrichment from the resolved value the AI SDK attaches to the channel context.
|
|
57
|
+
* Everything here is guarded: when a field is missing or the shape differs across `ai` versions,
|
|
58
|
+
* we simply don't set the attribute rather than emit a malformed span.
|
|
59
|
+
*/
|
|
60
|
+
export declare function enrichSpanOnEnd(span: Span, data: VercelAiChannelMessage, channelOptions: VercelAiChannelOptions): void;
|
|
61
|
+
export {};
|
|
62
|
+
//# sourceMappingURL=vercel-ai-dc-subscriber.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vercel-ai-dc-subscriber.d.ts","sourceRoot":"","sources":["../../../src/vercel-ai/vercel-ai-dc-subscriber.ts"],"names":[],"mappings":"AA4BA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAiBzC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AA6C/D,2GAA2G;AAC3G,wBAAgB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DiagnosticChannelResponseHook, RedisTracingChannelFactory, } from './redis/redis-dc-subscriber';
|
|
8
8
|
export { bindTracingChannelToSpan } from './tracing-channel';
|
|
9
9
|
export { SentryTracingChannel, TracingChannelLifeCycleOptions, TracingChannelBindingHandle, TracingChannelPayloadWithSpan, } from './tracing-channel';
|
|
10
|
+
export { vercelAiIntegration } from './vercel-ai';
|
|
10
11
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
type VercelAiOptions = {
|
|
2
|
+
/**
|
|
3
|
+
* Enable or disable input recording. Enabled if `dataCollection.genAI.inputs` (or the deprecated `sendDefaultPii` option) is `true`
|
|
4
|
+
* or if you set `isEnabled` to `true` in your ai SDK method telemetry settings.
|
|
5
|
+
* Integration-level options take precedence over global `dataCollection` config.
|
|
6
|
+
*/
|
|
7
|
+
recordInputs?: boolean;
|
|
8
|
+
/**
|
|
9
|
+
* Enable or disable output recording. Enabled if `dataCollection.genAI.outputs` (or the deprecated `sendDefaultPii` option) is `true`
|
|
10
|
+
* or if you set `isEnabled` to `true` in your ai SDK method telemetry settings.
|
|
11
|
+
* Integration-level options take precedence over global `dataCollection` config.
|
|
12
|
+
*/
|
|
13
|
+
recordOutputs?: boolean;
|
|
14
|
+
/**
|
|
15
|
+
* Enable or disable truncation of recorded input messages.
|
|
16
|
+
* Defaults to `true`.
|
|
17
|
+
*/
|
|
18
|
+
enableTruncation?: boolean;
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Auto-instrument the `ai` SDK's native telemetry tracing channel (ai >= 7).
|
|
22
|
+
*/
|
|
23
|
+
export declare const vercelAiIntegration: (options?: VercelAiOptions | undefined) => import("@sentry/core").Integration;
|
|
24
|
+
export {};
|
|
25
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { Span } from '@sentry/core';
|
|
2
|
+
import { TracingChannel } from 'node:diagnostics_channel';
|
|
3
|
+
/** Drop the per-operation `callId` maps once the owning top-level operation settles (success or error). */
|
|
4
|
+
export declare function clearOperationId(data: VercelAiChannelMessage): void;
|
|
5
|
+
/** The lifecycle event types the `ai:telemetry` channel can carry. */
|
|
6
|
+
export type ChannelEventType = 'generateText' | 'streamText' | 'step' | 'languageModelCall' | 'executeTool' | 'embed' | 'rerank';
|
|
7
|
+
/**
|
|
8
|
+
* The context object the AI SDK passes through one tracing-channel call. It is the same object
|
|
9
|
+
* identity across `start`/`end`/`asyncEnd`/`error`, and Node's `tracingChannel` attaches
|
|
10
|
+
* `result`/`error` to it as the traced promise settles.
|
|
11
|
+
*/
|
|
12
|
+
export interface VercelAiChannelMessage {
|
|
13
|
+
type: ChannelEventType;
|
|
14
|
+
event: Record<string, unknown>;
|
|
15
|
+
result?: unknown;
|
|
16
|
+
error?: unknown;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Platform-provided factory that returns a tracing channel for the given channel name. The factory
|
|
20
|
+
* is responsible for, when `start` fires, calling `transformStart(data)` and storing the returned
|
|
21
|
+
* span on `data._sentrySpan` so the subscriber's `asyncEnd`/`error` handlers can read it.
|
|
22
|
+
*
|
|
23
|
+
* Node passes `@sentry/opentelemetry/tracing-channel`, which uses `bindStore` to additionally make
|
|
24
|
+
* the span the active OTel context for the duration of the traced operation. That is what makes
|
|
25
|
+
* nested AI SDK operations (model calls, tool calls) become children of the enclosing span without
|
|
26
|
+
* any manual parent bookkeeping here.
|
|
27
|
+
*/
|
|
28
|
+
type VercelAiTracingChannelFactory = <T extends object>(name: string) => TracingChannel<T, T>;
|
|
29
|
+
/** Integration-level recording options, pinned at subscribe time so we never look the integration up per event. */
|
|
30
|
+
interface VercelAiChannelOptions {
|
|
31
|
+
recordInputs?: boolean;
|
|
32
|
+
recordOutputs?: boolean;
|
|
33
|
+
enableTruncation?: boolean;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Subscribe Sentry span handlers to the `ai` SDK's native telemetry tracing channel (`ai:telemetry`,
|
|
37
|
+
* available in `ai` >= 7) and emit fully-formed `gen_ai.*` spans directly — no OpenTelemetry span
|
|
38
|
+
* post-processing involved.
|
|
39
|
+
*
|
|
40
|
+
* The integration passes its options in directly (rather than us looking the integration up on every
|
|
41
|
+
* event); the global `dataCollection.genAI` default is still read from the client per event.
|
|
42
|
+
*
|
|
43
|
+
* Safe to always call: on `ai` versions that don't publish to the channel (e.g. < 7) nothing is
|
|
44
|
+
* ever emitted and this is inert, so there is no double-instrumentation against the OTel-based
|
|
45
|
+
* patcher. Idempotent.
|
|
46
|
+
*/
|
|
47
|
+
export declare function subscribeVercelAiTracingChannel(tracingChannel: VercelAiTracingChannelFactory, options?: VercelAiChannelOptions): void;
|
|
48
|
+
/**
|
|
49
|
+
* Transform a channel `start` payload into the span that should be active for the operation. For
|
|
50
|
+
* `step` we deliberately don't open a span (model calls and tool calls are siblings under the
|
|
51
|
+
* invoke_agent span, matching the OTel-based output), so we reuse the active span and mark the
|
|
52
|
+
* payload to skip ending it.
|
|
53
|
+
*/
|
|
54
|
+
export declare function createSpanFromMessage(data: VercelAiChannelMessage, channelOptions: VercelAiChannelOptions): Span | undefined;
|
|
55
|
+
/**
|
|
56
|
+
* Best-effort enrichment from the resolved value the AI SDK attaches to the channel context.
|
|
57
|
+
* Everything here is guarded: when a field is missing or the shape differs across `ai` versions,
|
|
58
|
+
* we simply don't set the attribute rather than emit a malformed span.
|
|
59
|
+
*/
|
|
60
|
+
export declare function enrichSpanOnEnd(span: Span, data: VercelAiChannelMessage, channelOptions: VercelAiChannelOptions): void;
|
|
61
|
+
export {};
|
|
62
|
+
//# sourceMappingURL=vercel-ai-dc-subscriber.d.ts.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sentry/server-utils",
|
|
3
|
-
"version": "10.
|
|
3
|
+
"version": "10.62.0",
|
|
4
4
|
"description": "Server Utilities for all Sentry JavaScript SDKs",
|
|
5
5
|
"repository": "git://github.com/getsentry/sentry-javascript.git",
|
|
6
6
|
"homepage": "https://github.com/getsentry/sentry-javascript/tree/master/packages/server-utils",
|
|
@@ -86,7 +86,7 @@
|
|
|
86
86
|
"@apm-js-collab/code-transformer": "^0.15.0",
|
|
87
87
|
"@apm-js-collab/tracing-hooks": "^0.10.0",
|
|
88
88
|
"@sentry/conventions": "^0.12.0",
|
|
89
|
-
"@sentry/core": "10.
|
|
89
|
+
"@sentry/core": "10.62.0",
|
|
90
90
|
"magic-string": "~0.30.0"
|
|
91
91
|
},
|
|
92
92
|
"devDependencies": {
|