@pingops/otel 0.2.6 → 0.4.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.d.cts CHANGED
@@ -1,12 +1,18 @@
1
1
  import { ReadableSpan, Span, SpanProcessor } from "@opentelemetry/sdk-trace-base";
2
2
  import { Attributes, Context, Span as Span$1, TracerProvider } from "@opentelemetry/api";
3
- import { DomainRule, HeaderRedactionConfig } from "@pingops/core";
3
+ import { DomainRule, HttpTransformConfig } from "@pingops/core";
4
4
  import "@opentelemetry/sdk-trace-node";
5
5
  import { Instrumentation, InstrumentationBase, InstrumentationConfig } from "@opentelemetry/instrumentation";
6
6
  import { HttpInstrumentation, HttpInstrumentationConfig } from "@opentelemetry/instrumentation-http";
7
7
 
8
+ //#region src/llm/types.d.ts
9
+ type LlmProvider = "openai" | "anthropic" | "gemini" | "xai";
10
+ interface LlmMonitoringConfig {
11
+ enabled?: boolean;
12
+ streaming?: boolean;
13
+ }
14
+ //#endregion
8
15
  //#region src/config.d.ts
9
-
10
16
  /**
11
17
  * Span export mode to use.
12
18
  *
@@ -22,6 +28,11 @@ type PingopsExportMode = "immediate" | "batched";
22
28
  * Configuration parameters for the PingopsSpanProcessor.
23
29
  */
