langwatch 1.19.0 → 2.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/README.md +27 -13
- package/dist/agent/index.d.mts +122 -79
- package/dist/agent/index.d.ts +122 -79
- package/dist/agent/index.js +541 -301
- package/dist/agent/index.js.map +1 -1
- package/dist/agent/index.mjs +540 -302
- package/dist/agent/index.mjs.map +1 -1
- package/dist/{chunk-NPEK4RSD.mjs → chunk-2GKEMCKT.mjs} +7757 -2409
- package/dist/chunk-2GKEMCKT.mjs.map +1 -0
- package/dist/chunk-5VYEG3RS.js +117 -0
- package/dist/chunk-5VYEG3RS.js.map +1 -0
- package/dist/chunk-AYPQNLCC.mjs +852 -0
- package/dist/chunk-AYPQNLCC.mjs.map +1 -0
- package/dist/chunk-BL3GHEKF.js +59 -0
- package/dist/chunk-BL3GHEKF.js.map +1 -0
- package/dist/chunk-C7IWJ2GJ.mjs +59 -0
- package/dist/chunk-C7IWJ2GJ.mjs.map +1 -0
- package/dist/chunk-DLZCOUXC.js +852 -0
- package/dist/chunk-DLZCOUXC.js.map +1 -0
- package/dist/{chunk-O4J3ZPZY.js → chunk-F7BVJW3S.js} +7912 -2564
- package/dist/chunk-F7BVJW3S.js.map +1 -0
- package/dist/{chunk-SY5HSL5G.mjs → chunk-M3DSPR5S.mjs} +124 -112
- package/dist/chunk-M3DSPR5S.mjs.map +1 -0
- package/dist/{chunk-CSV7B7B5.js → chunk-MAO3SIBB.js} +141 -129
- package/dist/chunk-MAO3SIBB.js.map +1 -0
- package/dist/{chunk-LCG5Y2EG.js → chunk-N76BG37W.js} +15 -101
- package/dist/chunk-N76BG37W.js.map +1 -0
- package/dist/chunk-SERULD4Z.mjs +117 -0
- package/dist/chunk-SERULD4Z.mjs.map +1 -0
- package/dist/{chunk-73QOHSHU.js → chunk-WDUUAIG3.js} +2 -2
- package/dist/chunk-WDUUAIG3.js.map +1 -0
- package/dist/{chunk-WMDQVWA6.mjs → chunk-WSGVZ3J2.mjs} +22 -108
- package/dist/chunk-WSGVZ3J2.mjs.map +1 -0
- package/dist/{chunk-57L2K66L.mjs → chunk-XQ4CP2JK.mjs} +2 -2
- package/dist/chunk-XQ4CP2JK.mjs.map +1 -0
- package/dist/cli/bundle.js +853 -552
- package/dist/implementation-BXVPzwOt.d.mts +261 -0
- package/dist/implementation-DJ-JveZl.d.ts +261 -0
- package/dist/index.d.mts +479 -1130
- package/dist/index.d.ts +479 -1130
- package/dist/index.js +7908 -3525
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +7883 -3500
- package/dist/index.mjs.map +1 -1
- package/dist/observability-sdk/index.d.mts +16 -76
- package/dist/observability-sdk/index.d.ts +16 -76
- package/dist/observability-sdk/index.js +8 -5
- package/dist/observability-sdk/index.js.map +1 -1
- package/dist/observability-sdk/index.mjs +13 -10
- package/dist/observability-sdk/instrumentation/langchain/index.d.mts +3 -5
- package/dist/observability-sdk/instrumentation/langchain/index.d.ts +3 -5
- package/dist/observability-sdk/instrumentation/langchain/index.js +160 -112
- package/dist/observability-sdk/instrumentation/langchain/index.js.map +1 -1
- package/dist/observability-sdk/instrumentation/langchain/index.mjs +148 -100
- package/dist/observability-sdk/instrumentation/langchain/index.mjs.map +1 -1
- package/dist/observability-sdk/semconv/index.d.mts +37 -0
- package/dist/observability-sdk/semconv/index.d.ts +37 -0
- package/dist/observability-sdk/semconv/index.js +121 -0
- package/dist/observability-sdk/semconv/index.js.map +1 -0
- package/dist/observability-sdk/semconv/index.mjs +121 -0
- package/dist/observability-sdk/semconv/index.mjs.map +1 -0
- package/dist/observability-sdk/setup/node/index.d.mts +73 -313
- package/dist/observability-sdk/setup/node/index.d.ts +73 -313
- package/dist/observability-sdk/setup/node/index.js +6 -4
- package/dist/observability-sdk/setup/node/index.js.map +1 -1
- package/dist/observability-sdk/setup/node/index.mjs +5 -3
- package/dist/types--ExXvd26.d.mts +16583 -0
- package/dist/{types-VOZv9LYO.d.ts → types-CoS5PmeU.d.mts} +22 -59
- package/dist/{types-VOZv9LYO.d.mts → types-CoS5PmeU.d.ts} +22 -59
- package/dist/types-CpT3iEIj.d.ts +16583 -0
- package/dist/{types-DLfhJb38.d.mts → types-RkiBQZ9j.d.mts} +1 -6
- package/dist/{types-DLfhJb38.d.ts → types-RkiBQZ9j.d.ts} +1 -6
- package/dist/values-1yj9l0Sa.d.mts +112 -0
- package/dist/values-1yj9l0Sa.d.ts +112 -0
- package/package.json +94 -64
- package/dist/chunk-57L2K66L.mjs.map +0 -1
- package/dist/chunk-73QOHSHU.js.map +0 -1
- package/dist/chunk-CSV7B7B5.js.map +0 -1
- package/dist/chunk-LCG5Y2EG.js.map +0 -1
- package/dist/chunk-NPEK4RSD.mjs.map +0 -1
- package/dist/chunk-O4J3ZPZY.js.map +0 -1
- package/dist/chunk-PIYOJF6V.mjs +0 -566
- package/dist/chunk-PIYOJF6V.mjs.map +0 -1
- package/dist/chunk-SY5HSL5G.mjs.map +0 -1
- package/dist/chunk-WGLVIV4J.js +0 -566
- package/dist/chunk-WGLVIV4J.js.map +0 -1
- package/dist/chunk-WMDQVWA6.mjs.map +0 -1
- package/dist/implementation-CeTvnq6e.d.mts +0 -716
- package/dist/implementation-CsQrexpY.d.ts +0 -716
- package/dist/types-ofe1fAYQ.d.mts +0 -38143
- package/dist/types-wuYJPoFb.d.ts +0 -38143
|
@@ -0,0 +1,261 @@
|
|
|
1
|
+
import { BatchSpanProcessor, SpanExporter, ReadableSpan } from '@opentelemetry/sdk-trace-base';
|
|
2
|
+
import { ExportResult } from '@opentelemetry/core';
|
|
3
|
+
import { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-proto';
|
|
4
|
+
import { CompressionAlgorithm } from '@opentelemetry/otlp-exporter-base';
|
|
5
|
+
import { Logger, LogRecord, LoggerProvider } from '@opentelemetry/api-logs';
|
|
6
|
+
import { V as VAL_GEN_AI_SYSTEMS, a as VAL_GEN_AI_FINISH_REASONS } from './values-1yj9l0Sa.mjs';
|
|
7
|
+
import { b as SemConvLogRecordAttributes, a as SemConvAttributes } from './types-CoS5PmeU.mjs';
|
|
8
|
+
import { TracerProvider } from '@opentelemetry/api';
|
|
9
|
+
import { j as LangWatchTracer } from './types--ExXvd26.mjs';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* A BatchSpanProcessor subclass that filters spans before export by
|
|
13
|
+
* configurable rules -- spans matching any exclude rule are dropped.
|
|
14
|
+
* @module filterable-batch-span-exporter
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* A rule for excluding spans from export, matched on `fieldName` by
|
|
19
|
+
* `matchOperation` against `matchValue`.
|
|
20
|
+
*/
|
|
21
|
+
interface SpanProcessingExcludeRule {
|
|
22
|
+
fieldName: "span_name" | "instrumentation_scope_name";
|
|
23
|
+
matchValue: string;
|
|
24
|
+
matchOperation: "includes" | "exact_match" | "starts_with" | "ends_with";
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* A BatchSpanProcessor that filters out spans matching any exclude rule
|
|
28
|
+
* before export — useful for dropping noisy spans like health checks.
|
|
29
|
+
*/
|
|
30
|
+
declare class FilterableBatchSpanProcessor extends BatchSpanProcessor {
|
|
31
|
+
private readonly _filters;
|
|
32
|
+
/**
|
|
33
|
+
* Create a new FilterableBatchSpanProcessor.
|
|
34
|
+
*
|
|
35
|
+
* @param exporter - The underlying SpanExporter to use for exporting spans.
|
|
36
|
+
* @param filters - An array of rules for excluding spans from export.
|
|
37
|
+
*/
|
|
38
|
+
constructor(exporter: SpanExporter, filters: SpanProcessingExcludeRule[]);
|
|
39
|
+
/**
|
|
40
|
+
* Called when a span ends. If the span matches any exclude rule, it is dropped and not exported.
|
|
41
|
+
*
|
|
42
|
+
* @param span - The ReadableSpan that has ended.
|
|
43
|
+
*/
|
|
44
|
+
onEnd(span: ReadableSpan): void;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
interface Criteria {
|
|
48
|
+
instrumentationScopeName?: Match[];
|
|
49
|
+
name?: Match[];
|
|
50
|
+
}
|
|
51
|
+
interface Match {
|
|
52
|
+
equals?: string;
|
|
53
|
+
startsWith?: string;
|
|
54
|
+
matches?: RegExp;
|
|
55
|
+
ignoreCase?: boolean;
|
|
56
|
+
}
|
|
57
|
+
type TraceFilter = {
|
|
58
|
+
preset: "vercelAIOnly" | "excludeHttpRequests";
|
|
59
|
+
} | {
|
|
60
|
+
include: Criteria;
|
|
61
|
+
} | {
|
|
62
|
+
exclude: Criteria;
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
/** Options: endpoint URL, API key for auth, and optional span filters (default excludes HTTP). */
|
|
66
|
+
interface LangWatchTraceExporterOptions {
|
|
67
|
+
endpoint?: string;
|
|
68
|
+
apiKey?: string;
|
|
69
|
+
/**
|
|
70
|
+
* Project identifier. Required when `apiKey` is a Personal Access Token
|
|
71
|
+
* (`pat-lw-*`); ignored for legacy `sk-lw-*` keys. Falls back to
|
|
72
|
+
* `LANGWATCH_PROJECT_ID`.
|
|
73
|
+
*/
|
|
74
|
+
projectId?: string;
|
|
75
|
+
filters?: TraceFilter[] | null;
|
|
76
|
+
/** Request compression: gzip unless an OTEL_EXPORTER_OTLP_*COMPRESSION env var is set. */
|
|
77
|
+
compression?: CompressionAlgorithm;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/** Sends traces to LangWatch with auth; applies span filters (default excludes HTTP). */
|
|
81
|
+
declare class LangWatchTraceExporter extends OTLPTraceExporter {
|
|
82
|
+
private readonly filters;
|
|
83
|
+
/** Configures auth from opts or environment; applies filters to span stream. */
|
|
84
|
+
constructor(opts?: LangWatchTraceExporterOptions);
|
|
85
|
+
export(spans: ReadableSpan[], resultCallback: (result: ExportResult) => void): void;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/** Body for a system message event in a GenAI span (a system/instruction to the model). */
|
|
89
|
+
interface LangWatchSpanGenAISystemMessageEventBody {
|
|
90
|
+
/** Content of the system message */
|
|
91
|
+
content?: string;
|
|
92
|
+
/** Role of the message (system or instruction) */
|
|
93
|
+
role?: "system" | "instruction";
|
|
94
|
+
}
|
|
95
|
+
/** Body for a user message event in a GenAI span (a user/customer message to the model). */
|
|
96
|
+
interface LangWatchSpanGenAIUserMessageEventBody {
|
|
97
|
+
/** Content of the user message */
|
|
98
|
+
content?: string;
|
|
99
|
+
/** Role of the message (user or customer) */
|
|
100
|
+
role?: "user" | "customer";
|
|
101
|
+
}
|
|
102
|
+
/** Body for an assistant message event in a GenAI span (a response, including tool calls). */
|
|
103
|
+
interface LangWatchSpanGenAIAssistantMessageEventBody {
|
|
104
|
+
/** Content of the assistant message */
|
|
105
|
+
content?: string;
|
|
106
|
+
/** Role of the message (assistant or bot) */
|
|
107
|
+
role?: "assistant" | "bot";
|
|
108
|
+
/** Tool calls made by the assistant */
|
|
109
|
+
tool_calls?: {
|
|
110
|
+
function: {
|
|
111
|
+
/** Name of the function called */
|
|
112
|
+
name: string;
|
|
113
|
+
/** Arguments passed to the function */
|
|
114
|
+
arguments?: string;
|
|
115
|
+
};
|
|
116
|
+
/** Tool call identifier */
|
|
117
|
+
id: string;
|
|
118
|
+
/** Type of tool call */
|
|
119
|
+
type: "function";
|
|
120
|
+
}[];
|
|
121
|
+
}
|
|
122
|
+
/** Body for a tool message event in a GenAI span (a message from a tool the assistant invoked). */
|
|
123
|
+
interface LangWatchSpanGenAIToolMessageEventBody {
|
|
124
|
+
/** Content of the tool message */
|
|
125
|
+
content?: string;
|
|
126
|
+
/** Tool call identifier */
|
|
127
|
+
id: string;
|
|
128
|
+
/** Role of the message (tool or function) */
|
|
129
|
+
role?: "tool" | "function";
|
|
130
|
+
}
|
|
131
|
+
/** Body for a choice event in a GenAI span (a model output choice, finish reason and message). */
|
|
132
|
+
interface LangWatchSpanGenAIChoiceEventBody {
|
|
133
|
+
/** Reason the generation finished */
|
|
134
|
+
finish_reason: VAL_GEN_AI_FINISH_REASONS | (string & {});
|
|
135
|
+
/** Index of the choice */
|
|
136
|
+
index: number;
|
|
137
|
+
/** Message content for the choice */
|
|
138
|
+
message?: {
|
|
139
|
+
/** Content of the message */
|
|
140
|
+
content?: string;
|
|
141
|
+
/** Role of the message (assistant or bot) */
|
|
142
|
+
role?: "assistant" | "bot";
|
|
143
|
+
/** Tool calls made by the assistant */
|
|
144
|
+
tool_calls?: {
|
|
145
|
+
function: {
|
|
146
|
+
/** Name of the function called */
|
|
147
|
+
name: string;
|
|
148
|
+
/** Arguments passed to the function */
|
|
149
|
+
arguments?: string;
|
|
150
|
+
};
|
|
151
|
+
/** Tool call identifier */
|
|
152
|
+
id: string;
|
|
153
|
+
/** Type of tool call */
|
|
154
|
+
type: "function";
|
|
155
|
+
}[];
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Extension of OpenTelemetry's LogRecord with LangWatch and GenAI-specific attributes.
|
|
160
|
+
*/
|
|
161
|
+
interface LangWatchLogRecord extends LogRecord {
|
|
162
|
+
/**
|
|
163
|
+
* Additional attributes to add to the log record.
|
|
164
|
+
*
|
|
165
|
+
* @default {}
|
|
166
|
+
*/
|
|
167
|
+
attributes?: SemConvLogRecordAttributes;
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* Options for emitting a log record.
|
|
171
|
+
*/
|
|
172
|
+
interface EmitOptions {
|
|
173
|
+
/**
|
|
174
|
+
* Whether to omit the OTel context from the log record — standard OpenTelemetry
|
|
175
|
+
* omits it by default, so set this to avoid attaching context to every record.
|
|
176
|
+
* @default false
|
|
177
|
+
*/
|
|
178
|
+
excludeContext?: boolean;
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Extension of OpenTelemetry's Logger with LangWatch and GenAI-specific methods.
|
|
182
|
+
*/
|
|
183
|
+
interface LangWatchLogger extends Logger {
|
|
184
|
+
/**
|
|
185
|
+
* Emit a log record with LangWatch and GenAI-specific attributes.
|
|
186
|
+
*
|
|
187
|
+
* @param logRecord - The log record to emit
|
|
188
|
+
* @param options - Optional options for emitting the log record
|
|
189
|
+
*/
|
|
190
|
+
emit(logRecord: LangWatchLogRecord, options?: EmitOptions): void;
|
|
191
|
+
/**
|
|
192
|
+
* Emit a GenAI system/instruction message event to the logger.
|
|
193
|
+
* @param body - The event body (content and role)
|
|
194
|
+
* @param system - The GenAI system (optional, e.g., 'openai', 'anthropic')
|
|
195
|
+
* @param attributes - Additional OpenTelemetry attributes (optional)
|
|
196
|
+
* @returns this
|
|
197
|
+
*/
|
|
198
|
+
emitGenAISystemMessageEvent(body: LangWatchSpanGenAISystemMessageEventBody, system?: VAL_GEN_AI_SYSTEMS | (string & {}), attributes?: SemConvAttributes): void;
|
|
199
|
+
/**
|
|
200
|
+
* Emit a GenAI user/customer message event to the logger.
|
|
201
|
+
* @param body - The event body (content and role)
|
|
202
|
+
* @param system - The GenAI system (optional)
|
|
203
|
+
* @param attributes - Additional OpenTelemetry attributes (optional)
|
|
204
|
+
* @returns this
|
|
205
|
+
*/
|
|
206
|
+
emitGenAIUserMessageEvent(body: LangWatchSpanGenAIUserMessageEventBody, system?: VAL_GEN_AI_SYSTEMS | (string & {}), attributes?: SemConvAttributes): void;
|
|
207
|
+
/**
|
|
208
|
+
* Emit a GenAI assistant/bot message event to the logger (including tool calls, if any).
|
|
209
|
+
* @param body - The event body (content, role, tool_calls)
|
|
210
|
+
* @param system - The GenAI system (optional)
|
|
211
|
+
* @param attributes - Additional OpenTelemetry attributes (optional)
|
|
212
|
+
* @returns this
|
|
213
|
+
*/
|
|
214
|
+
emitGenAIAssistantMessageEvent(body: LangWatchSpanGenAIAssistantMessageEventBody, system?: VAL_GEN_AI_SYSTEMS | (string & {}), attributes?: SemConvAttributes): void;
|
|
215
|
+
/**
|
|
216
|
+
* Emit a GenAI tool/function message event to the logger (from a tool the assistant invoked).
|
|
217
|
+
* @param body - The event body (content, id, role)
|
|
218
|
+
* @param system - The GenAI system (optional)
|
|
219
|
+
* @param attributes - Additional OpenTelemetry attributes (optional)
|
|
220
|
+
* @returns this
|
|
221
|
+
*/
|
|
222
|
+
emitGenAIToolMessageEvent(body: LangWatchSpanGenAIToolMessageEventBody, system?: VAL_GEN_AI_SYSTEMS | (string & {}), attributes?: SemConvAttributes): void;
|
|
223
|
+
/**
|
|
224
|
+
* Emit a GenAI choice event to the logger (a model output choice, finish reason, message).
|
|
225
|
+
* @param body - The event body (finish_reason, index, message)
|
|
226
|
+
* @param system - The GenAI system (optional)
|
|
227
|
+
* @param attributes - Additional OpenTelemetry attributes (optional)
|
|
228
|
+
* @returns this
|
|
229
|
+
*/
|
|
230
|
+
emitGenAIChoiceEvent(body: LangWatchSpanGenAIChoiceEventBody, system?: VAL_GEN_AI_SYSTEMS | (string & {}), attributes?: SemConvAttributes): void;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
/**
|
|
234
|
+
* @param name - The logger name (typically your service or module name).
|
|
235
|
+
* @param version - Optional logger version.
|
|
236
|
+
* @returns A {@link LangWatchLogger} instance, or a no-op logger if no provider was set.
|
|
237
|
+
*/
|
|
238
|
+
declare function getLangWatchLogger(name: string, version?: string): LangWatchLogger;
|
|
239
|
+
/**
|
|
240
|
+
* @param loggerProvider - The OpenTelemetry logger provider to use.
|
|
241
|
+
* @param name - The name of the logger.
|
|
242
|
+
* @param version - Optional logger version.
|
|
243
|
+
* @returns A {@link LangWatchLogger} instance.
|
|
244
|
+
*/
|
|
245
|
+
declare function getLangWatchLoggerFromProvider(loggerProvider: LoggerProvider, name: string, version?: string): LangWatchLogger;
|
|
246
|
+
|
|
247
|
+
/**
|
|
248
|
+
* @param name - Tracer name (service or library)
|
|
249
|
+
* @param version - Optional version identifier
|
|
250
|
+
* @returns A LangWatch tracer with enhanced functionality
|
|
251
|
+
*/
|
|
252
|
+
declare function getLangWatchTracer(name: string, version?: string): LangWatchTracer;
|
|
253
|
+
/**
|
|
254
|
+
* @param tracerProvider - The OpenTelemetry tracer provider to use
|
|
255
|
+
* @param name - Tracer name (service or library)
|
|
256
|
+
* @param version - Optional version identifier
|
|
257
|
+
* @returns A LangWatch tracer with enhanced functionality
|
|
258
|
+
*/
|
|
259
|
+
declare function getLangWatchTracerFromProvider(tracerProvider: TracerProvider, name: string, version?: string): LangWatchTracer;
|
|
260
|
+
|
|
261
|
+
export { FilterableBatchSpanProcessor as F, LangWatchTraceExporter as L, type SpanProcessingExcludeRule as S, getLangWatchTracer as a, type LangWatchTraceExporterOptions as b, type LangWatchLogger as c, getLangWatchLoggerFromProvider as d, getLangWatchTracerFromProvider as e, getLangWatchLogger as g };
|
|
@@ -0,0 +1,261 @@
|
|
|
1
|
+
import { BatchSpanProcessor, SpanExporter, ReadableSpan } from '@opentelemetry/sdk-trace-base';
|
|
2
|
+
import { ExportResult } from '@opentelemetry/core';
|
|
3
|
+
import { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-proto';
|
|
4
|
+
import { CompressionAlgorithm } from '@opentelemetry/otlp-exporter-base';
|
|
5
|
+
import { Logger, LogRecord, LoggerProvider } from '@opentelemetry/api-logs';
|
|
6
|
+
import { V as VAL_GEN_AI_SYSTEMS, a as VAL_GEN_AI_FINISH_REASONS } from './values-1yj9l0Sa.js';
|
|
7
|
+
import { b as SemConvLogRecordAttributes, a as SemConvAttributes } from './types-CoS5PmeU.js';
|
|
8
|
+
import { TracerProvider } from '@opentelemetry/api';
|
|
9
|
+
import { j as LangWatchTracer } from './types-CpT3iEIj.js';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* A BatchSpanProcessor subclass that filters spans before export by
|
|
13
|
+
* configurable rules -- spans matching any exclude rule are dropped.
|
|
14
|
+
* @module filterable-batch-span-exporter
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* A rule for excluding spans from export, matched on `fieldName` by
|
|
19
|
+
* `matchOperation` against `matchValue`.
|
|
20
|
+
*/
|
|
21
|
+
interface SpanProcessingExcludeRule {
|
|
22
|
+
fieldName: "span_name" | "instrumentation_scope_name";
|
|
23
|
+
matchValue: string;
|
|
24
|
+
matchOperation: "includes" | "exact_match" | "starts_with" | "ends_with";
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* A BatchSpanProcessor that filters out spans matching any exclude rule
|
|
28
|
+
* before export — useful for dropping noisy spans like health checks.
|
|
29
|
+
*/
|
|
30
|
+
declare class FilterableBatchSpanProcessor extends BatchSpanProcessor {
|
|
31
|
+
private readonly _filters;
|
|
32
|
+
/**
|
|
33
|
+
* Create a new FilterableBatchSpanProcessor.
|
|
34
|
+
*
|
|
35
|
+
* @param exporter - The underlying SpanExporter to use for exporting spans.
|
|
36
|
+
* @param filters - An array of rules for excluding spans from export.
|
|
37
|
+
*/
|
|
38
|
+
constructor(exporter: SpanExporter, filters: SpanProcessingExcludeRule[]);
|
|
39
|
+
/**
|
|
40
|
+
* Called when a span ends. If the span matches any exclude rule, it is dropped and not exported.
|
|
41
|
+
*
|
|
42
|
+
* @param span - The ReadableSpan that has ended.
|
|
43
|
+
*/
|
|
44
|
+
onEnd(span: ReadableSpan): void;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
interface Criteria {
|
|
48
|
+
instrumentationScopeName?: Match[];
|
|
49
|
+
name?: Match[];
|
|
50
|
+
}
|
|
51
|
+
interface Match {
|
|
52
|
+
equals?: string;
|
|
53
|
+
startsWith?: string;
|
|
54
|
+
matches?: RegExp;
|
|
55
|
+
ignoreCase?: boolean;
|
|
56
|
+
}
|
|
57
|
+
type TraceFilter = {
|
|
58
|
+
preset: "vercelAIOnly" | "excludeHttpRequests";
|
|
59
|
+
} | {
|
|
60
|
+
include: Criteria;
|
|
61
|
+
} | {
|
|
62
|
+
exclude: Criteria;
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
/** Options: endpoint URL, API key for auth, and optional span filters (default excludes HTTP). */
|
|
66
|
+
interface LangWatchTraceExporterOptions {
|
|
67
|
+
endpoint?: string;
|
|
68
|
+
apiKey?: string;
|
|
69
|
+
/**
|
|
70
|
+
* Project identifier. Required when `apiKey` is a Personal Access Token
|
|
71
|
+
* (`pat-lw-*`); ignored for legacy `sk-lw-*` keys. Falls back to
|
|
72
|
+
* `LANGWATCH_PROJECT_ID`.
|
|
73
|
+
*/
|
|
74
|
+
projectId?: string;
|
|
75
|
+
filters?: TraceFilter[] | null;
|
|
76
|
+
/** Request compression: gzip unless an OTEL_EXPORTER_OTLP_*COMPRESSION env var is set. */
|
|
77
|
+
compression?: CompressionAlgorithm;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/** Sends traces to LangWatch with auth; applies span filters (default excludes HTTP). */
|
|
81
|
+
declare class LangWatchTraceExporter extends OTLPTraceExporter {
|
|
82
|
+
private readonly filters;
|
|
83
|
+
/** Configures auth from opts or environment; applies filters to span stream. */
|
|
84
|
+
constructor(opts?: LangWatchTraceExporterOptions);
|
|
85
|
+
export(spans: ReadableSpan[], resultCallback: (result: ExportResult) => void): void;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/** Body for a system message event in a GenAI span (a system/instruction to the model). */
|
|
89
|
+
interface LangWatchSpanGenAISystemMessageEventBody {
|
|
90
|
+
/** Content of the system message */
|
|
91
|
+
content?: string;
|
|
92
|
+
/** Role of the message (system or instruction) */
|
|
93
|
+
role?: "system" | "instruction";
|
|
94
|
+
}
|
|
95
|
+
/** Body for a user message event in a GenAI span (a user/customer message to the model). */
|
|
96
|
+
interface LangWatchSpanGenAIUserMessageEventBody {
|
|
97
|
+
/** Content of the user message */
|
|
98
|
+
content?: string;
|
|
99
|
+
/** Role of the message (user or customer) */
|
|
100
|
+
role?: "user" | "customer";
|
|
101
|
+
}
|
|
102
|
+
/** Body for an assistant message event in a GenAI span (a response, including tool calls). */
|
|
103
|
+
interface LangWatchSpanGenAIAssistantMessageEventBody {
|
|
104
|
+
/** Content of the assistant message */
|
|
105
|
+
content?: string;
|
|
106
|
+
/** Role of the message (assistant or bot) */
|
|
107
|
+
role?: "assistant" | "bot";
|
|
108
|
+
/** Tool calls made by the assistant */
|
|
109
|
+
tool_calls?: {
|
|
110
|
+
function: {
|
|
111
|
+
/** Name of the function called */
|
|
112
|
+
name: string;
|
|
113
|
+
/** Arguments passed to the function */
|
|
114
|
+
arguments?: string;
|
|
115
|
+
};
|
|
116
|
+
/** Tool call identifier */
|
|
117
|
+
id: string;
|
|
118
|
+
/** Type of tool call */
|
|
119
|
+
type: "function";
|
|
120
|
+
}[];
|
|
121
|
+
}
|
|
122
|
+
/** Body for a tool message event in a GenAI span (a message from a tool the assistant invoked). */
|
|
123
|
+
interface LangWatchSpanGenAIToolMessageEventBody {
|
|
124
|
+
/** Content of the tool message */
|
|
125
|
+
content?: string;
|
|
126
|
+
/** Tool call identifier */
|
|
127
|
+
id: string;
|
|
128
|
+
/** Role of the message (tool or function) */
|
|
129
|
+
role?: "tool" | "function";
|
|
130
|
+
}
|
|
131
|
+
/** Body for a choice event in a GenAI span (a model output choice, finish reason and message). */
|
|
132
|
+
interface LangWatchSpanGenAIChoiceEventBody {
|
|
133
|
+
/** Reason the generation finished */
|
|
134
|
+
finish_reason: VAL_GEN_AI_FINISH_REASONS | (string & {});
|
|
135
|
+
/** Index of the choice */
|
|
136
|
+
index: number;
|
|
137
|
+
/** Message content for the choice */
|
|
138
|
+
message?: {
|
|
139
|
+
/** Content of the message */
|
|
140
|
+
content?: string;
|
|
141
|
+
/** Role of the message (assistant or bot) */
|
|
142
|
+
role?: "assistant" | "bot";
|
|
143
|
+
/** Tool calls made by the assistant */
|
|
144
|
+
tool_calls?: {
|
|
145
|
+
function: {
|
|
146
|
+
/** Name of the function called */
|
|
147
|
+
name: string;
|
|
148
|
+
/** Arguments passed to the function */
|
|
149
|
+
arguments?: string;
|
|
150
|
+
};
|
|
151
|
+
/** Tool call identifier */
|
|
152
|
+
id: string;
|
|
153
|
+
/** Type of tool call */
|
|
154
|
+
type: "function";
|
|
155
|
+
}[];
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Extension of OpenTelemetry's LogRecord with LangWatch and GenAI-specific attributes.
|
|
160
|
+
*/
|
|
161
|
+
interface LangWatchLogRecord extends LogRecord {
|
|
162
|
+
/**
|
|
163
|
+
* Additional attributes to add to the log record.
|
|
164
|
+
*
|
|
165
|
+
* @default {}
|
|
166
|
+
*/
|
|
167
|
+
attributes?: SemConvLogRecordAttributes;
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* Options for emitting a log record.
|
|
171
|
+
*/
|
|
172
|
+
interface EmitOptions {
|
|
173
|
+
/**
|
|
174
|
+
* Whether to omit the OTel context from the log record — standard OpenTelemetry
|
|
175
|
+
* omits it by default, so set this to avoid attaching context to every record.
|
|
176
|
+
* @default false
|
|
177
|
+
*/
|
|
178
|
+
excludeContext?: boolean;
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Extension of OpenTelemetry's Logger with LangWatch and GenAI-specific methods.
|
|
182
|
+
*/
|
|
183
|
+
interface LangWatchLogger extends Logger {
|
|
184
|
+
/**
|
|
185
|
+
* Emit a log record with LangWatch and GenAI-specific attributes.
|
|
186
|
+
*
|
|
187
|
+
* @param logRecord - The log record to emit
|
|
188
|
+
* @param options - Optional options for emitting the log record
|
|
189
|
+
*/
|
|
190
|
+
emit(logRecord: LangWatchLogRecord, options?: EmitOptions): void;
|
|
191
|
+
/**
|
|
192
|
+
* Emit a GenAI system/instruction message event to the logger.
|
|
193
|
+
* @param body - The event body (content and role)
|
|
194
|
+
* @param system - The GenAI system (optional, e.g., 'openai', 'anthropic')
|
|
195
|
+
* @param attributes - Additional OpenTelemetry attributes (optional)
|
|
196
|
+
* @returns this
|
|
197
|
+
*/
|
|
198
|
+
emitGenAISystemMessageEvent(body: LangWatchSpanGenAISystemMessageEventBody, system?: VAL_GEN_AI_SYSTEMS | (string & {}), attributes?: SemConvAttributes): void;
|
|
199
|
+
/**
|
|
200
|
+
* Emit a GenAI user/customer message event to the logger.
|
|
201
|
+
* @param body - The event body (content and role)
|
|
202
|
+
* @param system - The GenAI system (optional)
|
|
203
|
+
* @param attributes - Additional OpenTelemetry attributes (optional)
|
|
204
|
+
* @returns this
|
|
205
|
+
*/
|
|
206
|
+
emitGenAIUserMessageEvent(body: LangWatchSpanGenAIUserMessageEventBody, system?: VAL_GEN_AI_SYSTEMS | (string & {}), attributes?: SemConvAttributes): void;
|
|
207
|
+
/**
|
|
208
|
+
* Emit a GenAI assistant/bot message event to the logger (including tool calls, if any).
|
|
209
|
+
* @param body - The event body (content, role, tool_calls)
|
|
210
|
+
* @param system - The GenAI system (optional)
|
|
211
|
+
* @param attributes - Additional OpenTelemetry attributes (optional)
|
|
212
|
+
* @returns this
|
|
213
|
+
*/
|
|
214
|
+
emitGenAIAssistantMessageEvent(body: LangWatchSpanGenAIAssistantMessageEventBody, system?: VAL_GEN_AI_SYSTEMS | (string & {}), attributes?: SemConvAttributes): void;
|
|
215
|
+
/**
|
|
216
|
+
* Emit a GenAI tool/function message event to the logger (from a tool the assistant invoked).
|
|
217
|
+
* @param body - The event body (content, id, role)
|
|
218
|
+
* @param system - The GenAI system (optional)
|
|
219
|
+
* @param attributes - Additional OpenTelemetry attributes (optional)
|
|
220
|
+
* @returns this
|
|
221
|
+
*/
|
|
222
|
+
emitGenAIToolMessageEvent(body: LangWatchSpanGenAIToolMessageEventBody, system?: VAL_GEN_AI_SYSTEMS | (string & {}), attributes?: SemConvAttributes): void;
|
|
223
|
+
/**
|
|
224
|
+
* Emit a GenAI choice event to the logger (a model output choice, finish reason, message).
|
|
225
|
+
* @param body - The event body (finish_reason, index, message)
|
|
226
|
+
* @param system - The GenAI system (optional)
|
|
227
|
+
* @param attributes - Additional OpenTelemetry attributes (optional)
|
|
228
|
+
* @returns this
|
|
229
|
+
*/
|
|
230
|
+
emitGenAIChoiceEvent(body: LangWatchSpanGenAIChoiceEventBody, system?: VAL_GEN_AI_SYSTEMS | (string & {}), attributes?: SemConvAttributes): void;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
/**
|
|
234
|
+
* @param name - The logger name (typically your service or module name).
|
|
235
|
+
* @param version - Optional logger version.
|
|
236
|
+
* @returns A {@link LangWatchLogger} instance, or a no-op logger if no provider was set.
|
|
237
|
+
*/
|
|
238
|
+
declare function getLangWatchLogger(name: string, version?: string): LangWatchLogger;
|
|
239
|
+
/**
|
|
240
|
+
* @param loggerProvider - The OpenTelemetry logger provider to use.
|
|
241
|
+
* @param name - The name of the logger.
|
|
242
|
+
* @param version - Optional logger version.
|
|
243
|
+
* @returns A {@link LangWatchLogger} instance.
|
|
244
|
+
*/
|
|
245
|
+
declare function getLangWatchLoggerFromProvider(loggerProvider: LoggerProvider, name: string, version?: string): LangWatchLogger;
|
|
246
|
+
|
|
247
|
+
/**
|
|
248
|
+
* @param name - Tracer name (service or library)
|
|
249
|
+
* @param version - Optional version identifier
|
|
250
|
+
* @returns A LangWatch tracer with enhanced functionality
|
|
251
|
+
*/
|
|
252
|
+
declare function getLangWatchTracer(name: string, version?: string): LangWatchTracer;
|
|
253
|
+
/**
|
|
254
|
+
* @param tracerProvider - The OpenTelemetry tracer provider to use
|
|
255
|
+
* @param name - Tracer name (service or library)
|
|
256
|
+
* @param version - Optional version identifier
|
|
257
|
+
* @returns A LangWatch tracer with enhanced functionality
|
|
258
|
+
*/
|
|
259
|
+
declare function getLangWatchTracerFromProvider(tracerProvider: TracerProvider, name: string, version?: string): LangWatchTracer;
|
|
260
|
+
|
|
261
|
+
export { FilterableBatchSpanProcessor as F, LangWatchTraceExporter as L, type SpanProcessingExcludeRule as S, getLangWatchTracer as a, type LangWatchTraceExporterOptions as b, type LangWatchLogger as c, getLangWatchLoggerFromProvider as d, getLangWatchTracerFromProvider as e, getLangWatchLogger as g };
|