@latitude-data/telemetry 1.1.1 → 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/dist/index.cjs +130 -281
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +50 -38
- package/dist/index.js +130 -281
- package/dist/index.js.map +1 -1
- package/package.json +5 -4
package/dist/index.d.ts
CHANGED
|
@@ -1,27 +1,12 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
1
2
|
import * as otel from '@opentelemetry/api';
|
|
2
3
|
import { TextMapPropagator } from '@opentelemetry/api';
|
|
4
|
+
import { Provider } from 'rosetta-ai';
|
|
3
5
|
import { SpanProcessor, ReadableSpan, SpanExporter, NodeTracerProvider } from '@opentelemetry/sdk-trace-node';
|
|
4
6
|
import * as latitude from '@latitude-data/sdk';
|
|
5
7
|
import { Latitude } from '@latitude-data/sdk';
|
|
6
|
-
import { z } from 'zod';
|
|
7
8
|
import { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-http';
|
|
8
9
|
|
|
9
|
-
interface RedactSpanProcessorOptions {
|
|
10
|
-
attributes: (string | RegExp)[];
|
|
11
|
-
mask?: (attribute: string, value: any) => string;
|
|
12
|
-
}
|
|
13
|
-
declare class RedactSpanProcessor implements SpanProcessor {
|
|
14
|
-
private options;
|
|
15
|
-
constructor(options: RedactSpanProcessorOptions);
|
|
16
|
-
onStart(_span: ReadableSpan, _context: otel.Context): void;
|
|
17
|
-
onEnd(span: ReadableSpan): void;
|
|
18
|
-
forceFlush(): Promise<void>;
|
|
19
|
-
shutdown(): Promise<void>;
|
|
20
|
-
private shouldRedact;
|
|
21
|
-
private redactAttributes;
|
|
22
|
-
}
|
|
23
|
-
declare const DEFAULT_REDACT_SPAN_PROCESSOR: () => RedactSpanProcessor;
|
|
24
|
-
|
|
25
10
|
interface BaseInstrumentation {
|
|
26
11
|
isEnabled(): boolean;
|
|
27
12
|
enable(): void;
|
|
@@ -84,13 +69,13 @@ type StartCompletionSpanOptions = StartSpanOptions & {
|
|
|
84
69
|
provider: string;
|
|
85
70
|
model: string;
|
|
86
71
|
configuration?: Record<string, unknown>;
|
|
87
|
-
input?: Record<string, unknown>[];
|
|
72
|
+
input?: string | Record<string, unknown>[];
|
|
88
73
|
versionUuid?: string;
|
|
89
74
|
promptUuid?: string;
|
|
90
75
|
experimentUuid?: string;
|
|
91
76
|
};
|
|
92
77
|
type EndCompletionSpanOptions = EndSpanOptions & {
|
|
93
|
-
output?: Record<string, unknown>[];
|
|
78
|
+
output?: string | Record<string, unknown>[];
|
|
94
79
|
tokens?: {
|
|
95
80
|
prompt?: number;
|
|
96
81
|
cached?: number;
|
|
@@ -146,32 +131,34 @@ type CaptureOptions = StartSpanOptions & {
|
|
|
146
131
|
versionUuid?: string;
|
|
147
132
|
conversationUuid?: string;
|
|
148
133
|
};
|
|
134
|
+
type ManualInstrumentationOptions = {
|
|
135
|
+
provider?: Provider;
|
|
136
|
+
};
|
|
149
137
|
declare class ManualInstrumentation implements BaseInstrumentation {
|
|
150
138
|
private enabled;
|
|
151
139
|
private readonly tracer;
|
|
152
|
-
|
|
140
|
+
private readonly options;
|
|
141
|
+
constructor(tracer: otel.Tracer, options?: ManualInstrumentationOptions);
|
|
153
142
|
isEnabled(): boolean;
|
|
154
143
|
enable(): void;
|
|
155
144
|
disable(): void;
|
|
156
145
|
resume(ctx: TraceContext): otel.Context;
|
|
157
|
-
private capitalize;
|
|
158
|
-
private toCamelCase;
|
|
159
|
-
private toSnakeCase;
|
|
160
|
-
private toKebabCase;
|
|
161
146
|
private error;
|
|
162
147
|
private span;
|
|
163
|
-
|
|
148
|
+
unknown(ctx: otel.Context, options?: StartSpanOptions): {
|
|
164
149
|
context: otel.Context;
|
|
150
|
+
end: (_options?: EndSpanOptions) => void;
|
|
151
|
+
fail: (_error: Error, _options?: ErrorOptions) => void;
|
|
152
|
+
};
|
|
153
|
+
tool(ctx: otel.Context, options: StartToolSpanOptions): {
|
|
165
154
|
end: (options: EndToolSpanOptions) => void;
|
|
155
|
+
context: otel.Context;
|
|
166
156
|
fail: (_error: Error, _options?: ErrorOptions) => void;
|
|
167
157
|
};
|
|
168
|
-
private attribifyMessageToolCalls;
|
|
169
|
-
private attribifyMessageContent;
|
|
170
|
-
private attribifyMessages;
|
|
171
158
|
private attribifyConfiguration;
|
|
172
159
|
completion(ctx: otel.Context, options: StartCompletionSpanOptions): {
|
|
173
|
-
context: otel.Context;
|
|
174
160
|
end: (options?: EndCompletionSpanOptions) => void;
|
|
161
|
+
context: otel.Context;
|
|
175
162
|
fail: (_error: Error, _options?: ErrorOptions) => void;
|
|
176
163
|
};
|
|
177
164
|
embedding(ctx: otel.Context, options?: StartSpanOptions): {
|
|
@@ -181,8 +168,8 @@ declare class ManualInstrumentation implements BaseInstrumentation {
|
|
|
181
168
|
};
|
|
182
169
|
private attribifyHeaders;
|
|
183
170
|
http(ctx: otel.Context, options: StartHttpSpanOptions): {
|
|
184
|
-
context: otel.Context;
|
|
185
171
|
end: (options: EndHttpSpanOptions) => void;
|
|
172
|
+
context: otel.Context;
|
|
186
173
|
fail: (_error: Error, _options?: ErrorOptions) => void;
|
|
187
174
|
};
|
|
188
175
|
prompt(ctx: otel.Context, { documentLogUuid, versionUuid, promptUuid, projectId, experimentUuid, testDeploymentId, externalId, template, parameters, name, source, ...rest }: PromptSpanOptions): {
|
|
@@ -207,19 +194,40 @@ declare class ManualInstrumentation implements BaseInstrumentation {
|
|
|
207
194
|
};
|
|
208
195
|
}
|
|
209
196
|
|
|
197
|
+
interface RedactSpanProcessorOptions {
|
|
198
|
+
attributes: (string | RegExp)[];
|
|
199
|
+
mask?: (attribute: string, value: any) => string;
|
|
200
|
+
}
|
|
201
|
+
declare class RedactSpanProcessor implements SpanProcessor {
|
|
202
|
+
private options;
|
|
203
|
+
constructor(options: RedactSpanProcessorOptions);
|
|
204
|
+
onStart(_span: ReadableSpan, _context: otel.Context): void;
|
|
205
|
+
onEnd(span: ReadableSpan): void;
|
|
206
|
+
forceFlush(): Promise<void>;
|
|
207
|
+
shutdown(): Promise<void>;
|
|
208
|
+
private shouldRedact;
|
|
209
|
+
private redactAttributes;
|
|
210
|
+
}
|
|
211
|
+
declare const DEFAULT_REDACT_SPAN_PROCESSOR: () => RedactSpanProcessor;
|
|
212
|
+
|
|
210
213
|
type TelemetryContext = otel.Context;
|
|
211
214
|
declare const BACKGROUND: () => otel.Context;
|
|
212
215
|
declare class SpanFactory {
|
|
213
|
-
private telemetry;
|
|
216
|
+
private readonly telemetry;
|
|
214
217
|
constructor(telemetry: ManualInstrumentation);
|
|
215
|
-
|
|
218
|
+
span(options?: StartSpanOptions, ctx?: TelemetryContext): {
|
|
216
219
|
context: otel.Context;
|
|
220
|
+
end: (_options?: EndSpanOptions) => void;
|
|
221
|
+
fail: (_error: Error, _options?: ErrorOptions) => void;
|
|
222
|
+
};
|
|
223
|
+
tool(options: StartToolSpanOptions, ctx?: TelemetryContext): {
|
|
217
224
|
end: (options: EndToolSpanOptions) => void;
|
|
225
|
+
context: otel.Context;
|
|
218
226
|
fail: (_error: Error, _options?: ErrorOptions) => void;
|
|
219
227
|
};
|
|
220
228
|
completion(options: StartCompletionSpanOptions, ctx?: TelemetryContext): {
|
|
221
|
-
context: otel.Context;
|
|
222
229
|
end: (options?: EndCompletionSpanOptions) => void;
|
|
230
|
+
context: otel.Context;
|
|
223
231
|
fail: (_error: Error, _options?: ErrorOptions) => void;
|
|
224
232
|
};
|
|
225
233
|
embedding(options?: StartSpanOptions, ctx?: TelemetryContext): {
|
|
@@ -228,8 +236,8 @@ declare class SpanFactory {
|
|
|
228
236
|
fail: (_error: Error, _options?: ErrorOptions) => void;
|
|
229
237
|
};
|
|
230
238
|
http(options: StartHttpSpanOptions, ctx?: TelemetryContext): {
|
|
231
|
-
context: otel.Context;
|
|
232
239
|
end: (options: EndHttpSpanOptions) => void;
|
|
240
|
+
context: otel.Context;
|
|
233
241
|
fail: (_error: Error, _options?: ErrorOptions) => void;
|
|
234
242
|
};
|
|
235
243
|
prompt(options: PromptSpanOptions, ctx?: TelemetryContext): {
|
|
@@ -249,20 +257,21 @@ declare class SpanFactory {
|
|
|
249
257
|
};
|
|
250
258
|
}
|
|
251
259
|
declare class ContextManager {
|
|
252
|
-
private telemetry;
|
|
260
|
+
private readonly telemetry;
|
|
253
261
|
constructor(telemetry: ManualInstrumentation);
|
|
254
262
|
resume(ctx: TraceContext): otel.Context;
|
|
255
263
|
active(): otel.Context;
|
|
264
|
+
with<A extends unknown[], F extends (...args: A) => ReturnType<F>>(ctx: TelemetryContext, fn: F, thisArg?: ThisParameterType<F>, ...args: A): ReturnType<F>;
|
|
256
265
|
}
|
|
257
266
|
declare class InstrumentationManager {
|
|
258
|
-
private instrumentations;
|
|
267
|
+
private readonly instrumentations;
|
|
259
268
|
constructor(instrumentations: BaseInstrumentation[]);
|
|
260
269
|
enable(): void;
|
|
261
270
|
disable(): void;
|
|
262
271
|
}
|
|
263
272
|
declare class TracerManager {
|
|
264
|
-
private nodeProvider;
|
|
265
|
-
private scopeVersion;
|
|
273
|
+
private readonly nodeProvider;
|
|
274
|
+
private readonly scopeVersion;
|
|
266
275
|
constructor(nodeProvider: NodeTracerProvider, scopeVersion: string);
|
|
267
276
|
get(scope: Instrumentation): otel.Tracer;
|
|
268
277
|
provider(scope: Instrumentation): ScopedTracerProvider;
|
|
@@ -283,6 +292,7 @@ declare enum Instrumentation {
|
|
|
283
292
|
Langchain = "langchain",
|
|
284
293
|
Latitude = "latitude",
|
|
285
294
|
LlamaIndex = "llamaindex",
|
|
295
|
+
Manual = "manual",
|
|
286
296
|
OpenAI = "openai",
|
|
287
297
|
TogetherAI = "togetherai",
|
|
288
298
|
VertexAI = "vertexai"
|
|
@@ -305,6 +315,7 @@ type TelemetryOptions = {
|
|
|
305
315
|
[Instrumentation.Langchain]?: {
|
|
306
316
|
callbackManagerModule?: any;
|
|
307
317
|
};
|
|
318
|
+
[Instrumentation.Manual]?: ManualInstrumentationOptions;
|
|
308
319
|
};
|
|
309
320
|
};
|
|
310
321
|
declare class LatitudeTelemetry {
|
|
@@ -316,6 +327,7 @@ declare class LatitudeTelemetry {
|
|
|
316
327
|
readonly context: ContextManager;
|
|
317
328
|
readonly instrumentation: InstrumentationManager;
|
|
318
329
|
readonly tracer: TracerManager;
|
|
330
|
+
private readonly lifecycle;
|
|
319
331
|
constructor(apiKey: string, options?: TelemetryOptions);
|
|
320
332
|
flush(): Promise<void>;
|
|
321
333
|
shutdown(): Promise<void>;
|