24
30
  interface PingopsProcessorConfig {
31
+ /**
32
+ * PingOps SDK version to attach on exported spans.
33
+ * Intended to be set by @pingops/sdk.
34
+ */
35
+ sdkVersion?: string;
25
36
  /**
26
37
  * API key for authentication. Can also be set via PINGOPS_API_KEY environment variable.
27
38
  */
@@ -39,14 +50,6 @@ interface PingopsProcessorConfig {
39
50
  * Service name for resource identification (required).
40
51
  */
41
52
  serviceName: string;
42
- /**
43
- * List of headers to include (case-insensitive).
44
- */
45
- headersAllowList?: string[];
46
- /**
47
- * List of headers to exclude (case-insensitive, takes precedence over allow list).
48
- */
49
- headersDenyList?: string[];
50
53
  /**
51
54
  * Capture request body.
52
55
  */
@@ -55,26 +58,6 @@ interface PingopsProcessorConfig {
55
58
  * Capture response body.
56
59
  */
57
60
  captureResponseBody?: boolean;
58
- /**
59
- * Maximum size of request body to capture (bytes).
60
- * Applies to both `http` and `undici` instrumentations.
61
- *
62
- * Note: this is the number of raw bytes observed at the instrumentation layer.
63
- * For compressed bodies, this is the compressed size.
64
- *
65
- * @defaultValue 4096 (4 KB)
66
- */
67
- maxRequestBodySize?: number;
68
- /**
69
- * Maximum size of response body to capture (bytes).
70
- * Applies to both `http` and `undici` instrumentations.
71
- *
72
- * Note: this is the number of raw bytes observed at the instrumentation layer.
73
- * For compressed bodies, this is the compressed size.
74
- *
75
- * @defaultValue 4096 (4 KB)
76
- */
77
- maxResponseBodySize?: number;
78
61
  /**
79
62
  * Domain allow list rules.
80
63
  */
@@ -84,10 +67,14 @@ interface PingopsProcessorConfig {
84
67
  */
85
68
  domainDenyList?: DomainRule[];
86
69
  /**
87
- * Configuration for header value redaction.
88
- * If not provided, default redaction is enabled for sensitive headers.
70
+ * LLM monitoring configuration for GenAI semantic attributes and token usage.
71
+ * Disabled by default.
72
+ */
73
+ llmMonitoring?: LlmMonitoringConfig;
74
+ /**
75
+ * Outbound HTTP transform rules for headers, bodies, and query params.
89
76
  */
90
- headerRedaction?: HeaderRedactionConfig;
77
+ transforms?: HttpTransformConfig;
91
78
  /**
92
79
  * Number of spans to batch before flushing (only used in batched mode).
93
80
  * @defaultValue 50
@@ -198,25 +185,19 @@ declare function getInstrumentations(): Instrumentation[];
198
185
  declare const PingopsSemanticAttributes: {
199
186
  HTTP_REQUEST_BODY: string;
200
187
  HTTP_RESPONSE_BODY: string;
188
+ HTTP_REQUEST_BODY_SIZE: string;
189
+ HTTP_RESPONSE_BODY_SIZE: string;
201
190
  };
202
- interface PingopsInstrumentationConfig {
203
- /**
204
- * Maximum size of request body to capture in bytes
205
- * @defaultValue 4096 (4 KB)
206
- */
207
- maxRequestBodySize?: number;
208
- /**
209
- * Maximum size of response body to capture in bytes
210
- * @defaultValue 4096 (4 KB)
211
- */
212
- maxResponseBodySize?: number;
213
- }
191
+ type PingopsInstrumentationConfig = {};
214
192
  declare const PingopsHttpSemanticAttributes: {
215
193
  HTTP_REQUEST_BODY: string;
216
194
  HTTP_RESPONSE_BODY: string;
195
+ HTTP_REQUEST_BODY_SIZE: string;
196
+ HTTP_RESPONSE_BODY_SIZE: string;
217
197
  };
218
198
  interface PingopsHttpInstrumentationConfig extends HttpInstrumentationConfig, PingopsInstrumentationConfig {}
219
199
  declare class PingopsHttpInstrumentation extends HttpInstrumentation {
200
+ private _llmStateByRequest;
220
201
  constructor(config?: PingopsHttpInstrumentationConfig);
221
202
  /**
222
203
  * HttpInstrumentation's span creation is private, so we wrap the instance method
@@ -266,21 +247,13 @@ interface UndiciResponse {
266
247
  statusCode: number;
267
248
  statusText: string;
268
249
  }
269
- interface IgnoreRequestFunction<T = UndiciRequest> {
270
- (request: T): boolean;
271
- }
272
- interface RequestHookFunction<T = UndiciRequest> {
273
- (span: Span$1, request: T): void;
274
- }
275
- interface ResponseHookFunction<RequestType = UndiciRequest, ResponseType = UndiciResponse> {
276
- (span: Span$1, info: {
277
- request: RequestType;
278
- response: ResponseType;
279
- }): void;
280
- }
281
- interface StartSpanHookFunction<T = UndiciRequest> {
282
- (request: T): Attributes;
283
- }
250
+ type IgnoreRequestFunction<T = UndiciRequest> = (request: T) => boolean;
251
+ type RequestHookFunction<T = UndiciRequest> = (span: Span$1, request: T) => void;
252
+ type ResponseHookFunction<RequestType = UndiciRequest, ResponseType = UndiciResponse> = (span: Span$1, info: {
253
+ request: RequestType;
254
+ response: ResponseType;
255
+ }) => void;
256
+ type StartSpanHookFunction<T = UndiciRequest> = (request: T) => Attributes;
284
257
  interface UndiciInstrumentationConfig<RequestType = UndiciRequest, ResponseType = UndiciResponse> extends InstrumentationConfig {
285
258
  /** Not trace all outgoing requests that matched with custom function */
286
259
  ignoreRequestHook?: IgnoreRequestFunction<RequestType>;
@@ -297,16 +270,6 @@ interface UndiciInstrumentationConfig<RequestType = UndiciRequest, ResponseType
297
270
  requestHeaders?: string[];
298
271
  responseHeaders?: string[];
299
272
  };
300
- /**
301
- * Maximum size of request body to capture in bytes
302
- * @defaultValue 4096 (4 KB)
303
- */
304
- maxRequestBodySize?: number;
305
- /**
306
- * Maximum size of response body to capture in bytes
307
- * @defaultValue 4096 (4 KB)
308
- */
309
- maxResponseBodySize?: number;
310
273
  }
311
274
  //#endregion
312
275
  //#region src/instrumentations/undici/pingops-undici.d.ts
@@ -342,5 +305,5 @@ declare class UndiciInstrumentation extends InstrumentationBase<UndiciInstrument
342
305
  */
343
306
  declare function createUndiciInstrumentation(): UndiciInstrumentation;
344
307
  //#endregion
345
- export { PingopsHttpInstrumentation, type PingopsHttpInstrumentationConfig, PingopsHttpSemanticAttributes, type PingopsInstrumentationConfig, type PingopsProcessorConfig, PingopsSemanticAttributes, PingopsSpanProcessor, createHttpInstrumentation, createUndiciInstrumentation, getInstrumentations, getPingopsTracerProvider, setPingopsTracerProvider, shutdownTracerProvider };
308
+ export { type LlmMonitoringConfig, type LlmProvider, PingopsHttpInstrumentation, type PingopsHttpInstrumentationConfig, PingopsHttpSemanticAttributes, type PingopsInstrumentationConfig, type PingopsProcessorConfig, PingopsSemanticAttributes, PingopsSpanProcessor, createHttpInstrumentation, createUndiciInstrumentation, getInstrumentations, getPingopsTracerProvider, setPingopsTracerProvider, shutdownTracerProvider };
346
309
  //# sourceMappingURL=index.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.cts","names":[],"sources":["../src/config.ts","../src/span-processor.ts","../src/tracer-provider.ts","../src/instrumentations/index.ts","../src/instrumentations/http/pingops-http.ts","../src/instrumentations/http/http.ts","../src/instrumentations/undici/types.ts","../src/instrumentations/undici/pingops-undici.ts","../src/instrumentations/undici/undici.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;;;AAgBA;AAKA;;;;;AAsGgC,KA3GpB,iBAAA,GA2GoB,WAAA,GAAA,SAAA;;;;ACsBnB,UD5HI,sBAAA,CC4HiB;EAmBZ;;;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A,IEGF,aFHE,CAAA,CAAA;EAsdhC,CAAA,OAAA,EEldD,CFkdC,CAAA,EEldG,UFkdH;AAEb;AAGa,UEldI,2BFmdM,CAAA,cEldP,aFkdO,EAAA,eEjdN,cFgdkD,CAAA,SE/czD,qBF+cyD,CAAA;;sBE7c7C,sBAAsB;;EDF5B,WAAA,CAAA,ECIA,mBDJyB,CCIL,WDJK,CAAA;EACtB;EAAR,YAAA,CAAA,ECKM,oBDLN,CCK2B,WDL3B,ECKwC,YDLxC,CAAA;EACR;EAA0B,aAAA,CAAA,ECMX,qBDNW,CCMW,WDNX,CAAA;;;;ECvDZ,uBAAa,CAAA,EAAA;IAuBb,cAAc,CAAA,EAAA,MAAA,EACpB;IAKM,eAAA,CAAA,EAAA,MAAqB,EAAA;EAIrB,CAAA;EAAwB;;;;EAIxB,kBAAA,CAAA,EAAA,MAAoB;EACrB;;;;EAGuC,mBAAA,CAAA,EAAA,MAAA;;;;cCkJ1C,qBAAA,SAA8B,oBAAoB;;;;uBAMzC;;EPpLV,OAAA,CAAA,CAAA,EAAA,IAAA;EAKK,MAAA,CAAA,CAAA,EAAA,IAAA;EAmEG,UAAA,wBAAA,CAAA,CAAA,EAAA,IAAA;EAKD,QAAA,kBAAA;EAMC,QAAA,mBAAA;EAwBL,QAAA,gBAAA;EAAiB,QAAA,gBAAA;;;;ECsBnB,QAAA,eAAqB;EAmBZ,QAAA,UAAA;EAoEN,QAAA,mBAAA;EAAqB,QAAA,qBAAA;EAmCvB,QAAA,gBAAA;;;;;;;;AD3Pd;AAKA;AAmEoB,iBQjEJ,2BAAA,CAAA,CRiEI,EQjE2B,qBRiE3B"}
1
+ {"version":3,"file":"index.d.cts","names":[],"sources":["../src/llm/types.ts","../src/config.ts","../src/span-processor.ts","../src/tracer-provider.ts","../src/instrumentations/index.ts","../src/instrumentations/http/pingops-http.ts","../src/instrumentations/http/http.ts","../src/instrumentations/undici/types.ts","../src/instrumentations/undici/pingops-undici.ts","../src/instrumentations/undici/undici.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AAA,CAAA,IAAA,EKpVnB,MLoVmB,EAAA,OAAA,EKnVhB,CLmVgB,EAAA,GAAA,IAAA;AA1OkB,KKtGjC,oBLsGiC,CAAA,cKrG7B,aLqG6B,EAAA,eKpG5B,cLoG4B,CAAA,GAAA,CAAA,IAAA,EKlGrC,MLkGqC,EAAA,IAAA,EAAA;EAAa,OAAA,EKjGvC,WLiGuC;YKjGhB;;KAG9B,0BAA0B,2BAC3B,MACN;AJkDW,UI9CC,2BJ+CL,CAAA,cI9CI,aJ8CU,EAAA,eI7CT,cJ6CS,CAAA,SI5ChB,qBJ4CgB,CAAA;EA4BV;EA2EM,iBAAA,CAAA,EIjJA,qBJiJ0B,CIjJJ,WJiJW,CAAA;;gBI/IvC,oBAAoB;;EH3CpB,YAAA,CAAA,EG6CC,oBH7CsB,CG6CD,WH7CC,EG6CY,YH7CG,CAAA;;kBG+CpC,sBAAsB;;EFf3B,qBAAA,CAAA,EAAA,OAKZ;EACW;EAiUC,uBAAA,CAAA,EAAA;IAEI,cAAA,CAAA,EAAA,MAAA,EAAA;IAIJ,eAAA,CAAA,EAAA,MAAA,EAA2B;;;;;cGrS3B,qBAAA,SAA8B,oBAAoB;;;;uBAMzC;;ER7FV,OAAA,CAAA,CAAA,EAAA,IAAW;EAEN,MAAA,CAAA,CAAA,EAAA,IAAA;;;;ECaL,QAAA,gBAAiB;EAKZ,QAAA,gBAAA;EAyCG,QAAA,iBAAA;EAKD,QAAA,MAAA;EAMD,QAAA,OAAA;EAKH,QAAA,eAAA;EAwBA,QAAA,UAAA;EAAiB,QAAA,mBAAA;;;;;;;;;;ADrGhC;AAEA;iBSkBgB,2BAAA,CAAA,GAA+B"}
package/dist/index.d.mts CHANGED
@@ -1,12 +1,18 @@
1
1
  import { ReadableSpan, Span, SpanProcessor } from "@opentelemetry/sdk-trace-base";
2
- import { DomainRule, HeaderRedactionConfig } from "@pingops/core";
2
+ import { DomainRule, HttpTransformConfig } from "@pingops/core";
3
3
  import { Attributes, Context, Span as Span$1, TracerProvider } from "@opentelemetry/api";
4
4
  import "@opentelemetry/sdk-trace-node";
5
5
  import { HttpInstrumentation, HttpInstrumentationConfig } from "@opentelemetry/instrumentation-http";
6
6
  import { Instrumentation, InstrumentationBase, InstrumentationConfig } from "@opentelemetry/instrumentation";
7
7
 
8
+ //#region src/llm/types.d.ts
9
+ type LlmProvider = "openai" | "anthropic" | "gemini" | "xai";
10
+ interface LlmMonitoringConfig {
11
+ enabled?: boolean;
12
+ streaming?: boolean;
13
+ }
14
+ //#endregion
8
15
  //#region src/config.d.ts
9
-
10
16
  /**
11
17
  * Span export mode to use.
12
18
  *
@@ -22,6 +28,11 @@ type PingopsExportMode = "immediate" | "batched";
22
28
  * Configuration parameters for the PingopsSpanProcessor.
23
29
  */
24
30
  interface PingopsProcessorConfig {
31
+ /**
32
+ * PingOps SDK version to attach on exported spans.
33
+ * Intended to be set by @pingops/sdk.
34
+ */
35
+ sdkVersion?: string;
25
36
  /**
26
37
  * API key for authentication. Can also be set via PINGOPS_API_KEY environment variable.
27
38
  */
@@ -39,14 +50,6 @@ interface PingopsProcessorConfig {
39
50
  * Service name for resource identification (required).
40
51
  */
41
52
  serviceName: string;
42
- /**
43
- * List of headers to include (case-insensitive).
44
- */
45
- headersAllowList?: string[];
46
- /**
47
- * List of headers to exclude (case-insensitive, takes precedence over allow list).
48
- */
49
- headersDenyList?: string[];
50
53
  /**
51
54
  * Capture request body.
52
55
  */
@@ -55,26 +58,6 @@ interface PingopsProcessorConfig {
55
58
  * Capture response body.
56
59
  */
57
60
  captureResponseBody?: boolean;
58
- /**
59
- * Maximum size of request body to capture (bytes).
60
- * Applies to both `http` and `undici` instrumentations.
61
- *
62
- * Note: this is the number of raw bytes observed at the instrumentation layer.
63
- * For compressed bodies, this is the compressed size.
64
- *
65
- * @defaultValue 4096 (4 KB)
66
- */
67
- maxRequestBodySize?: number;
68
- /**
69
- * Maximum size of response body to capture (bytes).
70
- * Applies to both `http` and `undici` instrumentations.
71
- *
72
- * Note: this is the number of raw bytes observed at the instrumentation layer.
73
- * For compressed bodies, this is the compressed size.
74
- *
75
- * @defaultValue 4096 (4 KB)
76
- */
77
- maxResponseBodySize?: number;
78
61
  /**
79
62
  * Domain allow list rules.
80
63
  */
@@ -84,10 +67,14 @@ interface PingopsProcessorConfig {
84
67
  */
85
68
  domainDenyList?: DomainRule[];
86
69
  /**
87
- * Configuration for header value redaction.
88
- * If not provided, default redaction is enabled for sensitive headers.
70
+ * LLM monitoring configuration for GenAI semantic attributes and token usage.
71
+ * Disabled by default.
72
+ */
73
+ llmMonitoring?: LlmMonitoringConfig;
74
+ /**
75
+ * Outbound HTTP transform rules for headers, bodies, and query params.
89
76
  */
90
- headerRedaction?: HeaderRedactionConfig;
77
+ transforms?: HttpTransformConfig;
91
78
  /**
92
79
  * Number of spans to batch before flushing (only used in batched mode).
93
80
  * @defaultValue 50
@@ -198,25 +185,19 @@ declare function getInstrumentations(): Instrumentation[];
198
185
  declare const PingopsSemanticAttributes: {
199
186
  HTTP_REQUEST_BODY: string;
200
187
  HTTP_RESPONSE_BODY: string;
188
+ HTTP_REQUEST_BODY_SIZE: string;
189
+ HTTP_RESPONSE_BODY_SIZE: string;
201
190
  };
202
- interface PingopsInstrumentationConfig {
203
- /**
204
- * Maximum size of request body to capture in bytes
205
- * @defaultValue 4096 (4 KB)
206
- */
207
- maxRequestBodySize?: number;
208
- /**
209
- * Maximum size of response body to capture in bytes
210
- * @defaultValue 4096 (4 KB)
211
- */
212
- maxResponseBodySize?: number;
213
- }
191
+ type PingopsInstrumentationConfig = {};
214
192
  declare const PingopsHttpSemanticAttributes: {
215
193
  HTTP_REQUEST_BODY: string;
216
194
  HTTP_RESPONSE_BODY: string;
195
+ HTTP_REQUEST_BODY_SIZE: string;
196
+ HTTP_RESPONSE_BODY_SIZE: string;
217
197
  };
218
198
  interface PingopsHttpInstrumentationConfig extends HttpInstrumentationConfig, PingopsInstrumentationConfig {}
219
199
  declare class PingopsHttpInstrumentation extends HttpInstrumentation {
200
+ private _llmStateByRequest;
220
201
  constructor(config?: PingopsHttpInstrumentationConfig);
221
202
  /**
222
203
  * HttpInstrumentation's span creation is private, so we wrap the instance method
@@ -266,21 +247,13 @@ interface UndiciResponse {
266
247
  statusCode: number;
267
248
  statusText: string;
268
249
  }
269
- interface IgnoreRequestFunction<T = UndiciRequest> {
270
- (request: T): boolean;
271
- }
272
- interface RequestHookFunction<T = UndiciRequest> {
273
- (span: Span$1, request: T): void;
274
- }
275
- interface ResponseHookFunction<RequestType = UndiciRequest, ResponseType = UndiciResponse> {
276
- (span: Span$1, info: {
277
- request: RequestType;
278
- response: ResponseType;
279
- }): void;
280
- }
281
- interface StartSpanHookFunction<T = UndiciRequest> {
282
- (request: T): Attributes;
283
- }
250
+ type IgnoreRequestFunction<T = UndiciRequest> = (request: T) => boolean;
251
+ type RequestHookFunction<T = UndiciRequest> = (span: Span$1, request: T) => void;
252
+ type ResponseHookFunction<RequestType = UndiciRequest, ResponseType = UndiciResponse> = (span: Span$1, info: {
253
+ request: RequestType;
254
+ response: ResponseType;
255
+ }) => void;
256
+ type StartSpanHookFunction<T = UndiciRequest> = (request: T) => Attributes;
284
257
  interface UndiciInstrumentationConfig<RequestType = UndiciRequest, ResponseType = UndiciResponse> extends InstrumentationConfig {
285
258
  /** Not trace all outgoing requests that matched with custom function */
286
259
  ignoreRequestHook?: IgnoreRequestFunction<RequestType>;
@@ -297,16 +270,6 @@ interface UndiciInstrumentationConfig<RequestType = UndiciRequest, ResponseType
297
270
  requestHeaders?: string[];
298
271
  responseHeaders?: string[];
299
272
  };
300
- /**
301
- * Maximum size of request body to capture in bytes
302
- * @defaultValue 4096 (4 KB)
303
- */
304
- maxRequestBodySize?: number;
305
- /**
306
- * Maximum size of response body to capture in bytes
307
- * @defaultValue 4096 (4 KB)
308
- */
309
- maxResponseBodySize?: number;
310
273
  }
311
274
  //#endregion
312
275
  //#region src/instrumentations/undici/pingops-undici.d.ts
@@ -342,5 +305,5 @@ declare class UndiciInstrumentation extends InstrumentationBase<UndiciInstrument
342
305
  */
343
306
  declare function createUndiciInstrumentation(): UndiciInstrumentation;
344
307
  //#endregion
345
- export { PingopsHttpInstrumentation, type PingopsHttpInstrumentationConfig, PingopsHttpSemanticAttributes, type PingopsInstrumentationConfig, type PingopsProcessorConfig, PingopsSemanticAttributes, PingopsSpanProcessor, createHttpInstrumentation, createUndiciInstrumentation, getInstrumentations, getPingopsTracerProvider, setPingopsTracerProvider, shutdownTracerProvider };
308
+ export { type LlmMonitoringConfig, type LlmProvider, PingopsHttpInstrumentation, type PingopsHttpInstrumentationConfig, PingopsHttpSemanticAttributes, type PingopsInstrumentationConfig, type PingopsProcessorConfig, PingopsSemanticAttributes, PingopsSpanProcessor, createHttpInstrumentation, createUndiciInstrumentation, getInstrumentations, getPingopsTracerProvider, setPingopsTracerProvider, shutdownTracerProvider };
346
309
  //# sourceMappingURL=index.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.mts","names":[],"sources":["../src/config.ts","../src/span-processor.ts","../src/tracer-provider.ts","../src/instrumentations/index.ts","../src/instrumentations/http/pingops-http.ts","../src/instrumentations/http/http.ts","../src/instrumentations/undici/types.ts","../src/instrumentations/undici/pingops-undici.ts","../src/instrumentations/undici/undici.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;;;AAgBA;AAKA;;;;;AAsGgC,KA3GpB,iBAAA,GA2GoB,WAAA,GAAA,SAAA;;;;ACsBnB,UD5HI,sBAAA,CC4HiB;EAmBZ;;;EAuGR,MAAA,CAAA,EAAA,MAAA;EAoGe;;;EA9N6B,OAAA,EAAA,MAAA;;;;AC9C1D;EA6BgB,KAAA,CAAA,EAAA,OAAA;EA2EM;;;;EC1LN;;;;ECsBH;AAKb;AAsdA;EAEiB,eAAA,CAAA,EAAA,MAAA,EAAA;EAGJ;;;;EC/cG;;;EAEb,mBAAA,CAAA,EAAA,OAAA;EAA0B;;;;ACvD7B;AAuBA;AAMA;AAIA;;EACS,kBAAA,CAAA,EAA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C,YDLxC,CAAA;EACR;EAA0B,aAAA,CAAA,ECMX,qBDNW,CCMW,WDNX,CAAA;;;;ECvDZ,uBAAa,CAAA,EAAA;IAuBb,cAAc,CAAA,EAAA,MAAA,EACpB;IAKM,eAAA,CAAA,EAAA,MAAqB,EAAA;EAIrB,CAAA;EAAwB;;;;EAIxB,kBAAA,CAAA,EAAA,MAAoB;EACrB;;;;EAGuC,mBAAA,CAAA,EAAA,MAAA;;;;cCkJ1C,qBAAA,SAA8B,oBAAoB;;;;uBAMzC;;EPpLV,OAAA,CAAA,CAAA,EAAA,IAAA;EAKK,MAAA,CAAA,CAAA,EAAA,IAAA;EAmEG,UAAA,wBAAA,CAAA,CAAA,EAAA,IAAA;EAKD,QAAA,kBAAA;EAMC,QAAA,mBAAA;EAwBL,QAAA,gBAAA;EAAiB,QAAA,gBAAA;;;;ECsBnB,QAAA,eAAqB;EAmBZ,QAAA,UAAA;EAoEN,QAAA,mBAAA;EAAqB,QAAA,qBAAA;EAmCvB,QAAA,gBAAA;;;;;;;;AD3Pd;AAKA;AAmEoB,iBQjEJ,2BAAA,CAAA,CRiEI,EQjE2B,qBRiE3B"}
1
+ {"version":3,"file":"index.d.mts","names":[],"sources":["../src/llm/types.ts","../src/config.ts","../src/span-processor.ts","../src/tracer-provider.ts","../src/instrumentations/index.ts","../src/instrumentations/http/pingops-http.ts","../src/instrumentations/http/http.ts","../src/instrumentations/undici/types.ts","../src/instrumentations/undici/pingops-undici.ts","../src/instrumentations/undici/undici.ts"],"sourcesContent":[],"mappings":";;;;;;;;KAEY,WAAA;UAEK,mBAAA;;;;;;;;;AAFjB;AAEA;;;;ACaA;AAKA;AAyCoB,KA9CR,iBAAA,GA8CQ,WAAA,GAAA,SAAA;;;;AAwCL,UAjFE,sBAAA,CAiFF;EAAiB;;;;ECsCnB,UAAA,CAAA,EAAA,MAAA;EAkBS;;;EAsGR,MAAA,CAAA,EAAA,MAAA;EAgGe;;;EAxN6B,OAAA,EAAA,MAAA;;;;AC1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