@latitude-data/telemetry 1.0.3 → 1.1.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/dist/index.cjs +791 -665
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +221 -209
- package/dist/index.js +793 -667
- package/dist/index.js.map +1 -1
- package/package.json +29 -40
package/dist/index.d.ts
CHANGED
|
@@ -1,23 +1,9 @@
|
|
|
1
1
|
import * as otel from '@opentelemetry/api';
|
|
2
2
|
import { TextMapPropagator } from '@opentelemetry/api';
|
|
3
|
-
import { SpanProcessor, ReadableSpan, SpanExporter } from '@opentelemetry/sdk-trace-node';
|
|
3
|
+
import { SpanProcessor, ReadableSpan, SpanExporter, NodeTracerProvider } from '@opentelemetry/sdk-trace-node';
|
|
4
4
|
import * as latitude from '@latitude-data/sdk';
|
|
5
5
|
import { z } from 'zod';
|
|
6
6
|
import { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-http';
|
|
7
|
-
import * as anthropic from '@anthropic-ai/sdk';
|
|
8
|
-
import * as bedrock from '@aws-sdk/client-bedrock-runtime';
|
|
9
|
-
import * as azure from '@azure/openai';
|
|
10
|
-
import * as aiplatform from '@google-cloud/aiplatform';
|
|
11
|
-
import * as vertexai from '@google-cloud/vertexai';
|
|
12
|
-
import * as langchain_runnables from '@langchain/core/runnables';
|
|
13
|
-
import * as langchain_vectorstores from '@langchain/core/vectorstores';
|
|
14
|
-
import * as cohere from 'cohere-ai';
|
|
15
|
-
import * as langchain_agents from 'langchain/agents';
|
|
16
|
-
import * as langchain_chains from 'langchain/chains';
|
|
17
|
-
import * as langchain_tools from 'langchain/tools';
|
|
18
|
-
import * as llamaindex from 'llamaindex';
|
|
19
|
-
import * as openai from 'openai';
|
|
20
|
-
import * as togetherai from 'together-ai';
|
|
21
7
|
|
|
22
8
|
interface RedactSpanProcessorOptions {
|
|
23
9
|
attributes: (string | RegExp)[];
|
|
@@ -35,121 +21,39 @@ declare class RedactSpanProcessor implements SpanProcessor {
|
|
|
35
21
|
}
|
|
36
22
|
declare const DEFAULT_REDACT_SPAN_PROCESSOR: () => RedactSpanProcessor;
|
|
37
23
|
|
|
38
|
-
|
|
24
|
+
interface BaseInstrumentation {
|
|
25
|
+
isEnabled(): boolean;
|
|
26
|
+
enable(): void;
|
|
27
|
+
disable(): void;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
type LatitudeInstrumentationOptions = {
|
|
31
|
+
module: typeof latitude.Latitude;
|
|
32
|
+
completions?: boolean;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
declare enum LogSources {
|
|
39
36
|
API = "api",
|
|
40
|
-
AgentAsTool = "agent_as_tool"
|
|
37
|
+
AgentAsTool = "agent_as_tool",
|
|
41
38
|
Copilot = "copilot",
|
|
42
39
|
EmailTrigger = "email_trigger",
|
|
43
|
-
Evaluation = "evaluation"
|
|
40
|
+
Evaluation = "evaluation",
|
|
44
41
|
Experiment = "experiment",
|
|
42
|
+
IntegrationTrigger = "integration_trigger",
|
|
45
43
|
Playground = "playground",
|
|
46
44
|
ScheduledTrigger = "scheduled_trigger",
|
|
47
|
-
IntegrationTrigger = "integration_trigger",
|
|
48
45
|
SharedPrompt = "shared_prompt",
|
|
46
|
+
ShadowTest = "shadow_test",
|
|
47
|
+
ABTestChallenger = "ab_test_challenger",
|
|
49
48
|
User = "user"
|
|
50
49
|
}
|
|
51
|
-
declare enum SegmentType {
|
|
52
|
-
Document = "document",
|
|
53
|
-
Step = "step"
|
|
54
|
-
}
|
|
55
|
-
declare const segmentBaggageSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObject<z.objectUtil.extendShape<{
|
|
56
|
-
id: z.ZodString;
|
|
57
|
-
parentId: z.ZodOptional<z.ZodString>;
|
|
58
|
-
source: z.ZodNativeEnum<typeof SegmentSource>;
|
|
59
|
-
}, {
|
|
60
|
-
type: z.ZodLiteral<SegmentType.Document>;
|
|
61
|
-
data: z.ZodObject<{
|
|
62
|
-
logUuid: z.ZodOptional<z.ZodString>;
|
|
63
|
-
commitUuid: z.ZodString;
|
|
64
|
-
documentUuid: z.ZodString;
|
|
65
|
-
experimentUuid: z.ZodOptional<z.ZodString>;
|
|
66
|
-
externalId: z.ZodOptional<z.ZodString>;
|
|
67
|
-
}, "strip", z.ZodTypeAny, {
|
|
68
|
-
commitUuid: string;
|
|
69
|
-
documentUuid: string;
|
|
70
|
-
logUuid?: string | undefined;
|
|
71
|
-
experimentUuid?: string | undefined;
|
|
72
|
-
externalId?: string | undefined;
|
|
73
|
-
}, {
|
|
74
|
-
commitUuid: string;
|
|
75
|
-
documentUuid: string;
|
|
76
|
-
logUuid?: string | undefined;
|
|
77
|
-
experimentUuid?: string | undefined;
|
|
78
|
-
externalId?: string | undefined;
|
|
79
|
-
}>;
|
|
80
|
-
}>, "strip", z.ZodTypeAny, {
|
|
81
|
-
id: string;
|
|
82
|
-
type: SegmentType.Document;
|
|
83
|
-
data: {
|
|
84
|
-
commitUuid: string;
|
|
85
|
-
documentUuid: string;
|
|
86
|
-
logUuid?: string | undefined;
|
|
87
|
-
experimentUuid?: string | undefined;
|
|
88
|
-
externalId?: string | undefined;
|
|
89
|
-
};
|
|
90
|
-
source: SegmentSource;
|
|
91
|
-
parentId?: string | undefined;
|
|
92
|
-
}, {
|
|
93
|
-
id: string;
|
|
94
|
-
type: SegmentType.Document;
|
|
95
|
-
data: {
|
|
96
|
-
commitUuid: string;
|
|
97
|
-
documentUuid: string;
|
|
98
|
-
logUuid?: string | undefined;
|
|
99
|
-
experimentUuid?: string | undefined;
|
|
100
|
-
externalId?: string | undefined;
|
|
101
|
-
};
|
|
102
|
-
source: SegmentSource;
|
|
103
|
-
parentId?: string | undefined;
|
|
104
|
-
}>, z.ZodObject<z.objectUtil.extendShape<{
|
|
105
|
-
id: z.ZodString;
|
|
106
|
-
parentId: z.ZodOptional<z.ZodString>;
|
|
107
|
-
source: z.ZodNativeEnum<typeof SegmentSource>;
|
|
108
|
-
}, {
|
|
109
|
-
type: z.ZodLiteral<SegmentType.Step>;
|
|
110
|
-
data: z.ZodOptional<z.ZodUndefined>;
|
|
111
|
-
}>, "strip", z.ZodTypeAny, {
|
|
112
|
-
id: string;
|
|
113
|
-
type: SegmentType.Step;
|
|
114
|
-
source: SegmentSource;
|
|
115
|
-
data?: undefined;
|
|
116
|
-
parentId?: string | undefined;
|
|
117
|
-
}, {
|
|
118
|
-
id: string;
|
|
119
|
-
type: SegmentType.Step;
|
|
120
|
-
source: SegmentSource;
|
|
121
|
-
data?: undefined;
|
|
122
|
-
parentId?: string | undefined;
|
|
123
|
-
}>]>;
|
|
124
|
-
type SegmentBaggage<T extends SegmentType = SegmentType> = Extract<z.infer<typeof segmentBaggageSchema>, {
|
|
125
|
-
type: T;
|
|
126
|
-
}>;
|
|
127
50
|
|
|
128
51
|
declare const traceContextSchema: z.ZodObject<{
|
|
129
52
|
traceparent: z.ZodString;
|
|
130
53
|
tracestate: z.ZodOptional<z.ZodString>;
|
|
131
54
|
baggage: z.ZodOptional<z.ZodString>;
|
|
132
|
-
},
|
|
133
|
-
traceparent: string;
|
|
134
|
-
tracestate?: string | undefined;
|
|
135
|
-
baggage?: string | undefined;
|
|
136
|
-
}, {
|
|
137
|
-
traceparent: string;
|
|
138
|
-
tracestate?: string | undefined;
|
|
139
|
-
baggage?: string | undefined;
|
|
140
|
-
}>;
|
|
55
|
+
}, z.core.$strip>;
|
|
141
56
|
type TraceContext = z.infer<typeof traceContextSchema>;
|
|
142
|
-
type TraceBaggage = {
|
|
143
|
-
segment: Pick<SegmentBaggage, 'id' | 'parentId'>;
|
|
144
|
-
segments: (SegmentBaggage & Pick<TraceContext, 'traceparent' | 'tracestate'> & {
|
|
145
|
-
paused?: boolean;
|
|
146
|
-
})[];
|
|
147
|
-
};
|
|
148
|
-
|
|
149
|
-
type LatitudeInstrumentationOptions = {
|
|
150
|
-
module: typeof latitude.Latitude;
|
|
151
|
-
completions?: boolean;
|
|
152
|
-
};
|
|
153
57
|
|
|
154
58
|
type StartSpanOptions = {
|
|
155
59
|
name?: string;
|
|
@@ -177,18 +81,21 @@ type EndToolSpanOptions = EndSpanOptions & {
|
|
|
177
81
|
type StartCompletionSpanOptions = StartSpanOptions & {
|
|
178
82
|
provider: string;
|
|
179
83
|
model: string;
|
|
180
|
-
configuration
|
|
181
|
-
input
|
|
84
|
+
configuration?: Record<string, unknown>;
|
|
85
|
+
input?: Record<string, unknown>[];
|
|
86
|
+
versionUuid?: string;
|
|
87
|
+
promptUuid?: string;
|
|
88
|
+
experimentUuid?: string;
|
|
182
89
|
};
|
|
183
90
|
type EndCompletionSpanOptions = EndSpanOptions & {
|
|
184
|
-
output
|
|
185
|
-
tokens
|
|
186
|
-
prompt
|
|
187
|
-
cached
|
|
188
|
-
reasoning
|
|
189
|
-
completion
|
|
91
|
+
output?: Record<string, unknown>[];
|
|
92
|
+
tokens?: {
|
|
93
|
+
prompt?: number;
|
|
94
|
+
cached?: number;
|
|
95
|
+
reasoning?: number;
|
|
96
|
+
completion?: number;
|
|
190
97
|
};
|
|
191
|
-
finishReason
|
|
98
|
+
finishReason?: string;
|
|
192
99
|
};
|
|
193
100
|
type StartHttpSpanOptions = StartSpanOptions & {
|
|
194
101
|
request: {
|
|
@@ -205,104 +112,62 @@ type EndHttpSpanOptions = EndSpanOptions & {
|
|
|
205
112
|
body: string | Record<string, unknown>;
|
|
206
113
|
};
|
|
207
114
|
};
|
|
208
|
-
type
|
|
209
|
-
|
|
210
|
-
baggage?: Record<string, otel.BaggageEntry>;
|
|
211
|
-
_internal?: {
|
|
212
|
-
id?: string;
|
|
213
|
-
source?: SegmentSource;
|
|
214
|
-
};
|
|
215
|
-
};
|
|
216
|
-
type PromptSegmentOptions = SegmentOptions & {
|
|
217
|
-
logUuid?: string;
|
|
115
|
+
type PromptSpanOptions = StartSpanOptions & {
|
|
116
|
+
documentLogUuid: string;
|
|
218
117
|
versionUuid?: string;
|
|
219
118
|
promptUuid: string;
|
|
119
|
+
projectId?: number;
|
|
220
120
|
experimentUuid?: string;
|
|
121
|
+
testDeploymentId?: number;
|
|
221
122
|
externalId?: string;
|
|
222
123
|
template: string;
|
|
223
124
|
parameters?: Record<string, unknown>;
|
|
125
|
+
source?: LogSources;
|
|
224
126
|
};
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
private readonly scope;
|
|
230
|
-
private readonly version;
|
|
231
|
-
private readonly provider;
|
|
232
|
-
constructor(scope: string, version: string, provider: otel.TracerProvider);
|
|
233
|
-
getTracer(_name: string, _version?: string, options?: otel.TracerOptions): otel.Tracer;
|
|
234
|
-
}
|
|
235
|
-
declare const DEFAULT_SPAN_EXPORTER: (apiKey: string) => OTLPTraceExporter;
|
|
236
|
-
declare enum Instrumentation {
|
|
237
|
-
Latitude = "latitude",
|
|
238
|
-
OpenAI = "openai",
|
|
239
|
-
Anthropic = "anthropic",
|
|
240
|
-
AzureOpenAI = "azure",
|
|
241
|
-
VercelAI = "vercelai",
|
|
242
|
-
VertexAI = "vertexai",
|
|
243
|
-
AIPlatform = "aiplatform",
|
|
244
|
-
Bedrock = "bedrock",
|
|
245
|
-
TogetherAI = "togetherai",
|
|
246
|
-
Cohere = "cohere",
|
|
247
|
-
Langchain = "langchain",
|
|
248
|
-
LlamaIndex = "llamaindex"
|
|
249
|
-
}
|
|
250
|
-
type TelemetryOptions = {
|
|
251
|
-
instrumentations?: {
|
|
252
|
-
[Instrumentation.Latitude]?: typeof latitude.Latitude | LatitudeInstrumentationOptions;
|
|
253
|
-
[Instrumentation.OpenAI]?: typeof openai.OpenAI;
|
|
254
|
-
[Instrumentation.Anthropic]?: typeof anthropic;
|
|
255
|
-
[Instrumentation.AzureOpenAI]?: typeof azure;
|
|
256
|
-
[Instrumentation.VercelAI]?: 'manual';
|
|
257
|
-
[Instrumentation.VertexAI]?: typeof vertexai;
|
|
258
|
-
[Instrumentation.AIPlatform]?: typeof aiplatform;
|
|
259
|
-
[Instrumentation.Bedrock]?: typeof bedrock;
|
|
260
|
-
[Instrumentation.TogetherAI]?: typeof togetherai.Together;
|
|
261
|
-
[Instrumentation.Cohere]?: typeof cohere;
|
|
262
|
-
[Instrumentation.Langchain]?: {
|
|
263
|
-
chainsModule: typeof langchain_chains;
|
|
264
|
-
agentsModule: typeof langchain_agents;
|
|
265
|
-
toolsModule: typeof langchain_tools;
|
|
266
|
-
vectorStoreModule: typeof langchain_vectorstores;
|
|
267
|
-
runnablesModule: typeof langchain_runnables;
|
|
268
|
-
};
|
|
269
|
-
[Instrumentation.LlamaIndex]?: typeof llamaindex;
|
|
270
|
-
};
|
|
271
|
-
disableBatch?: boolean;
|
|
272
|
-
exporter?: SpanExporter;
|
|
273
|
-
processors?: SpanProcessor[];
|
|
274
|
-
propagators?: TextMapPropagator[];
|
|
127
|
+
type ChatSpanOptions = StartSpanOptions & {
|
|
128
|
+
documentLogUuid: string;
|
|
129
|
+
previousTraceId: string;
|
|
130
|
+
source?: LogSources;
|
|
275
131
|
};
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
132
|
+
type ExternalSpanOptions = StartSpanOptions & {
|
|
133
|
+
promptUuid: string;
|
|
134
|
+
documentLogUuid: string;
|
|
135
|
+
source?: LogSources;
|
|
136
|
+
versionUuid?: string;
|
|
137
|
+
externalId?: string;
|
|
138
|
+
};
|
|
139
|
+
type CaptureOptions = StartSpanOptions & {
|
|
140
|
+
path: string;
|
|
141
|
+
projectId: number;
|
|
142
|
+
versionUuid?: string;
|
|
143
|
+
conversationUuid?: string;
|
|
144
|
+
};
|
|
145
|
+
declare class ManualInstrumentation implements BaseInstrumentation {
|
|
146
|
+
private enabled;
|
|
147
|
+
private readonly tracer;
|
|
148
|
+
constructor(tracer: otel.Tracer);
|
|
149
|
+
isEnabled(): boolean;
|
|
150
|
+
enable(): void;
|
|
151
|
+
disable(): void;
|
|
295
152
|
resume(ctx: TraceContext): otel.Context;
|
|
296
|
-
|
|
297
|
-
|
|
153
|
+
private capitalize;
|
|
154
|
+
private toCamelCase;
|
|
155
|
+
private toSnakeCase;
|
|
156
|
+
private toKebabCase;
|
|
157
|
+
private error;
|
|
158
|
+
private span;
|
|
298
159
|
tool(ctx: otel.Context, options: StartToolSpanOptions): {
|
|
299
160
|
context: otel.Context;
|
|
300
161
|
end: (options: EndToolSpanOptions) => void;
|
|
301
162
|
fail: (_error: Error, _options?: ErrorOptions) => void;
|
|
302
163
|
};
|
|
164
|
+
private attribifyMessageToolCalls;
|
|
165
|
+
private attribifyMessageContent;
|
|
166
|
+
private attribifyMessages;
|
|
167
|
+
private attribifyConfiguration;
|
|
303
168
|
completion(ctx: otel.Context, options: StartCompletionSpanOptions): {
|
|
304
169
|
context: otel.Context;
|
|
305
|
-
end: (options
|
|
170
|
+
end: (options?: EndCompletionSpanOptions) => void;
|
|
306
171
|
fail: (_error: Error, _options?: ErrorOptions) => void;
|
|
307
172
|
};
|
|
308
173
|
embedding(ctx: otel.Context, options?: StartSpanOptions): {
|
|
@@ -320,22 +185,169 @@ declare class LatitudeTelemetry {
|
|
|
320
185
|
end: (_options?: EndSpanOptions) => void;
|
|
321
186
|
fail: (_error: Error, _options?: ErrorOptions) => void;
|
|
322
187
|
};
|
|
188
|
+
private attribifyHeaders;
|
|
323
189
|
http(ctx: otel.Context, options: StartHttpSpanOptions): {
|
|
324
190
|
context: otel.Context;
|
|
325
191
|
end: (options: EndHttpSpanOptions) => void;
|
|
326
192
|
fail: (_error: Error, _options?: ErrorOptions) => void;
|
|
327
193
|
};
|
|
328
|
-
prompt(ctx: otel.Context,
|
|
194
|
+
prompt(ctx: otel.Context, { documentLogUuid, versionUuid, promptUuid, projectId, experimentUuid, testDeploymentId, externalId, template, parameters, name, source, ...rest }: PromptSpanOptions): {
|
|
329
195
|
context: otel.Context;
|
|
330
196
|
end: (_options?: EndSpanOptions) => void;
|
|
331
197
|
fail: (_error: Error, _options?: ErrorOptions) => void;
|
|
332
198
|
};
|
|
333
|
-
step(ctx: otel.Context, options?:
|
|
199
|
+
step(ctx: otel.Context, options?: StartSpanOptions): {
|
|
334
200
|
context: otel.Context;
|
|
335
201
|
end: (_options?: EndSpanOptions) => void;
|
|
336
202
|
fail: (_error: Error, _options?: ErrorOptions) => void;
|
|
337
203
|
};
|
|
204
|
+
chat(ctx: otel.Context, { documentLogUuid, previousTraceId, source, name, ...rest }: ChatSpanOptions): {
|
|
205
|
+
context: otel.Context;
|
|
206
|
+
end: (_options?: EndSpanOptions) => void;
|
|
207
|
+
fail: (_error: Error, _options?: ErrorOptions) => void;
|
|
208
|
+
};
|
|
209
|
+
external(ctx: otel.Context, { promptUuid, documentLogUuid, source, versionUuid, externalId, name, ...rest }: ExternalSpanOptions): {
|
|
210
|
+
context: otel.Context;
|
|
211
|
+
end: (_options?: EndSpanOptions) => void;
|
|
212
|
+
fail: (_error: Error, _options?: ErrorOptions) => void;
|
|
213
|
+
};
|
|
214
|
+
unresolvedExternal(ctx: otel.Context, { path, projectId, versionUuid, conversationUuid, name, ...rest }: CaptureOptions): {
|
|
215
|
+
context: otel.Context;
|
|
216
|
+
end: (_options?: EndSpanOptions) => void;
|
|
217
|
+
fail: (_error: Error, _options?: ErrorOptions) => void;
|
|
218
|
+
};
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
type TelemetryContext = otel.Context;
|
|
222
|
+
declare const BACKGROUND: () => otel.Context;
|
|
223
|
+
declare class SpanFactory {
|
|
224
|
+
private telemetry;
|
|
225
|
+
constructor(telemetry: ManualInstrumentation);
|
|
226
|
+
tool(options: StartToolSpanOptions, ctx?: TelemetryContext): {
|
|
227
|
+
context: otel.Context;
|
|
228
|
+
end: (options: EndToolSpanOptions) => void;
|
|
229
|
+
fail: (_error: Error, _options?: ErrorOptions) => void;
|
|
230
|
+
};
|
|
231
|
+
completion(options: StartCompletionSpanOptions, ctx?: TelemetryContext): {
|
|
232
|
+
context: otel.Context;
|
|
233
|
+
end: (options?: EndCompletionSpanOptions) => void;
|
|
234
|
+
fail: (_error: Error, _options?: ErrorOptions) => void;
|
|
235
|
+
};
|
|
236
|
+
embedding(options?: StartSpanOptions, ctx?: TelemetryContext): {
|
|
237
|
+
context: otel.Context;
|
|
238
|
+
end: (_options?: EndSpanOptions) => void;
|
|
239
|
+
fail: (_error: Error, _options?: ErrorOptions) => void;
|
|
240
|
+
};
|
|
241
|
+
retrieval(options?: StartSpanOptions, ctx?: TelemetryContext): {
|
|
242
|
+
context: otel.Context;
|
|
243
|
+
end: (_options?: EndSpanOptions) => void;
|
|
244
|
+
fail: (_error: Error, _options?: ErrorOptions) => void;
|
|
245
|
+
};
|
|
246
|
+
reranking(options?: StartSpanOptions, ctx?: TelemetryContext): {
|
|
247
|
+
context: otel.Context;
|
|
248
|
+
end: (_options?: EndSpanOptions) => void;
|
|
249
|
+
fail: (_error: Error, _options?: ErrorOptions) => void;
|
|
250
|
+
};
|
|
251
|
+
http(options: StartHttpSpanOptions, ctx?: TelemetryContext): {
|
|
252
|
+
context: otel.Context;
|
|
253
|
+
end: (options: EndHttpSpanOptions) => void;
|
|
254
|
+
fail: (_error: Error, _options?: ErrorOptions) => void;
|
|
255
|
+
};
|
|
256
|
+
prompt(options: PromptSpanOptions, ctx?: TelemetryContext): {
|
|
257
|
+
context: otel.Context;
|
|
258
|
+
end: (_options?: EndSpanOptions) => void;
|
|
259
|
+
fail: (_error: Error, _options?: ErrorOptions) => void;
|
|
260
|
+
};
|
|
261
|
+
step(options?: StartSpanOptions, ctx?: TelemetryContext): {
|
|
262
|
+
context: otel.Context;
|
|
263
|
+
end: (_options?: EndSpanOptions) => void;
|
|
264
|
+
fail: (_error: Error, _options?: ErrorOptions) => void;
|
|
265
|
+
};
|
|
266
|
+
chat(options: ChatSpanOptions, ctx?: TelemetryContext): {
|
|
267
|
+
context: otel.Context;
|
|
268
|
+
end: (_options?: EndSpanOptions) => void;
|
|
269
|
+
fail: (_error: Error, _options?: ErrorOptions) => void;
|
|
270
|
+
};
|
|
271
|
+
external(options: ExternalSpanOptions, ctx?: TelemetryContext): {
|
|
272
|
+
context: otel.Context;
|
|
273
|
+
end: (_options?: EndSpanOptions) => void;
|
|
274
|
+
fail: (_error: Error, _options?: ErrorOptions) => void;
|
|
275
|
+
};
|
|
276
|
+
}
|
|
277
|
+
declare class ContextManager {
|
|
278
|
+
private telemetry;
|
|
279
|
+
constructor(telemetry: ManualInstrumentation);
|
|
280
|
+
resume(ctx: TraceContext): otel.Context;
|
|
281
|
+
active(): otel.Context;
|
|
282
|
+
}
|
|
283
|
+
declare class InstrumentationManager {
|
|
284
|
+
private instrumentations;
|
|
285
|
+
constructor(instrumentations: BaseInstrumentation[]);
|
|
286
|
+
enable(): void;
|
|
287
|
+
disable(): void;
|
|
288
|
+
}
|
|
289
|
+
declare class TracerManager {
|
|
290
|
+
private nodeProvider;
|
|
291
|
+
private scopeVersion;
|
|
292
|
+
constructor(nodeProvider: NodeTracerProvider, scopeVersion: string);
|
|
293
|
+
get(scope: Instrumentation): otel.Tracer;
|
|
294
|
+
provider(scope: Instrumentation): ScopedTracerProvider;
|
|
295
|
+
}
|
|
296
|
+
declare class ScopedTracerProvider implements otel.TracerProvider {
|
|
297
|
+
private readonly scope;
|
|
298
|
+
private readonly version;
|
|
299
|
+
private readonly provider;
|
|
300
|
+
constructor(scope: string, version: string, provider: otel.TracerProvider);
|
|
301
|
+
getTracer(_name: string, _version?: string, options?: otel.TracerOptions): otel.Tracer;
|
|
302
|
+
}
|
|
303
|
+
declare const DEFAULT_SPAN_EXPORTER: (apiKey: string) => OTLPTraceExporter;
|
|
304
|
+
declare enum Instrumentation {
|
|
305
|
+
Anthropic = "anthropic",
|
|
306
|
+
AIPlatform = "aiplatform",
|
|
307
|
+
Bedrock = "bedrock",
|
|
308
|
+
Cohere = "cohere",
|
|
309
|
+
Langchain = "langchain",
|
|
310
|
+
Latitude = "latitude",
|
|
311
|
+
LlamaIndex = "llamaindex",
|
|
312
|
+
OpenAI = "openai",
|
|
313
|
+
TogetherAI = "togetherai",
|
|
314
|
+
VertexAI = "vertexai"
|
|
315
|
+
}
|
|
316
|
+
type TelemetryOptions = {
|
|
317
|
+
disableBatch?: boolean;
|
|
318
|
+
exporter?: SpanExporter;
|
|
319
|
+
processors?: SpanProcessor[];
|
|
320
|
+
propagators?: TextMapPropagator[];
|
|
321
|
+
instrumentations?: {
|
|
322
|
+
[Instrumentation.Latitude]?: typeof latitude.Latitude | LatitudeInstrumentationOptions;
|
|
323
|
+
[Instrumentation.AIPlatform]?: any;
|
|
324
|
+
[Instrumentation.Anthropic]?: any;
|
|
325
|
+
[Instrumentation.Bedrock]?: any;
|
|
326
|
+
[Instrumentation.Cohere]?: any;
|
|
327
|
+
[Instrumentation.OpenAI]?: any;
|
|
328
|
+
[Instrumentation.LlamaIndex]?: any;
|
|
329
|
+
[Instrumentation.TogetherAI]?: any;
|
|
330
|
+
[Instrumentation.VertexAI]?: any;
|
|
331
|
+
[Instrumentation.Langchain]?: {
|
|
332
|
+
callbackManagerModule?: any;
|
|
333
|
+
};
|
|
334
|
+
};
|
|
335
|
+
};
|
|
336
|
+
declare class LatitudeTelemetry {
|
|
337
|
+
private options;
|
|
338
|
+
private nodeProvider;
|
|
339
|
+
private manualInstrumentation;
|
|
340
|
+
private instrumentationsList;
|
|
341
|
+
readonly span: SpanFactory;
|
|
342
|
+
readonly context: ContextManager;
|
|
343
|
+
readonly instrumentation: InstrumentationManager;
|
|
344
|
+
readonly tracer: TracerManager;
|
|
345
|
+
constructor(apiKey: string, options?: TelemetryOptions);
|
|
346
|
+
flush(): Promise<void>;
|
|
347
|
+
shutdown(): Promise<void>;
|
|
348
|
+
private initInstrumentations;
|
|
349
|
+
capture<T>(options: CaptureOptions, fn: (ctx: TelemetryContext) => T | Promise<T>): Promise<T>;
|
|
338
350
|
}
|
|
339
351
|
|
|
340
352
|
export { BACKGROUND, DEFAULT_REDACT_SPAN_PROCESSOR, DEFAULT_SPAN_EXPORTER, Instrumentation, LatitudeTelemetry, RedactSpanProcessor };
|
|
341
|
-
export type { EndCompletionSpanOptions, EndHttpSpanOptions, EndSpanOptions, EndToolSpanOptions, ErrorOptions, PromptSegmentOptions, RedactSpanProcessorOptions,
|
|
353
|
+
export type { CaptureOptions, ChatSpanOptions, EndCompletionSpanOptions, EndHttpSpanOptions, EndSpanOptions, EndToolSpanOptions, ErrorOptions, ExternalSpanOptions, PromptSpanOptions as PromptSegmentOptions, RedactSpanProcessorOptions, StartCompletionSpanOptions, StartHttpSpanOptions, StartSpanOptions, StartToolSpanOptions, TelemetryContext, TelemetryOptions };
|