@latitude-data/telemetry 1.0.3 → 1.0.4
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 +470 -585
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +41 -161
- package/dist/index.js +471 -586
- package/dist/index.js.map +1 -1
- package/package.json +30 -41
package/dist/index.d.ts
CHANGED
|
@@ -4,20 +4,6 @@ import { SpanProcessor, ReadableSpan, SpanExporter } from '@opentelemetry/sdk-tr
|
|
|
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,33 @@ declare class RedactSpanProcessor implements SpanProcessor {
|
|
|
35
21
|
}
|
|
36
22
|
declare const DEFAULT_REDACT_SPAN_PROCESSOR: () => RedactSpanProcessor;
|
|
37
23
|
|
|
38
|
-
|
|
24
|
+
type LatitudeInstrumentationOptions = {
|
|
25
|
+
module: typeof latitude.Latitude;
|
|
26
|
+
completions?: boolean;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
declare enum LogSources {
|
|
39
30
|
API = "api",
|
|
40
|
-
AgentAsTool = "agent_as_tool"
|
|
31
|
+
AgentAsTool = "agent_as_tool",
|
|
41
32
|
Copilot = "copilot",
|
|
42
33
|
EmailTrigger = "email_trigger",
|
|
43
|
-
Evaluation = "evaluation"
|
|
34
|
+
Evaluation = "evaluation",
|
|
44
35
|
Experiment = "experiment",
|
|
36
|
+
IntegrationTrigger = "integration_trigger",
|
|
45
37
|
Playground = "playground",
|
|
46
38
|
ScheduledTrigger = "scheduled_trigger",
|
|
47
|
-
IntegrationTrigger = "integration_trigger",
|
|
48
39
|
SharedPrompt = "shared_prompt",
|
|
40
|
+
ShadowTest = "shadow_test",
|
|
41
|
+
ABTestChallenger = "ab_test_challenger",
|
|
49
42
|
User = "user"
|
|
50
43
|
}
|
|
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
44
|
|
|
128
45
|
declare const traceContextSchema: z.ZodObject<{
|
|
129
46
|
traceparent: z.ZodString;
|
|
130
47
|
tracestate: z.ZodOptional<z.ZodString>;
|
|
131
48
|
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
|
-
}>;
|
|
49
|
+
}, z.core.$strip>;
|
|
141
50
|
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
51
|
|
|
154
52
|
type StartSpanOptions = {
|
|
155
53
|
name?: string;
|
|
@@ -179,6 +77,9 @@ type StartCompletionSpanOptions = StartSpanOptions & {
|
|
|
179
77
|
model: string;
|
|
180
78
|
configuration: Record<string, unknown>;
|
|
181
79
|
input: Record<string, unknown>[];
|
|
80
|
+
versionUuid?: string;
|
|
81
|
+
promptUuid?: string;
|
|
82
|
+
experimentUuid?: string;
|
|
182
83
|
};
|
|
183
84
|
type EndCompletionSpanOptions = EndSpanOptions & {
|
|
184
85
|
output: Record<string, unknown>[];
|
|
@@ -205,22 +106,17 @@ type EndHttpSpanOptions = EndSpanOptions & {
|
|
|
205
106
|
body: string | Record<string, unknown>;
|
|
206
107
|
};
|
|
207
108
|
};
|
|
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;
|
|
109
|
+
type PromptSpanOptions = StartSpanOptions & {
|
|
110
|
+
documentLogUuid?: string;
|
|
218
111
|
versionUuid?: string;
|
|
219
112
|
promptUuid: string;
|
|
113
|
+
projectId?: string;
|
|
220
114
|
experimentUuid?: string;
|
|
115
|
+
testDeploymentId?: number;
|
|
221
116
|
externalId?: string;
|
|
222
117
|
template: string;
|
|
223
118
|
parameters?: Record<string, unknown>;
|
|
119
|
+
source?: LogSources;
|
|
224
120
|
};
|
|
225
121
|
|
|
226
122
|
type TelemetryContext = otel.Context;
|
|
@@ -234,44 +130,36 @@ declare class ScopedTracerProvider implements otel.TracerProvider {
|
|
|
234
130
|
}
|
|
235
131
|
declare const DEFAULT_SPAN_EXPORTER: (apiKey: string) => OTLPTraceExporter;
|
|
236
132
|
declare enum Instrumentation {
|
|
237
|
-
Latitude = "latitude",
|
|
238
|
-
OpenAI = "openai",
|
|
239
133
|
Anthropic = "anthropic",
|
|
240
|
-
AzureOpenAI = "azure",
|
|
241
|
-
VercelAI = "vercelai",
|
|
242
|
-
VertexAI = "vertexai",
|
|
243
134
|
AIPlatform = "aiplatform",
|
|
244
135
|
Bedrock = "bedrock",
|
|
245
|
-
TogetherAI = "togetherai",
|
|
246
136
|
Cohere = "cohere",
|
|
247
137
|
Langchain = "langchain",
|
|
248
|
-
|
|
138
|
+
Latitude = "latitude",
|
|
139
|
+
LlamaIndex = "llamaindex",
|
|
140
|
+
OpenAI = "openai",
|
|
141
|
+
TogetherAI = "togetherai",
|
|
142
|
+
VertexAI = "vertexai"
|
|
249
143
|
}
|
|
250
144
|
type TelemetryOptions = {
|
|
145
|
+
disableBatch?: boolean;
|
|
146
|
+
exporter?: SpanExporter;
|
|
147
|
+
processors?: SpanProcessor[];
|
|
148
|
+
propagators?: TextMapPropagator[];
|
|
251
149
|
instrumentations?: {
|
|
252
150
|
[Instrumentation.Latitude]?: typeof latitude.Latitude | LatitudeInstrumentationOptions;
|
|
253
|
-
[Instrumentation.
|
|
254
|
-
[Instrumentation.Anthropic]?:
|
|
255
|
-
[Instrumentation.
|
|
256
|
-
[Instrumentation.
|
|
257
|
-
[Instrumentation.
|
|
258
|
-
[Instrumentation.
|
|
259
|
-
[Instrumentation.
|
|
260
|
-
[Instrumentation.
|
|
261
|
-
[Instrumentation.Cohere]?: typeof cohere;
|
|
151
|
+
[Instrumentation.AIPlatform]?: any;
|
|
152
|
+
[Instrumentation.Anthropic]?: any;
|
|
153
|
+
[Instrumentation.Bedrock]?: any;
|
|
154
|
+
[Instrumentation.Cohere]?: any;
|
|
155
|
+
[Instrumentation.OpenAI]?: any;
|
|
156
|
+
[Instrumentation.LlamaIndex]?: any;
|
|
157
|
+
[Instrumentation.TogetherAI]?: any;
|
|
158
|
+
[Instrumentation.VertexAI]?: any;
|
|
262
159
|
[Instrumentation.Langchain]?: {
|
|
263
|
-
|
|
264
|
-
agentsModule: typeof langchain_agents;
|
|
265
|
-
toolsModule: typeof langchain_tools;
|
|
266
|
-
vectorStoreModule: typeof langchain_vectorstores;
|
|
267
|
-
runnablesModule: typeof langchain_runnables;
|
|
160
|
+
callbackManagerModule?: any;
|
|
268
161
|
};
|
|
269
|
-
[Instrumentation.LlamaIndex]?: typeof llamaindex;
|
|
270
162
|
};
|
|
271
|
-
disableBatch?: boolean;
|
|
272
|
-
exporter?: SpanExporter;
|
|
273
|
-
processors?: SpanProcessor[];
|
|
274
|
-
propagators?: TextMapPropagator[];
|
|
275
163
|
};
|
|
276
164
|
declare class LatitudeTelemetry {
|
|
277
165
|
private options;
|
|
@@ -286,15 +174,7 @@ declare class LatitudeTelemetry {
|
|
|
286
174
|
private initInstrumentations;
|
|
287
175
|
instrument(): void;
|
|
288
176
|
uninstrument(): void;
|
|
289
|
-
baggage(ctx: otel.Context | TraceContext): TraceBaggage | undefined;
|
|
290
|
-
pause(ctx: otel.Context): {
|
|
291
|
-
traceparent: string;
|
|
292
|
-
tracestate?: string | undefined;
|
|
293
|
-
baggage?: string | undefined;
|
|
294
|
-
};
|
|
295
177
|
resume(ctx: TraceContext): otel.Context;
|
|
296
|
-
restored(ctx: otel.Context): boolean;
|
|
297
|
-
restore(ctx: otel.Context): otel.Context;
|
|
298
178
|
tool(ctx: otel.Context, options: StartToolSpanOptions): {
|
|
299
179
|
context: otel.Context;
|
|
300
180
|
end: (options: EndToolSpanOptions) => void;
|
|
@@ -325,12 +205,12 @@ declare class LatitudeTelemetry {
|
|
|
325
205
|
end: (options: EndHttpSpanOptions) => void;
|
|
326
206
|
fail: (_error: Error, _options?: ErrorOptions) => void;
|
|
327
207
|
};
|
|
328
|
-
prompt(ctx: otel.Context, options:
|
|
208
|
+
prompt(ctx: otel.Context, options: PromptSpanOptions): {
|
|
329
209
|
context: otel.Context;
|
|
330
210
|
end: (_options?: EndSpanOptions) => void;
|
|
331
211
|
fail: (_error: Error, _options?: ErrorOptions) => void;
|
|
332
212
|
};
|
|
333
|
-
step(ctx: otel.Context, options?:
|
|
213
|
+
step(ctx: otel.Context, options?: StartSpanOptions): {
|
|
334
214
|
context: otel.Context;
|
|
335
215
|
end: (_options?: EndSpanOptions) => void;
|
|
336
216
|
fail: (_error: Error, _options?: ErrorOptions) => void;
|
|
@@ -338,4 +218,4 @@ declare class LatitudeTelemetry {
|
|
|
338
218
|
}
|
|
339
219
|
|
|
340
220
|
export { BACKGROUND, DEFAULT_REDACT_SPAN_PROCESSOR, DEFAULT_SPAN_EXPORTER, Instrumentation, LatitudeTelemetry, RedactSpanProcessor };
|
|
341
|
-
export type { EndCompletionSpanOptions, EndHttpSpanOptions, EndSpanOptions, EndToolSpanOptions, ErrorOptions, PromptSegmentOptions, RedactSpanProcessorOptions,
|
|
221
|
+
export type { EndCompletionSpanOptions, EndHttpSpanOptions, EndSpanOptions, EndToolSpanOptions, ErrorOptions, PromptSpanOptions as PromptSegmentOptions, RedactSpanProcessorOptions, StartCompletionSpanOptions, StartHttpSpanOptions, StartSpanOptions, StartToolSpanOptions, TelemetryContext, TelemetryOptions };
|