@introspection-sdk/introspection-node 0.19.1 → 0.21.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/README.md +28 -8
- package/dist/auth.d.ts +1 -1
- package/dist/client.d.ts +4 -3
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +16 -7
- package/dist/client.js.map +1 -1
- package/dist/dev-target.js +1 -1
- package/dist/index.d.ts +4 -7
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -6
- package/dist/index.js.map +1 -1
- package/dist/otel/index.d.ts +1 -14
- package/dist/otel/index.d.ts.map +1 -1
- package/dist/otel/index.js +10 -18
- package/dist/otel/index.js.map +1 -1
- package/dist/otel/init.d.ts +19 -21
- package/dist/otel/init.d.ts.map +1 -1
- package/dist/otel/init.js +62 -48
- package/dist/otel/init.js.map +1 -1
- package/dist/otel/integrations/base.d.ts +17 -37
- package/dist/otel/integrations/base.d.ts.map +1 -1
- package/dist/otel/integrations/base.js +6 -13
- package/dist/otel/integrations/base.js.map +1 -1
- package/dist/otel/integrations/index.d.ts +3 -4
- package/dist/otel/integrations/index.d.ts.map +1 -1
- package/dist/otel/integrations/index.js +6 -25
- package/dist/otel/integrations/index.js.map +1 -1
- package/dist/otel/integrations/pi.d.ts.map +1 -1
- package/dist/otel/integrations/pi.js +9 -1
- package/dist/otel/integrations/pi.js.map +1 -1
- package/dist/otel/logs.d.ts +41 -8
- package/dist/otel/logs.d.ts.map +1 -1
- package/dist/otel/logs.js +95 -66
- package/dist/otel/logs.js.map +1 -1
- package/dist/otel/pi.d.ts +18 -5
- package/dist/otel/pi.d.ts.map +1 -1
- package/dist/otel/pi.js +38 -9
- package/dist/otel/pi.js.map +1 -1
- package/dist/otel/register.d.ts +2 -2
- package/dist/otel/register.d.ts.map +1 -1
- package/dist/otel/register.js +7 -9
- package/dist/otel/register.js.map +1 -1
- package/dist/otel/setup.d.ts +2 -2
- package/dist/otel/setup.d.ts.map +1 -1
- package/dist/otel/setup.js +16 -6
- package/dist/otel/setup.js.map +1 -1
- package/dist/otel/span-processor.d.ts +18 -5
- package/dist/otel/span-processor.d.ts.map +1 -1
- package/dist/otel/span-processor.js +50 -65
- package/dist/otel/span-processor.js.map +1 -1
- package/dist/resources/experiments.d.ts +10 -5
- package/dist/resources/experiments.d.ts.map +1 -1
- package/dist/resources/experiments.js +9 -25
- package/dist/resources/experiments.js.map +1 -1
- package/dist/resources/recipes.d.ts +6 -6
- package/dist/resources/recipes.d.ts.map +1 -1
- package/dist/resources/recipes.js +5 -23
- package/dist/resources/recipes.js.map +1 -1
- package/dist/resources/runtimes.d.ts +2 -2
- package/dist/resources/runtimes.d.ts.map +1 -1
- package/dist/resources/runtimes.js +2 -2
- package/dist/resources/runtimes.js.map +1 -1
- package/dist/runner.d.ts +8 -4
- package/dist/runner.d.ts.map +1 -1
- package/dist/runner.js +26 -18
- package/dist/runner.js.map +1 -1
- package/dist/types.d.ts +1 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +1 -1
- package/dist/types.js.map +1 -1
- package/dist/utils.d.ts +45 -0
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +61 -2
- package/dist/utils.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.d.ts.map +1 -1
- package/dist/version.js +1 -1
- package/dist/version.js.map +1 -1
- package/package.json +18 -60
- package/.turbo/turbo-build.log +0 -4
- package/dist/converters/claude.d.ts +0 -150
- package/dist/converters/claude.d.ts.map +0 -1
- package/dist/converters/claude.js +0 -211
- package/dist/converters/claude.js.map +0 -1
- package/dist/converters/gemini.d.ts +0 -90
- package/dist/converters/gemini.d.ts.map +0 -1
- package/dist/converters/gemini.js +0 -171
- package/dist/converters/gemini.js.map +0 -1
- package/dist/converters/index.d.ts +0 -9
- package/dist/converters/index.d.ts.map +0 -1
- package/dist/converters/index.js +0 -9
- package/dist/converters/index.js.map +0 -1
- package/dist/converters/openai.d.ts +0 -51
- package/dist/converters/openai.d.ts.map +0 -1
- package/dist/converters/openai.js +0 -269
- package/dist/converters/openai.js.map +0 -1
- package/dist/converters/openinference.d.ts +0 -107
- package/dist/converters/openinference.d.ts.map +0 -1
- package/dist/converters/openinference.js +0 -553
- package/dist/converters/openinference.js.map +0 -1
- package/dist/converters/vercel.d.ts +0 -21
- package/dist/converters/vercel.d.ts.map +0 -1
- package/dist/converters/vercel.js +0 -236
- package/dist/converters/vercel.js.map +0 -1
- package/dist/otel/anthropic.d.ts +0 -63
- package/dist/otel/anthropic.d.ts.map +0 -1
- package/dist/otel/anthropic.js +0 -475
- package/dist/otel/anthropic.js.map +0 -1
- package/dist/otel/claude-hooks.d.ts +0 -346
- package/dist/otel/claude-hooks.d.ts.map +0 -1
- package/dist/otel/claude-hooks.js +0 -647
- package/dist/otel/claude-hooks.js.map +0 -1
- package/dist/otel/claude-wrapper.d.ts +0 -93
- package/dist/otel/claude-wrapper.d.ts.map +0 -1
- package/dist/otel/claude-wrapper.js +0 -155
- package/dist/otel/claude-wrapper.js.map +0 -1
- package/dist/otel/gemini.d.ts +0 -56
- package/dist/otel/gemini.d.ts.map +0 -1
- package/dist/otel/gemini.js +0 -350
- package/dist/otel/gemini.js.map +0 -1
- package/dist/otel/integrations/anthropic.d.ts +0 -10
- package/dist/otel/integrations/anthropic.d.ts.map +0 -1
- package/dist/otel/integrations/anthropic.js +0 -26
- package/dist/otel/integrations/anthropic.js.map +0 -1
- package/dist/otel/integrations/claude-agent.d.ts +0 -12
- package/dist/otel/integrations/claude-agent.d.ts.map +0 -1
- package/dist/otel/integrations/claude-agent.js +0 -28
- package/dist/otel/integrations/claude-agent.js.map +0 -1
- package/dist/otel/integrations/gemini.d.ts +0 -11
- package/dist/otel/integrations/gemini.d.ts.map +0 -1
- package/dist/otel/integrations/gemini.js +0 -23
- package/dist/otel/integrations/gemini.js.map +0 -1
- package/dist/otel/integrations/langchain.d.ts +0 -15
- package/dist/otel/integrations/langchain.d.ts.map +0 -1
- package/dist/otel/integrations/langchain.js +0 -43
- package/dist/otel/integrations/langchain.js.map +0 -1
- package/dist/otel/integrations/mastra.d.ts +0 -14
- package/dist/otel/integrations/mastra.d.ts.map +0 -1
- package/dist/otel/integrations/mastra.js +0 -31
- package/dist/otel/integrations/mastra.js.map +0 -1
- package/dist/otel/integrations/openai-agents.d.ts +0 -11
- package/dist/otel/integrations/openai-agents.d.ts.map +0 -1
- package/dist/otel/integrations/openai-agents.js +0 -30
- package/dist/otel/integrations/openai-agents.js.map +0 -1
- package/dist/otel/integrations/vercel.d.ts +0 -14
- package/dist/otel/integrations/vercel.d.ts.map +0 -1
- package/dist/otel/integrations/vercel.js +0 -20
- package/dist/otel/integrations/vercel.js.map +0 -1
- package/dist/otel/langchain-handler.d.ts +0 -112
- package/dist/otel/langchain-handler.d.ts.map +0 -1
- package/dist/otel/langchain-handler.js +0 -561
- package/dist/otel/langchain-handler.js.map +0 -1
- package/dist/otel/mastra-exporter.d.ts +0 -87
- package/dist/otel/mastra-exporter.d.ts.map +0 -1
- package/dist/otel/mastra-exporter.js +0 -530
- package/dist/otel/mastra-exporter.js.map +0 -1
- package/dist/otel/openai.d.ts +0 -20
- package/dist/otel/openai.d.ts.map +0 -1
- package/dist/otel/openai.js +0 -55
- package/dist/otel/openai.js.map +0 -1
- package/dist/otel/tracing-processor.d.ts +0 -139
- package/dist/otel/tracing-processor.d.ts.map +0 -1
- package/dist/otel/tracing-processor.js +0 -434
- package/dist/otel/tracing-processor.js.map +0 -1
- package/eslint.config.mjs +0 -4
- package/src/auth.ts +0 -236
- package/src/client.ts +0 -163
- package/src/converters/claude.ts +0 -343
- package/src/converters/gemini.ts +0 -243
- package/src/converters/index.ts +0 -50
- package/src/converters/openai.ts +0 -300
- package/src/converters/openinference.ts +0 -665
- package/src/converters/vercel.ts +0 -302
- package/src/dev-target.ts +0 -79
- package/src/http.ts +0 -43
- package/src/index.ts +0 -266
- package/src/otel/anthropic.ts +0 -619
- package/src/otel/claude-hooks.ts +0 -1116
- package/src/otel/claude-wrapper.ts +0 -239
- package/src/otel/gemini.ts +0 -483
- package/src/otel/index.ts +0 -128
- package/src/otel/init.ts +0 -411
- package/src/otel/integrations/anthropic.ts +0 -36
- package/src/otel/integrations/base.ts +0 -158
- package/src/otel/integrations/claude-agent.ts +0 -36
- package/src/otel/integrations/gemini.ts +0 -30
- package/src/otel/integrations/index.ts +0 -152
- package/src/otel/integrations/langchain.ts +0 -60
- package/src/otel/integrations/mastra.ts +0 -48
- package/src/otel/integrations/openai-agents.ts +0 -47
- package/src/otel/integrations/pi.ts +0 -28
- package/src/otel/integrations/vercel.ts +0 -26
- package/src/otel/langchain-handler.ts +0 -804
- package/src/otel/logs.ts +0 -395
- package/src/otel/mastra-exporter.ts +0 -714
- package/src/otel/openai.ts +0 -93
- package/src/otel/pi.ts +0 -94
- package/src/otel/register.ts +0 -50
- package/src/otel/setup.ts +0 -215
- package/src/otel/span-processor.ts +0 -512
- package/src/otel/tracing-processor.ts +0 -637
- package/src/pagination.ts +0 -10
- package/src/proxy-from-env.d.ts +0 -7
- package/src/resources/experiments.ts +0 -176
- package/src/resources/recipes.ts +0 -74
- package/src/resources/runtimes.ts +0 -31
- package/src/runner.ts +0 -213
- package/src/types.ts +0 -13
- package/src/utils.ts +0 -95
- package/src/version.ts +0 -2
- package/tsconfig.json +0 -8
package/dist/otel/init.js
CHANGED
|
@@ -2,39 +2,36 @@
|
|
|
2
2
|
* One-liner bootstrap for the Introspection OTel surface.
|
|
3
3
|
*
|
|
4
4
|
* `init()` detects the installed LLM frameworks and wires them into one shared
|
|
5
|
-
* pipeline
|
|
5
|
+
* pipeline:
|
|
6
6
|
*
|
|
7
7
|
* ```ts
|
|
8
8
|
* import * as introspection from "@introspection-sdk/introspection-node/otel";
|
|
9
|
-
* import Anthropic from "@anthropic-ai/sdk";
|
|
10
9
|
*
|
|
11
10
|
* await introspection.init({ serviceName: "my-app" });
|
|
12
|
-
*
|
|
13
|
-
* const client = new Anthropic(); // auto-traced — no per-client wiring
|
|
14
|
-
* await introspection.conversation(() =>
|
|
15
|
-
* client.messages.create({ ... }),
|
|
16
|
-
* );
|
|
11
|
+
* // An installed Pi agent is wired into the shared provider automatically.
|
|
17
12
|
* ```
|
|
18
13
|
*
|
|
19
14
|
* It also exposes the `track` / `feedback` / `identify` analytics surface and a
|
|
20
15
|
* `conversation()` scope, proxied to a global {@link IntrospectionLogs}.
|
|
21
16
|
*/
|
|
22
|
-
import {
|
|
17
|
+
import { context, propagation } from "@opentelemetry/api";
|
|
18
|
+
import { defaultResource, resourceFromAttributes, } from "@opentelemetry/resources";
|
|
23
19
|
import { NodeTracerProvider } from "@opentelemetry/sdk-trace-node";
|
|
24
20
|
import { ATTR_SERVICE_NAME } from "@opentelemetry/semantic-conventions";
|
|
25
|
-
import { logger } from "../utils.js";
|
|
21
|
+
import { DEFAULT_SERVICE_NAME, logger } from "../utils.js";
|
|
26
22
|
import { discoverIntegrations, setupIntegrations, teardownIntegrations, } from "./integrations/index.js";
|
|
27
23
|
import { IntrospectionLogs } from "./logs.js";
|
|
28
24
|
import { registerOTelGlobals } from "./setup.js";
|
|
29
25
|
import { IntrospectionSpanProcessor } from "./span-processor.js";
|
|
30
26
|
const state = {
|
|
31
27
|
provider: null,
|
|
28
|
+
pending: null,
|
|
32
29
|
ownsProvider: false,
|
|
33
30
|
logs: null,
|
|
34
31
|
handles: {},
|
|
35
32
|
shutdownRegistered: false,
|
|
36
33
|
};
|
|
37
|
-
/** Generate a fresh conversation id
|
|
34
|
+
/** Generate a fresh conversation id in the format the backend expects. */
|
|
38
35
|
export function newConversationId() {
|
|
39
36
|
return `intro_conv_${crypto.randomUUID().replace(/-/g, "")}`;
|
|
40
37
|
}
|
|
@@ -45,9 +42,18 @@ function resolveProvider(options, token, serviceName, advanced) {
|
|
|
45
42
|
if (options.tracerProvider)
|
|
46
43
|
return options.tracerProvider;
|
|
47
44
|
const provider = new NodeTracerProvider({
|
|
48
|
-
resource:
|
|
49
|
-
|
|
50
|
-
|
|
45
|
+
// Merged onto the default resource, not substituted for it: a bare
|
|
46
|
+
// `resourceFromAttributes` replaces `defaultResource()` outright, which
|
|
47
|
+
// is where `telemetry.sdk.language` and the SDK version come from.
|
|
48
|
+
//
|
|
49
|
+
// Defaulted, because we are building this provider ourselves and the
|
|
50
|
+
// logs stream beside it defaults to the same name. Only here: a caller
|
|
51
|
+
// who passed their own `tracerProvider` returns above, and the span
|
|
52
|
+
// processor still gets `serviceName` undefined so it leaves a provider
|
|
53
|
+
// the caller already labelled alone.
|
|
54
|
+
resource: defaultResource().merge(resourceFromAttributes({
|
|
55
|
+
[ATTR_SERVICE_NAME]: serviceName ?? DEFAULT_SERVICE_NAME,
|
|
56
|
+
})),
|
|
51
57
|
// Order is irrelevant (IntrospectionSpanProcessor exports an isolated
|
|
52
58
|
// converted copy and never mutates the shared span); listed first to match
|
|
53
59
|
// setupTracing()'s ordering.
|
|
@@ -65,15 +71,33 @@ function resolveProvider(options, token, serviceName, advanced) {
|
|
|
65
71
|
* Idempotent: repeated calls return the already-configured provider without
|
|
66
72
|
* re-installing integrations.
|
|
67
73
|
*/
|
|
68
|
-
export
|
|
74
|
+
export function init(options = {}) {
|
|
69
75
|
if (state.provider) {
|
|
70
76
|
logger.debug("introspection.init() already called; returning provider");
|
|
71
|
-
return state.provider;
|
|
77
|
+
return Promise.resolve(state.provider);
|
|
78
|
+
}
|
|
79
|
+
if (state.pending) {
|
|
80
|
+
logger.debug("introspection.init() already in flight; awaiting it");
|
|
81
|
+
return state.pending;
|
|
72
82
|
}
|
|
83
|
+
// Cleared on both paths: on success the `state.provider` guard takes over,
|
|
84
|
+
// and on failure a later init() has to be free to retry.
|
|
85
|
+
const pending = initOnce(options).finally(() => {
|
|
86
|
+
state.pending = null;
|
|
87
|
+
});
|
|
88
|
+
state.pending = pending;
|
|
89
|
+
return pending;
|
|
90
|
+
}
|
|
91
|
+
async function initOnce(options) {
|
|
73
92
|
const token = options.token ?? process.env.INTROSPECTION_TOKEN;
|
|
74
93
|
const serviceName = options.serviceName ?? process.env.INTROSPECTION_SERVICE_NAME ?? undefined;
|
|
75
94
|
const baseUrl = options.baseUrl ?? process.env.INTROSPECTION_BASE_OTEL_URL ?? undefined;
|
|
76
95
|
const advanced = options.advanced;
|
|
96
|
+
// `AdvancedOptions.debug` is shared with the browser client, which honours
|
|
97
|
+
// it; Node only ever read INTROSPECTION_LOG_LEVEL, so passing it here was
|
|
98
|
+
// silently inert.
|
|
99
|
+
if (advanced?.debug)
|
|
100
|
+
logger.enableDebug();
|
|
77
101
|
// A custom span exporter (tests) stands in for a token; otherwise a token is
|
|
78
102
|
// required for anything to be exported.
|
|
79
103
|
if (!token && !advanced?.spanExporter && !options.tracerProvider) {
|
|
@@ -89,6 +113,14 @@ export async function init(options = {}) {
|
|
|
89
113
|
additionalHeaders: advanced?.additionalHeaders,
|
|
90
114
|
flushInterval: advanced?.flushInterval,
|
|
91
115
|
maxBatchSize: advanced?.maxBatchSize,
|
|
116
|
+
maxQueueSize: advanced?.maxQueueSize,
|
|
117
|
+
exportTimeoutMillis: advanced?.exportTimeoutMillis,
|
|
118
|
+
// Dropped here until now, so `init({ advanced: { logExporter } })` built
|
|
119
|
+
// an OTLP exporter anyway and every analytics event went to the real
|
|
120
|
+
// collector — from the one option documented as the seam for asserting
|
|
121
|
+
// what goes out on the wire. `spanExporter` was forwarded all along;
|
|
122
|
+
// this is its counterpart on the logs pipeline.
|
|
123
|
+
logExporter: advanced?.logExporter,
|
|
92
124
|
});
|
|
93
125
|
const ctx = {
|
|
94
126
|
tracerProvider: provider,
|
|
@@ -112,6 +144,10 @@ export async function init(options = {}) {
|
|
|
112
144
|
}
|
|
113
145
|
catch (e) {
|
|
114
146
|
state.handles = {};
|
|
147
|
+
// The logs client owns a LoggerProvider with a batch export timer. It was
|
|
148
|
+
// built before this try, so without shutting it down a failed init()
|
|
149
|
+
// leaves that timer running with nothing referencing it.
|
|
150
|
+
await logs.shutdown().catch(() => undefined);
|
|
115
151
|
throw e;
|
|
116
152
|
}
|
|
117
153
|
state.provider = provider;
|
|
@@ -154,7 +190,8 @@ export function identify(userId, traits, anonymousId, eventId) {
|
|
|
154
190
|
export function conversation(a, b) {
|
|
155
191
|
const conversationId = typeof a === "string" ? a : newConversationId();
|
|
156
192
|
const callback = (typeof a === "string" ? b : a);
|
|
157
|
-
|
|
193
|
+
const ctx = propagation.setBaggage(context.active(), (propagation.getBaggage(context.active()) ?? propagation.createBaggage()).setEntry("gen_ai.conversation.id", { value: conversationId }));
|
|
194
|
+
return Promise.resolve(context.with(ctx, () => callback(conversationId)));
|
|
158
195
|
}
|
|
159
196
|
/**
|
|
160
197
|
* Run `callback` with `gen_ai.agent.name` (+ optional `gen_ai.agent.id`) on the
|
|
@@ -180,25 +217,6 @@ export function withUserId(userId, callback) {
|
|
|
180
217
|
export function withAnonymousId(anonymousId, callback) {
|
|
181
218
|
return getClient().withAnonymousId(anonymousId, callback);
|
|
182
219
|
}
|
|
183
|
-
/**
|
|
184
|
-
* The LangChain handler bound by `init()`. Attach it per-invoke:
|
|
185
|
-
* `chain.invoke(input, { callbacks: [introspection.getLangchainHandler()] })`.
|
|
186
|
-
*/
|
|
187
|
-
export function getLangchainHandler() {
|
|
188
|
-
const handler = state.handles.langchainHandler;
|
|
189
|
-
if (!handler) {
|
|
190
|
-
throw new Error("LangChain integration not configured. Call introspection.init() with @langchain/core installed.");
|
|
191
|
-
}
|
|
192
|
-
return handler;
|
|
193
|
-
}
|
|
194
|
-
/** The Mastra exporter bound by `init()`. Put it in `observability.configs`. */
|
|
195
|
-
export function getMastraExporter() {
|
|
196
|
-
const exporter = state.handles.mastraExporter;
|
|
197
|
-
if (!exporter) {
|
|
198
|
-
throw new Error("Mastra integration not configured. Call introspection.init() with @mastra/core installed.");
|
|
199
|
-
}
|
|
200
|
-
return exporter;
|
|
201
|
-
}
|
|
202
220
|
/** Instrument a Pi `Agent` against the shared provider. Requires {@link init}. */
|
|
203
221
|
export function instrumentPi(agent, meta) {
|
|
204
222
|
const instrumentor = state.handles.piInstrumentor;
|
|
@@ -208,19 +226,14 @@ export function instrumentPi(agent, meta) {
|
|
|
208
226
|
instrumentor.instrument(agent, meta);
|
|
209
227
|
}
|
|
210
228
|
/**
|
|
211
|
-
*
|
|
212
|
-
*
|
|
229
|
+
* Flush and shut down the logs client and, if `init()` created it, the
|
|
230
|
+
* provider.
|
|
231
|
+
*
|
|
232
|
+
* A provider you passed via `init({ tracerProvider })` is **yours** — this
|
|
233
|
+
* leaves it running, so any processors you attached to it (a second
|
|
234
|
+
* OTLP backend, for instance) are not flushed. Call `provider.shutdown()`
|
|
235
|
+
* yourself after this.
|
|
213
236
|
*/
|
|
214
|
-
export function instrumentClaudeAgent(
|
|
215
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
216
|
-
sdk) {
|
|
217
|
-
const fn = state.handles.instrumentClaudeAgent;
|
|
218
|
-
if (!fn) {
|
|
219
|
-
throw new Error("Claude Agent integration not configured. Call introspection.init() with @anthropic-ai/claude-agent-sdk installed.");
|
|
220
|
-
}
|
|
221
|
-
return fn(sdk);
|
|
222
|
-
}
|
|
223
|
-
/** Flush and shut down the logs client and (if owned) the provider. */
|
|
224
237
|
export async function shutdown() {
|
|
225
238
|
const { logs, provider, ownsProvider } = state;
|
|
226
239
|
if (logs) {
|
|
@@ -239,7 +252,7 @@ export async function shutdown() {
|
|
|
239
252
|
logger.debug(`Error shutting down provider: ${String(e)}`);
|
|
240
253
|
}
|
|
241
254
|
}
|
|
242
|
-
// Run integration teardowns
|
|
255
|
+
// Run integration teardowns + clear the
|
|
243
256
|
// run-once guard so a later init() re-installs and rebuilds the handles
|
|
244
257
|
// against the new provider instead of being skipped.
|
|
245
258
|
teardownIntegrations();
|
|
@@ -252,6 +265,7 @@ export async function shutdown() {
|
|
|
252
265
|
export function _resetForTests() {
|
|
253
266
|
teardownIntegrations();
|
|
254
267
|
state.provider = null;
|
|
268
|
+
state.pending = null;
|
|
255
269
|
state.ownsProvider = false;
|
|
256
270
|
state.logs = null;
|
|
257
271
|
state.handles = {};
|
package/dist/otel/init.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init.js","sourceRoot":"","sources":["../../src/otel/init.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"init.js","sourceRoot":"","sources":["../../src/otel/init.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,OAAO,EAAE,WAAW,EAAuB,MAAM,oBAAoB,CAAC;AAC/E,OAAO,EACL,eAAe,EACf,sBAAsB,GACvB,MAAM,0BAA0B,CAAC;AAKlC,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AACnE,OAAO,EAAE,iBAAiB,EAAE,MAAM,qCAAqC,CAAC;AAGxE,OAAO,EAAE,oBAAoB,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAC3D,OAAO,EACL,oBAAoB,EACpB,iBAAiB,EACjB,oBAAoB,GAIrB,MAAM,yBAAyB,CAAC;AAIjC,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAC9C,OAAO,EAAyB,mBAAmB,EAAE,MAAM,YAAY,CAAC;AACxE,OAAO,EAAE,0BAA0B,EAAE,MAAM,qBAAqB,CAAC;AAkDjE,MAAM,KAAK,GAAc;IACvB,QAAQ,EAAE,IAAI;IACd,OAAO,EAAE,IAAI;IACb,YAAY,EAAE,KAAK;IACnB,IAAI,EAAE,IAAI;IACV,OAAO,EAAE,EAAE;IACX,kBAAkB,EAAE,KAAK;CAC1B,CAAC;AAEF,0EAA0E;AAC1E,MAAM,UAAU,iBAAiB;IAC/B,OAAO,cAAc,MAAM,CAAC,UAAU,EAAE,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,EAAE,CAAC;AAC/D,CAAC;AAED,SAAS,eAAe,CACtB,OAAoB,EACpB,KAAyB,EACzB,WAA+B,EAC/B,QAAqC;IAErC,6EAA6E;IAC7E,4BAA4B;IAC5B,mB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,CAAC;IAC3B,KAAK,CAAC,IAAI,GAAG,IAAI,CAAC;IAClB,KAAK,CAAC,OAAO,GAAG,EAAE,CAAC;AACrB,CAAC"}
|
|
@@ -1,49 +1,35 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Integration base contract, modeled on Sentry's integration registry
|
|
3
|
-
* Python SDK's `Integration` ABC.
|
|
2
|
+
* Integration base contract, modeled on Sentry's integration registry.
|
|
4
3
|
*
|
|
5
|
-
* An {@link Integration} knows how to wire one framework (
|
|
6
|
-
*
|
|
4
|
+
* An {@link Integration} knows how to wire one framework (currently Pi) into
|
|
5
|
+
* the shared Introspection trace pipeline. `init()`
|
|
7
6
|
* discovers the integrations whose framework is importable and runs each
|
|
8
7
|
* `setupOnce()` exactly once.
|
|
9
8
|
*/
|
|
10
9
|
import type { BasicTracerProvider } from "@opentelemetry/sdk-trace-base";
|
|
11
10
|
import type { AdvancedOptions } from "../../types.js";
|
|
12
|
-
import type { InstrumentedClaudeAgentSDK } from "../claude-wrapper.js";
|
|
13
|
-
import type { IntrospectionCallbackHandler } from "../langchain-handler.js";
|
|
14
11
|
import type { IntrospectionPiInstrumentor } from "../pi.js";
|
|
15
12
|
export declare const OPTIONAL_PEERS: {
|
|
16
|
-
readonly anthropic: "@anthropic-ai/sdk";
|
|
17
|
-
readonly claudeAgent: "@anthropic-ai/claude-agent-sdk";
|
|
18
|
-
readonly gemini: "@google/genai";
|
|
19
|
-
readonly langchainCallbacks: "@langchain/core/callbacks/base";
|
|
20
|
-
readonly mastraObservability: "@mastra/observability";
|
|
21
|
-
readonly openaiAgents: "@openai/agents";
|
|
22
13
|
readonly piAgentCore: "@earendil-works/pi-agent-core";
|
|
23
|
-
readonly vercelAi: "ai";
|
|
24
14
|
};
|
|
25
15
|
/**
|
|
26
16
|
* Bound framework handles published by instance/config-based integrations.
|
|
27
17
|
*
|
|
28
18
|
* Some JS framework hooks cannot be wired globally — the caller still has to
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
* `init()` token / provider, and `init()` re-exposes it (e.g.
|
|
33
|
-
* `introspection.getLangchainHandler()`).
|
|
19
|
+
* instrument an Agent instance. For those, the integration publishes a handle
|
|
20
|
+
* here, pre-bound to the `init()` token / provider, and `init()` re-exposes it
|
|
21
|
+
* (e.g. `introspection.instrumentPi()`).
|
|
34
22
|
*/
|
|
35
23
|
export interface IntegrationHandles {
|
|
36
|
-
langchainHandler?: IntrospectionCallbackHandler;
|
|
37
|
-
mastraExporter?: any;
|
|
38
24
|
piInstrumentor?: IntrospectionPiInstrumentor;
|
|
39
|
-
instrumentClaudeAgent?: (sdk: any) => InstrumentedClaudeAgentSDK;
|
|
40
25
|
}
|
|
41
26
|
/**
|
|
42
27
|
* Thrown by an integration module/`setupOnce` when the framework cannot be
|
|
43
28
|
* activated (package missing, version too old, …).
|
|
44
29
|
*
|
|
45
|
-
*
|
|
46
|
-
*
|
|
30
|
+
* Always swallowed by `setupIntegrations`, whether the integration was
|
|
31
|
+
* auto-discovered or requested explicitly — a framework that cannot activate
|
|
32
|
+
* skips its shim. Any other error propagates.
|
|
47
33
|
*/
|
|
48
34
|
export declare class DidNotEnable extends Error {
|
|
49
35
|
constructor(message: string);
|
|
@@ -64,10 +50,9 @@ export declare function isOptionalPeerInstalled(specifier: (typeof OPTIONAL_PEER
|
|
|
64
50
|
/**
|
|
65
51
|
* Everything an integration needs to wire itself into the shared pipeline.
|
|
66
52
|
*
|
|
67
|
-
*
|
|
68
|
-
*
|
|
69
|
-
* `token` / `serviceName` / `baseUrl`.
|
|
70
|
-
* `TracerProvider` (Anthropic, Gemini, Vercel AI SDK, Pi) use `tracerProvider`.
|
|
53
|
+
* Instrumentors that emit onto the shared `TracerProvider` (currently Pi) use
|
|
54
|
+
* `tracerProvider`; hooks that own their own OTLP export pipeline only need
|
|
55
|
+
* the `token` / `serviceName` / `baseUrl`.
|
|
71
56
|
*/
|
|
72
57
|
export interface IntegrationSetupContext {
|
|
73
58
|
/** The shared provider built (or adopted) by `init()`. */
|
|
@@ -88,23 +73,18 @@ export interface IntegrationSetupContext {
|
|
|
88
73
|
* users may also pass custom integrations to `init({ integrations: [...] })`.
|
|
89
74
|
*/
|
|
90
75
|
export interface Integration {
|
|
91
|
-
/** Stable identifier used for the run-once guard
|
|
76
|
+
/** Stable identifier used for the run-once guard. */
|
|
92
77
|
readonly identifier: string;
|
|
93
|
-
/**
|
|
94
|
-
* Identifiers of other integrations to disable when this one is active, so a
|
|
95
|
-
* wrapping framework (e.g. LangChain) does not double-trace the SDK it wraps.
|
|
96
|
-
*/
|
|
97
|
-
readonly deactivates?: readonly string[];
|
|
98
78
|
/**
|
|
99
79
|
* Optional availability probe for built-in integrations backed by optional
|
|
100
|
-
* peer packages. Missing peers should return false so
|
|
101
|
-
*
|
|
80
|
+
* peer packages. Missing peers should return false so the integration is
|
|
81
|
+
* skipped quietly.
|
|
102
82
|
*/
|
|
103
83
|
isAvailable?(): boolean | Promise<boolean>;
|
|
104
84
|
/**
|
|
105
85
|
* Wire the framework into the shared pipeline. Runs once; may throw
|
|
106
|
-
* {@link DidNotEnable}. May return a teardown callback (e.g. to
|
|
107
|
-
*
|
|
86
|
+
* {@link DidNotEnable}. May return a teardown callback (e.g. to detach a
|
|
87
|
+
* framework hook) that `introspection.shutdown()` runs so a later `init()`
|
|
108
88
|
* re-installs cleanly against the rebuilt provider.
|
|
109
89
|
*/
|
|
110
90
|
setupOnce(ctx: IntegrationSetupContext): void | (() => void) | Promise<void | (() => void)>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../../../src/otel/integrations/base.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../../../src/otel/integrations/base.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AAEzE,OAAO,KAAK,EAAE,eAAe,E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,MAAM,IAAI,CAAC,GAAG,OAAO,CAAC,IAAI,GAAG,CAAC,MAAM,IAAI,CAAC,CAAC,CAAC;CACvD"}
|
|
@@ -1,28 +1,21 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Integration base contract, modeled on Sentry's integration registry
|
|
3
|
-
* Python SDK's `Integration` ABC.
|
|
2
|
+
* Integration base contract, modeled on Sentry's integration registry.
|
|
4
3
|
*
|
|
5
|
-
* An {@link Integration} knows how to wire one framework (
|
|
6
|
-
*
|
|
4
|
+
* An {@link Integration} knows how to wire one framework (currently Pi) into
|
|
5
|
+
* the shared Introspection trace pipeline. `init()`
|
|
7
6
|
* discovers the integrations whose framework is importable and runs each
|
|
8
7
|
* `setupOnce()` exactly once.
|
|
9
8
|
*/
|
|
10
9
|
export const OPTIONAL_PEERS = {
|
|
11
|
-
anthropic: "@anthropic-ai/sdk",
|
|
12
|
-
claudeAgent: "@anthropic-ai/claude-agent-sdk",
|
|
13
|
-
gemini: "@google/genai",
|
|
14
|
-
langchainCallbacks: "@langchain/core/callbacks/base",
|
|
15
|
-
mastraObservability: "@mastra/observability",
|
|
16
|
-
openaiAgents: "@openai/agents",
|
|
17
10
|
piAgentCore: "@earendil-works/pi-agent-core",
|
|
18
|
-
vercelAi: "ai",
|
|
19
11
|
};
|
|
20
12
|
/**
|
|
21
13
|
* Thrown by an integration module/`setupOnce` when the framework cannot be
|
|
22
14
|
* activated (package missing, version too old, …).
|
|
23
15
|
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
16
|
+
* Always swallowed by `setupIntegrations`, whether the integration was
|
|
17
|
+
* auto-discovered or requested explicitly — a framework that cannot activate
|
|
18
|
+
* skips its shim. Any other error propagates.
|
|
26
19
|
*/
|
|
27
20
|
export class DidNotEnable extends Error {
|
|
28
21
|
constructor(message) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base.js","sourceRoot":"","sources":["../../../src/otel/integrations/base.ts"],"names":[],"mappings":"AAAA
|
|
1
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ACd,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,IAAI,CAAC,YAAY,YAAY;YAAE,OAAO,KAAK,CAAC;QAC5C,MAAM,CAAC,CAAC;IACV,CAAC;AACH,CAAC"}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Integration discovery + setup loader for `introspection.init()`.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* once per identifier per process, and an integration may `deactivate` others.
|
|
4
|
+
* Built-in integrations are resolved lazily (a missing framework just skips
|
|
5
|
+
* its shim) and `setupOnce` runs at most once per identifier per process.
|
|
7
6
|
*/
|
|
8
7
|
import { DidNotEnable, isModuleNotFound, type Integration, type IntegrationHandles, type IntegrationSetupContext } from "./base.js";
|
|
9
8
|
export { DidNotEnable, isModuleNotFound };
|
|
@@ -17,7 +16,7 @@ export type { Integration, IntegrationHandles, IntegrationSetupContext };
|
|
|
17
16
|
*/
|
|
18
17
|
export declare function discoverIntegrations(): Promise<Integration[]>;
|
|
19
18
|
/**
|
|
20
|
-
* Run each integration's `setupOnce` once
|
|
19
|
+
* Run each integration's `setupOnce` exactly once.
|
|
21
20
|
*
|
|
22
21
|
* @returns the set of identifiers installed so far this process.
|
|
23
22
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/otel/integrations/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/otel/integrations/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EACL,YAAY,EACZ,gBAAgB,EAChB,KAAK,WAAW,EAChB,KAAK,kBAAkB,EACvB,KAAK,uBAAuB,EAC7B,MAAM,WAAW,CAAC;AAEnB,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,CAAC;AAC1C,YAAY,EAAE,WAAW,EAAE,kBAAkB,EAAE,uBAAuB,EAAE,CAAC;AA+BzE;;;;;;GAMG;AACH,wBAAsB,oBAAoB,IAAI,OAAO,CAAC,WAAW,EAAE,CAAC,CAmBnE;AAED;;;;GAIG;AACH,wBAAsB,iBAAiB,CACrC,YAAY,EAAE,WAAW,EAAE,EAC3B,GAAG,EAAE,uBAAuB,GAC3B,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAyBtB;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,IAAI,IAAI,CAS3C;AAED,uEAAuE;AACvE,wBAAgB,sBAAsB,IAAI,IAAI,CAE7C"}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Integration discovery + setup loader for `introspection.init()`.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* once per identifier per process, and an integration may `deactivate` others.
|
|
4
|
+
* Built-in integrations are resolved lazily (a missing framework just skips
|
|
5
|
+
* its shim) and `setupOnce` runs at most once per identifier per process.
|
|
7
6
|
*/
|
|
8
7
|
import { logger } from "../../utils.js";
|
|
9
8
|
import { DidNotEnable, isModuleNotFound, } from "./base.js";
|
|
@@ -13,19 +12,10 @@ export { DidNotEnable, isModuleNotFound };
|
|
|
13
12
|
* framework package at runtime, so importing the OTel barrel never requires
|
|
14
13
|
* every optional framework SDK to be installed.
|
|
15
14
|
*/
|
|
16
|
-
const BUILTIN_INTEGRATIONS = [
|
|
17
|
-
() => import("./anthropic.js"),
|
|
18
|
-
() => import("./gemini.js"),
|
|
19
|
-
() => import("./openai-agents.js"),
|
|
20
|
-
() => import("./vercel.js"),
|
|
21
|
-
() => import("./claude-agent.js"),
|
|
22
|
-
() => import("./langchain.js"),
|
|
23
|
-
() => import("./mastra.js"),
|
|
24
|
-
() => import("./pi.js"),
|
|
25
|
-
];
|
|
15
|
+
const BUILTIN_INTEGRATIONS = [() => import("./pi.js")];
|
|
26
16
|
const installed = new Set();
|
|
27
|
-
// Teardown callbacks returned by integration setupOnce (e.g.
|
|
28
|
-
//
|
|
17
|
+
// Teardown callbacks returned by integration setupOnce (e.g. detach a
|
|
18
|
+
// framework hook), run by teardownIntegrations() on shutdown.
|
|
29
19
|
const teardowns = [];
|
|
30
20
|
async function availableIntegrations(integrations) {
|
|
31
21
|
const available = [];
|
|
@@ -64,7 +54,7 @@ export async function discoverIntegrations() {
|
|
|
64
54
|
return availableIntegrations(found);
|
|
65
55
|
}
|
|
66
56
|
/**
|
|
67
|
-
* Run each integration's `setupOnce` once
|
|
57
|
+
* Run each integration's `setupOnce` exactly once.
|
|
68
58
|
*
|
|
69
59
|
* @returns the set of identifiers installed so far this process.
|
|
70
60
|
*/
|
|
@@ -76,16 +66,7 @@ export async function setupIntegrations(integrations, ctx) {
|
|
|
76
66
|
byId.set(integration.identifier, integration);
|
|
77
67
|
}
|
|
78
68
|
}
|
|
79
|
-
const disabled = new Set();
|
|
80
|
-
for (const integration of byId.values()) {
|
|
81
|
-
for (const id of integration.deactivates ?? [])
|
|
82
|
-
disabled.add(id);
|
|
83
|
-
}
|
|
84
69
|
for (const [identifier, integration] of byId) {
|
|
85
|
-
if (disabled.has(identifier)) {
|
|
86
|
-
logger.debug(`Skipping ${identifier} (deactivated by another integration)`);
|
|
87
|
-
continue;
|
|
88
|
-
}
|
|
89
70
|
if (installed.has(identifier))
|
|
90
71
|
continue;
|
|
91
72
|
try {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/otel/integrations/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/otel/integrations/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AACxC,OAAO,EACL,YAAY,EACZ,gBAAgB,GAIjB,MAAM,WAAW,CAAC;AAEnB,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,CAAC;AAG1C;;;;GAIG;AACH,MAAM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ACX,MAAM,CAAC,KAAK,CAAC,mCAAmC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;QAC/D,CAAC;IACH,CAAC;IACD,SAAS,CAAC,KAAK,EAAE,CAAC;AACpB,CAAC;AAED,uEAAuE;AACvE,MAAM,UAAU,sBAAsB;IACpC,oBAAoB,EAAE,CAAC;AACzB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pi.d.ts","sourceRoot":"","sources":["../../../src/otel/integrations/pi.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,EAIL,KAAK,WAAW,EACjB,MAAM,WAAW,CAAC;AAEnB,QAAA,MAAM,WAAW,EAAE,
|
|
1
|
+
{"version":3,"file":"pi.d.ts","sourceRoot":"","sources":["../../../src/otel/integrations/pi.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,EAIL,KAAK,WAAW,EACjB,MAAM,WAAW,CAAC;AAEnB,QAAA,MAAM,WAAW,EAAE,WAiBlB,CAAC;AAEF,eAAe,WAAW,CAAC"}
|
|
@@ -14,7 +14,15 @@ const integration = {
|
|
|
14
14
|
await importOptionalPeer(OPTIONAL_PEERS.piAgentCore);
|
|
15
15
|
// The instrumentor emits onto the global tracer, which `init()` has just
|
|
16
16
|
// registered with the shared IntrospectionSpanProcessor.
|
|
17
|
-
|
|
17
|
+
const instrumentor = new IntrospectionPiInstrumentor();
|
|
18
|
+
handles.piInstrumentor = instrumentor;
|
|
19
|
+
// Returning the teardown is what makes `introspection.shutdown()` reach
|
|
20
|
+
// the instrumentor. Without it, open `execute_tool` spans stayed open and
|
|
21
|
+
// instrumented agents kept emitting onto a shut-down provider.
|
|
22
|
+
return () => {
|
|
23
|
+
instrumentor.stop();
|
|
24
|
+
handles.piInstrumentor = undefined;
|
|
25
|
+
};
|
|
18
26
|
},
|
|
19
27
|
};
|
|
20
28
|
export default integration;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pi.js","sourceRoot":"","sources":["../../../src/otel/integrations/pi.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,2BAA2B,EAAE,MAAM,UAAU,CAAC;AACvD,OAAO,EACL,kBAAkB,EAClB,uBAAuB,EACvB,cAAc,GAEf,MAAM,WAAW,CAAC;AAEnB,MAAM,WAAW,GAAgB;IAC/B,UAAU,EAAE,IAAI;IAChB,WAAW,EAAE,GAAG,EAAE,CAAC,uBAAuB,CAAC,cAAc,CAAC,WAAW,CAAC;IACtE,KAAK,CAAC,SAAS,CAAC,EAAE,OAAO,EAAE;QACzB,MAAM,kBAAkB,CAAC,cAAc,CAAC,WAAW,CAAC,CAAC;QACrD,yEAAyE;QACzE,yDAAyD;QACzD,OAAO,CAAC,cAAc,GAAG,
|
|
1
|
+
{"version":3,"file":"pi.js","sourceRoot":"","sources":["../../../src/otel/integrations/pi.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,2BAA2B,EAAE,MAAM,UAAU,CAAC;AACvD,OAAO,EACL,kBAAkB,EAClB,uBAAuB,EACvB,cAAc,GAEf,MAAM,WAAW,CAAC;AAEnB,MAAM,WAAW,GAAgB;IAC/B,UAAU,EAAE,IAAI;IAChB,WAAW,EAAE,GAAG,EAAE,CAAC,uBAAuB,CAAC,cAAc,CAAC,WAAW,CAAC;IACtE,KAAK,CAAC,SAAS,CAAC,EAAE,OAAO,EAAE;QACzB,MAAM,kBAAkB,CAAC,cAAc,CAAC,WAAW,CAAC,CAAC;QACrD,yEAAyE;QACzE,yDAAyD;QACzD,MAAM,YAAY,GAAG,IAAI,2BAA2B,EAAE,CAAC;QACvD,OAAO,CAAC,cAAc,GAAG,YAAY,CAAC;QACtC,wEAAwE;QACxE,0EAA0E;QAC1E,+DAA+D;QAC/D,OAAO,GAAG,EAAE;YACV,YAAY,CAAC,IAAI,EAAE,CAAC;YACpB,OAAO,CAAC,cAAc,GAAG,SAAS,CAAC;QACrC,CAAC,CAAC;IACJ,CAAC;CACF,CAAC;AAEF,eAAe,WAAW,CAAC"}
|
package/dist/otel/logs.d.ts
CHANGED
|
@@ -27,6 +27,7 @@
|
|
|
27
27
|
* await logs.shutdown();
|
|
28
28
|
* ```
|
|
29
29
|
*/
|
|
30
|
+
import { type LogRecordExporter } from "@opentelemetry/sdk-logs";
|
|
30
31
|
import { type FeedbackOptions, type UserTraits } from "../types.js";
|
|
31
32
|
/**
|
|
32
33
|
* Configuration for {@link IntrospectionLogs}.
|
|
@@ -45,19 +46,44 @@ export interface IntrospectionLogsOptions {
|
|
|
45
46
|
additionalHeaders?: Record<string, string>;
|
|
46
47
|
/** Flush interval in milliseconds (default: 5000). */
|
|
47
48
|
flushInterval?: number;
|
|
48
|
-
/** Maximum
|
|
49
|
+
/** Maximum export batch size (default: 100). */
|
|
49
50
|
maxBatchSize?: number;
|
|
51
|
+
/**
|
|
52
|
+
* Maximum records buffered before new ones are dropped. Omit to keep the
|
|
53
|
+
* OTel SDK's default. See {@link AdvancedOptions.maxQueueSize}.
|
|
54
|
+
*/
|
|
55
|
+
maxQueueSize?: number;
|
|
56
|
+
/**
|
|
57
|
+
* How long one export may take before it is abandoned, in milliseconds.
|
|
58
|
+
* Omit to keep the OTel SDK's default.
|
|
59
|
+
*/
|
|
60
|
+
exportTimeoutMillis?: number;
|
|
61
|
+
/**
|
|
62
|
+
* Custom log record exporter, bypassing OTLP construction.
|
|
63
|
+
*
|
|
64
|
+
* The analytics stream is the contract that has to match across SDKs, and
|
|
65
|
+
* this is the seam for asserting what goes out on it. Matches the Python
|
|
66
|
+
* SDK's `log_exporter` constructor argument, the Rust config's
|
|
67
|
+
* `log_exporter`, and the browser client's `advanced.logExporter`.
|
|
68
|
+
*/
|
|
69
|
+
logExporter?: LogRecordExporter;
|
|
50
70
|
}
|
|
51
71
|
export declare class IntrospectionLogs {
|
|
52
72
|
private loggerProvider;
|
|
53
73
|
private otelLogger;
|
|
54
|
-
private userId;
|
|
55
|
-
private anonymousId;
|
|
56
|
-
private traits;
|
|
57
74
|
constructor(options?: IntrospectionLogsOptions);
|
|
58
75
|
/** Get gen_ai context from baggage */
|
|
59
76
|
private getGenAiFromContext;
|
|
60
|
-
/**
|
|
77
|
+
/**
|
|
78
|
+
* Get identity from baggage.
|
|
79
|
+
*
|
|
80
|
+
* Baggage only, deliberately. This used to fall back to `userId` /
|
|
81
|
+
* `anonymousId` held on the instance, but `init()` builds one instance per
|
|
82
|
+
* process: under any concurrency, the identity of whichever request called
|
|
83
|
+
* `identify()` last attached itself to every other request's events. Scope
|
|
84
|
+
* identity with {@link withUserId} / {@link withAnonymousId} instead, which
|
|
85
|
+
* carry it on the async context where it belongs.
|
|
86
|
+
*/
|
|
61
87
|
private getIdentityFromContext;
|
|
62
88
|
private getTimestamp;
|
|
63
89
|
private buildAttributes;
|
|
@@ -65,17 +91,24 @@ export declare class IntrospectionLogs {
|
|
|
65
91
|
eventId?: string;
|
|
66
92
|
}): void;
|
|
67
93
|
feedback(name: string, options?: FeedbackOptions): void;
|
|
94
|
+
/**
|
|
95
|
+
* Emit an `identify` event associating `userId` with `traits`.
|
|
96
|
+
*
|
|
97
|
+
* The identity lands on this event only. It does not persist onto later
|
|
98
|
+
* `track` / `feedback` calls — wrap those in {@link withUserId} (or set the
|
|
99
|
+
* baggage yourself) to scope identity across several events.
|
|
100
|
+
*/
|
|
68
101
|
identify(userId: string, traits?: UserTraits, anonymousId?: string, eventId?: string): void;
|
|
69
102
|
createBaggageContext(values: Record<string, string>): import("@opentelemetry/api").Context;
|
|
70
103
|
withBaggage<T>(values: Record<string, string>, callback: () => T | Promise<T>): Promise<T>;
|
|
71
104
|
withAgent<T>(agentName: string, agentId: string | undefined, callback: () => T | Promise<T>): Promise<T>;
|
|
72
105
|
withConversation<T>(conversationId: string | undefined, previousResponseId: string | undefined, callback: () => T | Promise<T>): Promise<T>;
|
|
73
|
-
setUserId(userId: string): void;
|
|
74
|
-
setAnonymousId(anonymousId: string): void;
|
|
75
106
|
withUserId<T>(userId: string, callback: () => T | Promise<T>): Promise<T>;
|
|
76
107
|
withAnonymousId<T>(anonymousId: string, callback: () => T | Promise<T>): Promise<T>;
|
|
108
|
+
/** The user id on the current async context, if one is scoped. */
|
|
109
|
+
getUserId(): string | undefined;
|
|
110
|
+
/** The anonymous id on the current async context, if one is scoped. */
|
|
77
111
|
getAnonymousId(): string | undefined;
|
|
78
|
-
reset(): void;
|
|
79
112
|
flush(): Promise<void>;
|
|
80
113
|
shutdown(): Promise<void>;
|
|
81
114
|
}
|