@pingops/otel 0.1.1 → 0.1.2

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.
Files changed (53) hide show
  1. package/dist/index.cjs +1018 -0
  2. package/dist/index.cjs.map +1 -0
  3. package/dist/index.d.cts +342 -0
  4. package/dist/index.d.cts.map +1 -0
  5. package/dist/index.d.mts +342 -0
  6. package/dist/index.d.mts.map +1 -0
  7. package/dist/index.mjs +981 -0
  8. package/dist/index.mjs.map +1 -0
  9. package/package.json +18 -6
  10. package/dist/config-store.d.ts +0 -26
  11. package/dist/config-store.d.ts.map +0 -1
  12. package/dist/config-store.js +0 -26
  13. package/dist/config-store.js.map +0 -1
  14. package/dist/config.d.ts +0 -83
  15. package/dist/config.d.ts.map +0 -1
  16. package/dist/config.js +0 -5
  17. package/dist/config.js.map +0 -1
  18. package/dist/index.d.ts +0 -11
  19. package/dist/index.d.ts.map +0 -1
  20. package/dist/index.js +0 -10
  21. package/dist/index.js.map +0 -1
  22. package/dist/instrumentations/http/http.d.ts +0 -13
  23. package/dist/instrumentations/http/http.d.ts.map +0 -1
  24. package/dist/instrumentations/http/http.js +0 -28
  25. package/dist/instrumentations/http/http.js.map +0 -1
  26. package/dist/instrumentations/http/pingops-http.d.ts +0 -52
  27. package/dist/instrumentations/http/pingops-http.d.ts.map +0 -1
  28. package/dist/instrumentations/http/pingops-http.js +0 -381
  29. package/dist/instrumentations/http/pingops-http.js.map +0 -1
  30. package/dist/instrumentations/index.d.ts +0 -17
  31. package/dist/instrumentations/index.d.ts.map +0 -1
  32. package/dist/instrumentations/index.js +0 -28
  33. package/dist/instrumentations/index.js.map +0 -1
  34. package/dist/instrumentations/undici/pingops-undici.d.ts +0 -25
  35. package/dist/instrumentations/undici/pingops-undici.d.ts.map +0 -1
  36. package/dist/instrumentations/undici/pingops-undici.js +0 -568
  37. package/dist/instrumentations/undici/pingops-undici.js.map +0 -1
  38. package/dist/instrumentations/undici/types.d.ts +0 -106
  39. package/dist/instrumentations/undici/types.d.ts.map +0 -1
  40. package/dist/instrumentations/undici/types.js +0 -2
  41. package/dist/instrumentations/undici/types.js.map +0 -1
  42. package/dist/instrumentations/undici/undici.d.ts +0 -12
  43. package/dist/instrumentations/undici/undici.d.ts.map +0 -1
  44. package/dist/instrumentations/undici/undici.js +0 -26
  45. package/dist/instrumentations/undici/undici.js.map +0 -1
  46. package/dist/span-processor.d.ts +0 -78
  47. package/dist/span-processor.d.ts.map +0 -1
  48. package/dist/span-processor.js +0 -282
  49. package/dist/span-processor.js.map +0 -1
  50. package/dist/tracer-provider.d.ts +0 -57
  51. package/dist/tracer-provider.d.ts.map +0 -1
  52. package/dist/tracer-provider.js +0 -184
  53. package/dist/tracer-provider.js.map +0 -1
@@ -1,106 +0,0 @@
1
- import type { InstrumentationConfig } from "@opentelemetry/instrumentation";
2
- import type { Attributes, Span } from "@opentelemetry/api";
3
- export interface UndiciRequest {
4
- origin: string;
5
- method: string;
6
- path: string;
7
- /**
8
- * Serialized string of headers in the form `name: value\r\n` for v5
9
- * Array of strings `[key1, value1, key2, value2]`, where values are
10
- * `string | string[]` for v6
11
- */
12
- headers: string | (string | string[])[];
13
- /**
14
- * Helper method to add headers (from v6)
15
- */
16
- addHeader: (name: string, value: string) => void;
17
- throwOnError: boolean;
18
- completed: boolean;
19
- aborted: boolean;
20
- idempotent: boolean;
21
- contentLength: number | null;
22
- contentType: string | null;
23
- body: any;
24
- }
25
- export interface UndiciResponse {
26
- headers: Buffer[];
27
- statusCode: number;
28
- statusText: string;
29
- }
30
- export interface IgnoreRequestFunction<T = UndiciRequest> {
31
- (request: T): boolean;
32
- }
33
- export interface RequestHookFunction<T = UndiciRequest> {
34
- (span: Span, request: T): void;
35
- }
36
- export interface ResponseHookFunction<RequestType = UndiciRequest, ResponseType = UndiciResponse> {
37
- (span: Span, info: {
38
- request: RequestType;
39
- response: ResponseType;
40
- }): void;
41
- }
42
- export interface StartSpanHookFunction<T = UndiciRequest> {
43
- (request: T): Attributes;
44
- }
45
- export interface UndiciInstrumentationConfig<RequestType = UndiciRequest, ResponseType = UndiciResponse> extends InstrumentationConfig {
46
- /** Not trace all outgoing requests that matched with custom function */
47
- ignoreRequestHook?: IgnoreRequestFunction<RequestType>;
48
- /** Function for adding custom attributes before request is handled */
49
- requestHook?: RequestHookFunction<RequestType>;
50
- /** Function called once response headers have been received */
51
- responseHook?: ResponseHookFunction<RequestType, ResponseType>;
52
- /** Function for adding custom attributes before a span is started */
53
- startSpanHook?: StartSpanHookFunction<RequestType>;
54
- /** Require parent to create span for outgoing requests */
55
- requireParentforSpans?: boolean;
56
- /** Map the following HTTP headers to span attributes. */
57
- headersToSpanAttributes?: {
58
- requestHeaders?: string[];
59
- responseHeaders?: string[];
60
- };
61
- /**
62
- * Maximum size of request body to capture in bytes
63
- * @defaultValue 4096 (4 KB)
64
- */
65
- maxRequestBodySize?: number;
66
- /**
67
- * Maximum size of response body to capture in bytes
68
- * @defaultValue 4096 (4 KB)
69
- */
70
- maxResponseBodySize?: number;
71
- }
72
- export interface ListenerRecord {
73
- name: string;
74
- unsubscribe: () => void;
75
- }
76
- export interface RequestMessage {
77
- request: UndiciRequest;
78
- }
79
- export interface RequestHeadersMessage {
80
- request: UndiciRequest;
81
- socket: any;
82
- }
83
- export interface ResponseHeadersMessage {
84
- request: UndiciRequest;
85
- response: UndiciResponse;
86
- }
87
- export interface RequestTrailersMessage {
88
- request: UndiciRequest;
89
- response: UndiciResponse;
90
- }
91
- export interface RequestErrorMessage {
92
- request: UndiciRequest;
93
- error: Error;
94
- }
95
- export interface RequestBodyChunkSentMessage {
96
- request: UndiciRequest;
97
- chunk: Buffer;
98
- }
99
- export interface RequestBodySentMessage {
100
- request: UndiciRequest;
101
- }
102
- export interface RequestBodyChunkReceivedMessage {
103
- request: UndiciRequest;
104
- chunk: Buffer;
105
- }
106
- //# sourceMappingURL=types.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../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AAO,EAAE,aAAa,CAAC;IACvB,QAAQ,EAAE,cAAc,CAAC;CAC1B;AAED,MAAM,WAAW,mBAAmB;IAClC,OAAO,EAAE,aAAa,CAAC;IACvB,KAAK,EAAE,KAAK,CAAC;CACd;AAED,MAAM,WAAW,2BAA2B;IAC1C,OAAO,EAAE,aAAa,CAAC;IACvB,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,sBAAsB;IACrC,OAAO,EAAE,aAAa,CAAC;CACxB;AAED,MAAM,WAAW,+BAA+B;IAC9C,OAAO,EAAE,aAAa,CAAC;IACvB,KAAK,EAAE,MAAM,CAAC;CACf"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=types.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/instrumentations/undici/types.ts"],"names":[],"mappings":""}
@@ -1,12 +0,0 @@
1
- /**
2
- * Undici instrumentation for OpenTelemetry
3
- */
4
- import { UndiciInstrumentation } from "./pingops-undici";
5
- /**
6
- * Creates an Undici instrumentation instance
7
- *
8
- * @param isGlobalInstrumentationEnabled - Function that checks if global instrumentation is enabled
9
- * @returns UndiciInstrumentation instance
10
- */
11
- export declare function createUndiciInstrumentation(isGlobalInstrumentationEnabled: () => boolean): UndiciInstrumentation;
12
- //# sourceMappingURL=undici.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"undici.d.ts","sourceRoot":"","sources":["../../../src/instrumentations/undici/undici.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AAIzD;;;;;GAKG;AACH,wBAAgB,2BAA2B,CACzC,8BAA8B,EAAE,MAAM,OAAO,GAC5C,qBAAqB,CAYvB"}
@@ -1,26 +0,0 @@
1
- /**
2
- * Undici instrumentation for OpenTelemetry
3
- */
4
- import { UndiciInstrumentation } from "./pingops-undici";
5
- import { context } from "@opentelemetry/api";
6
- import { PINGOPS_HTTP_ENABLED } from "@pingops/core";
7
- /**
8
- * Creates an Undici instrumentation instance
9
- *
10
- * @param isGlobalInstrumentationEnabled - Function that checks if global instrumentation is enabled
11
- * @returns UndiciInstrumentation instance
12
- */
13
- export function createUndiciInstrumentation(isGlobalInstrumentationEnabled) {
14
- return new UndiciInstrumentation({
15
- enabled: true,
16
- ignoreRequestHook: () => {
17
- // If global instrumentation is enabled, instrument all requests
18
- if (isGlobalInstrumentationEnabled()) {
19
- return false;
20
- }
21
- // If global instrumentation is NOT enabled, only instrument when PINGOPS_HTTP_ENABLED is true
22
- return context.active().getValue(PINGOPS_HTTP_ENABLED) !== true;
23
- },
24
- });
25
- }
26
- //# sourceMappingURL=undici.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"undici.js","sourceRoot":"","sources":["../../../src/instrumentations/undici/undici.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAC7C,OAAO,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AAErD;;;;;GAKG;AACH,MAAM,UAAU,2BAA2B,CACzC,8BAA6C;IAE7C,OAAO,IAAI,qBAAqB,CAAC;QAC/B,OAAO,EAAE,IAAI;QACb,iBAAiB,EAAE,GAAG,EAAE;YACtB,gEAAgE;YAChE,IAAI,8BAA8B,EAAE,EAAE,CAAC;gBACrC,OAAO,KAAK,CAAC;YACf,CAAC;YACD,8FAA8F;YAC9F,OAAO,OAAO,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,oBAAoB,CAAC,KAAK,IAAI,CAAC;QAClE,CAAC;KACF,CAAC,CAAC;AACL,CAAC"}
@@ -1,78 +0,0 @@
1
- /**
2
- * PingopsSpanProcessor - OpenTelemetry SpanProcessor implementation
3
- * Observes finished spans and sends eligible ones to PingOps backend
4
- *
5
- * This processor provides:
6
- * - Automatic filtering of spans (CLIENT spans with HTTP/GenAI attributes only)
7
- * - Domain and header filtering based on configuration
8
- * - Batched or immediate export modes using OTLP exporters
9
- * - Fire-and-forget transport (never blocks application)
10
- *
11
- * @example
12
- * ```typescript
13
- * import { NodeSDK } from '@opentelemetry/sdk-node';
14
- * import { PingopsSpanProcessor } from '@pingops/otel';
15
- *
16
- * const sdk = new NodeSDK({
17
- * spanProcessors: [
18
- * new PingopsSpanProcessor({
19
- * apiKey: 'your-api-key',
20
- * baseUrl: 'https://api.pingops.com',
21
- * serviceName: 'my-service',
22
- * exportMode: 'batched', // or 'immediate'
23
- * domainAllowList: [
24
- * { domain: 'api.example.com' }
25
- * ]
26
- * })
27
- * ]
28
- * });
29
- *
30
- * sdk.start();
31
- * ```
32
- */
33
- import type { SpanProcessor, ReadableSpan, Span } from "@opentelemetry/sdk-trace-base";
34
- import type { Context } from "@opentelemetry/api";
35
- import type { PingopsProcessorConfig } from "./config";
36
- /**
37
- * OpenTelemetry span processor for sending spans to PingOps backend.
38
- *
39
- * This processor wraps OpenTelemetry's built-in processors (BatchSpanProcessor or SimpleSpanProcessor)
40
- * and applies filtering before passing spans to the OTLP exporter.
41
- */
42
- export declare class PingopsSpanProcessor implements SpanProcessor {
43
- private processor;
44
- private config;
45
- /**
46
- * Creates a new PingopsSpanProcessor instance.
47
- *
48
- * @param config - Configuration parameters for the processor
49
- */
50
- constructor(config: PingopsProcessorConfig);
51
- /**
52
- * Called when a span starts - extracts parent attributes from context and adds them to the span
53
- */
54
- onStart(span: Span, parentContext: Context): void;
55
- /**
56
- * Called when a span ends. Filters the span and passes it to the underlying processor if eligible.
57
- *
58
- * This method:
59
- * 1. Checks if the span is eligible (CLIENT + HTTP/GenAI attributes)
60
- * 2. Applies domain filtering (determines if span should be exported)
61
- * 3. Applies header filtering via FilteredSpan wrapper (domain-specific and global rules)
62
- * 4. If eligible, passes filtered span to underlying OTLP processor for export
63
- */
64
- onEnd(span: ReadableSpan): void;
65
- /**
66
- * Forces an immediate flush of all pending spans.
67
- *
68
- * @returns Promise that resolves when all pending operations are complete
69
- */
70
- forceFlush(): Promise<void>;
71
- /**
72
- * Gracefully shuts down the processor, ensuring all pending operations are completed.
73
- *
74
- * @returns Promise that resolves when shutdown is complete
75
- */
76
- shutdown(): Promise<void>;
77
- }
78
- //# sourceMappingURL=span-processor.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"span-processor.d.ts","sourceRoot":"","sources":["../src/span-processor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAEH,OAAO,KAAK,EACV,aAAa,EACb,YAAY,EACZ,IAAI,EACL,MAAM,+BAA+B,CAAC;AAMvC,OAAO,KAAK,EAAE,OAAO,EAAc,MAAM,oBAAoB,CAAC;AAS9D,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,UAAU,CAAC;AA8DvD;;;;;GAKG;AACH,qBAAa,oBAAqB,YAAW,aAAa;IACxD,OAAO,CAAC,SAAS,CAAgB;IACjC,OAAO,CAAC,MAAM,CAQZ;IAEF;;;;OAIG;gBACS,MAAM,EAAE,sBAAsB;IA2D1C;;OAEG;IACH,OAAO,CAAC,IAAI,EAAE,IAAI,EAAE,aAAa,EAAE,OAAO,GAAG,IAAI;IA0BjD;;;;;;;;OAQG;IACH,KAAK,CAAC,IAAI,EAAE,YAAY,GAAG,IAAI;IA2F/B;;;;OAIG;IACU,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAaxC;;;;OAIG;IACU,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;CAYvC"}
@@ -1,282 +0,0 @@
1
- /**
2
- * PingopsSpanProcessor - OpenTelemetry SpanProcessor implementation
3
- * Observes finished spans and sends eligible ones to PingOps backend
4
- *
5
- * This processor provides:
6
- * - Automatic filtering of spans (CLIENT spans with HTTP/GenAI attributes only)
7
- * - Domain and header filtering based on configuration
8
- * - Batched or immediate export modes using OTLP exporters
9
- * - Fire-and-forget transport (never blocks application)
10
- *
11
- * @example
12
- * ```typescript
13
- * import { NodeSDK } from '@opentelemetry/sdk-node';
14
- * import { PingopsSpanProcessor } from '@pingops/otel';
15
- *
16
- * const sdk = new NodeSDK({
17
- * spanProcessors: [
18
- * new PingopsSpanProcessor({
19
- * apiKey: 'your-api-key',
20
- * baseUrl: 'https://api.pingops.com',
21
- * serviceName: 'my-service',
22
- * exportMode: 'batched', // or 'immediate'
23
- * domainAllowList: [
24
- * { domain: 'api.example.com' }
25
- * ]
26
- * })
27
- * ]
28
- * });
29
- *
30
- * sdk.start();
31
- * ```
32
- */
33
- import { BatchSpanProcessor, SimpleSpanProcessor, } from "@opentelemetry/sdk-trace-base";
34
- import { OTLPTraceExporter } from "@opentelemetry/exporter-trace-otlp-http";
35
- import { isSpanEligible, shouldCaptureSpan, createLogger, getPropagatedAttributesFromContext, extractSpanPayload, } from "@pingops/core";
36
- import { setGlobalConfig } from "./config-store";
37
- const logger = createLogger("[PingOps Processor]");
38
- /**
39
- * Creates a filtered span wrapper that applies header filtering to attributes
40
- *
41
- * This wrapper applies both domain-specific and global header filtering:
42
- * - Uses domain allow list to determine domain-specific header rules
43
- * - Applies global header allow/deny lists
44
- * - Filters headers from http.request.header and http.response.header attributes
45
- *
46
- * Uses a Proxy to automatically forward all properties and methods to the original span,
47
- * except for 'attributes' which returns the filtered version. This approach is future-proof
48
- * and will work with any new methods or properties added to ReadableSpan.
49
- *
50
- * This allows us to filter headers before the span is serialized by OTLP exporter
51
- */
52
- function createFilteredSpan(span, domainAllowList, globalHeadersAllowList, globalHeadersDenyList, globalCaptureRequestBody, globalCaptureResponseBody) {
53
- // Use extractSpanPayload to get filtered attributes
54
- // This handles both domain-specific header rules and global header filtering
55
- // as well as body capture filtering
56
- const payload = extractSpanPayload(span, domainAllowList, globalHeadersAllowList, globalHeadersDenyList, globalCaptureRequestBody, globalCaptureResponseBody);
57
- const filteredAttributes = (payload?.attributes ??
58
- span.attributes);
59
- logger.debug("Payload", { payload });
60
- // Create a Proxy that intercepts 'attributes' access and forwards everything else
61
- return new Proxy(span, {
62
- get(target, prop) {
63
- // Intercept 'attributes' to return filtered version
64
- if (prop === "attributes") {
65
- return filteredAttributes;
66
- }
67
- // Forward all other property/method access to the original span
68
- const value = target[prop];
69
- // If it's a function, bind it to the original target to preserve 'this' context
70
- if (typeof value === "function") {
71
- return value.bind(target);
72
- }
73
- return value;
74
- },
75
- });
76
- }
77
- /**
78
- * OpenTelemetry span processor for sending spans to PingOps backend.
79
- *
80
- * This processor wraps OpenTelemetry's built-in processors (BatchSpanProcessor or SimpleSpanProcessor)
81
- * and applies filtering before passing spans to the OTLP exporter.
82
- */
83
- export class PingopsSpanProcessor {
84
- processor;
85
- config;
86
- /**
87
- * Creates a new PingopsSpanProcessor instance.
88
- *
89
- * @param config - Configuration parameters for the processor
90
- */
91
- constructor(config) {
92
- const exportMode = config.exportMode ?? "batched";
93
- // Get API key from config or environment
94
- const apiKey = config.apiKey || process.env.PINGOPS_API_KEY || "";
95
- // Create OTLP exporter pointing to PingOps backend
96
- const exporter = new OTLPTraceExporter({
97
- url: `${config.baseUrl}/v1/traces`,
98
- headers: {
99
- Authorization: apiKey ? `Bearer ${apiKey}` : "",
100
- "Content-Type": "application/json",
101
- },
102
- timeoutMillis: 5000,
103
- });
104
- // Create underlying processor based on export mode
105
- if (exportMode === "immediate") {
106
- this.processor = new SimpleSpanProcessor(exporter);
107
- }
108
- else {
109
- this.processor = new BatchSpanProcessor(exporter, {
110
- maxExportBatchSize: config.batchSize ?? 50,
111
- scheduledDelayMillis: config.batchTimeout ?? 5000,
112
- });
113
- }
114
- this.config = {
115
- debug: config.debug ?? false,
116
- headersAllowList: config.headersAllowList,
117
- headersDenyList: config.headersDenyList,
118
- domainAllowList: config.domainAllowList,
119
- domainDenyList: config.domainDenyList,
120
- captureRequestBody: config.captureRequestBody,
121
- captureResponseBody: config.captureResponseBody,
122
- };
123
- // Register global config for instrumentations to access
124
- setGlobalConfig({
125
- captureRequestBody: config.captureRequestBody,
126
- captureResponseBody: config.captureResponseBody,
127
- domainAllowList: config.domainAllowList,
128
- });
129
- logger.info("Initialized PingopsSpanProcessor", {
130
- baseUrl: config.baseUrl,
131
- exportMode,
132
- batchSize: config.batchSize,
133
- batchTimeout: config.batchTimeout,
134
- hasDomainAllowList: !!config.domainAllowList && config.domainAllowList.length > 0,
135
- hasDomainDenyList: !!config.domainDenyList && config.domainDenyList.length > 0,
136
- hasHeadersAllowList: !!config.headersAllowList && config.headersAllowList.length > 0,
137
- hasHeadersDenyList: !!config.headersDenyList && config.headersDenyList.length > 0,
138
- });
139
- }
140
- /**
141
- * Called when a span starts - extracts parent attributes from context and adds them to the span
142
- */
143
- onStart(span, parentContext) {
144
- const spanContext = span.spanContext();
145
- logger.debug("Span started", {
146
- spanName: span.name,
147
- spanId: spanContext.spanId,
148
- traceId: spanContext.traceId,
149
- });
150
- // Extract propagated attributes from context and set them on the span
151
- const propagatedAttributes = getPropagatedAttributesFromContext(parentContext);
152
- if (Object.keys(propagatedAttributes).length > 0) {
153
- for (const [key, value] of Object.entries(propagatedAttributes)) {
154
- // Type guard: value must be string or string[] for OpenTelemetry attributes
155
- if (typeof value === "string" || Array.isArray(value)) {
156
- span.setAttribute(key, value);
157
- }
158
- }
159
- logger.debug("Set propagated attributes on span", {
160
- spanName: span.name,
161
- attributeKeys: Object.keys(propagatedAttributes),
162
- });
163
- }
164
- this.processor.onStart(span, parentContext);
165
- }
166
- /**
167
- * Called when a span ends. Filters the span and passes it to the underlying processor if eligible.
168
- *
169
- * This method:
170
- * 1. Checks if the span is eligible (CLIENT + HTTP/GenAI attributes)
171
- * 2. Applies domain filtering (determines if span should be exported)
172
- * 3. Applies header filtering via FilteredSpan wrapper (domain-specific and global rules)
173
- * 4. If eligible, passes filtered span to underlying OTLP processor for export
174
- */
175
- onEnd(span) {
176
- const spanContext = span.spanContext();
177
- logger.debug("Span ended, processing", {
178
- spanName: span.name,
179
- spanId: spanContext.spanId,
180
- traceId: spanContext.traceId,
181
- spanKind: span.kind,
182
- });
183
- try {
184
- // Step 1: Check if span is eligible (CLIENT + HTTP/GenAI attributes)
185
- if (!isSpanEligible(span)) {
186
- logger.debug("Span not eligible, skipping", {
187
- spanName: span.name,
188
- spanId: spanContext.spanId,
189
- reason: "not CLIENT or missing HTTP/GenAI attributes",
190
- });
191
- return;
192
- }
193
- // Step 2: Extract URL for domain filtering
194
- const attributes = span.attributes;
195
- const url = attributes["http.url"] ||
196
- attributes["url.full"] ||
197
- (attributes["server.address"]
198
- ? `https://${String(attributes["server.address"])}`
199
- : "");
200
- logger.debug("Extracted URL for domain filtering", {
201
- spanName: span.name,
202
- url,
203
- hasHttpUrl: !!attributes["http.url"],
204
- hasUrlFull: !!attributes["url.full"],
205
- hasServerAddress: !!attributes["server.address"],
206
- });
207
- // Step 3: Apply domain filtering
208
- if (url) {
209
- const shouldCapture = shouldCaptureSpan(url, this.config.domainAllowList, this.config.domainDenyList);
210
- if (!shouldCapture) {
211
- logger.info("Span filtered out by domain rules", {
212
- spanName: span.name,
213
- spanId: spanContext.spanId,
214
- url,
215
- });
216
- return;
217
- }
218
- }
219
- else {
220
- logger.debug("No URL found for domain filtering, proceeding", {
221
- spanName: span.name,
222
- });
223
- }
224
- // Step 4: Apply filtering (header filtering with domain-specific rules) by wrapping the span
225
- const filteredSpan = createFilteredSpan(span, this.config.domainAllowList, this.config.headersAllowList, this.config.headersDenyList, this.config.captureRequestBody, this.config.captureResponseBody);
226
- // Step 5: Span passed all filters, pass filtered span to underlying processor for export
227
- this.processor.onEnd(filteredSpan);
228
- logger.info("Span passed all filters and queued for export", {
229
- spanName: span.name,
230
- spanId: spanContext.spanId,
231
- traceId: spanContext.traceId,
232
- url,
233
- hasHeaderFiltering: !!(this.config.headersAllowList || this.config.headersDenyList),
234
- });
235
- }
236
- catch (error) {
237
- // Defensive error handling - never crash the app
238
- logger.error("Error processing span", {
239
- spanName: span.name,
240
- spanId: spanContext.spanId,
241
- error: error instanceof Error ? error.message : String(error),
242
- });
243
- }
244
- }
245
- /**
246
- * Forces an immediate flush of all pending spans.
247
- *
248
- * @returns Promise that resolves when all pending operations are complete
249
- */
250
- async forceFlush() {
251
- logger.info("Force flushing spans");
252
- try {
253
- await this.processor.forceFlush();
254
- logger.info("Force flush complete");
255
- }
256
- catch (error) {
257
- logger.error("Error during force flush", {
258
- error: error instanceof Error ? error.message : String(error),
259
- });
260
- throw error;
261
- }
262
- }
263
- /**
264
- * Gracefully shuts down the processor, ensuring all pending operations are completed.
265
- *
266
- * @returns Promise that resolves when shutdown is complete
267
- */
268
- async shutdown() {
269
- logger.info("Shutting down processor");
270
- try {
271
- await this.processor.shutdown();
272
- logger.info("Processor shutdown complete");
273
- }
274
- catch (error) {
275
- logger.error("Error during processor shutdown", {
276
- error: error instanceof Error ? error.message : String(error),
277
- });
278
- throw error;
279
- }
280
- }
281
- }
282
- //# sourceMappingURL=span-processor.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"span-processor.js","sourceRoot":"","sources":["../src/span-processor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAOH,OAAO,EACL,kBAAkB,EAClB,mBAAmB,GACpB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,iBAAiB,EAAE,MAAM,yCAAyC,CAAC;AAE5E,OAAO,EACL,cAAc,EACd,iBAAiB,EAEjB,YAAY,EACZ,kCAAkC,EAClC,kBAAkB,GACnB,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAEjD,MAAM,MAAM,GAAG,YAAY,CAAC,qBAAqB,CAAC,CAAC;AAEnD;;;;;;;;;;;;;GAaG;AACH,SAAS,kBAAkB,CACzB,IAAkB,EAClB,eAA8B,EAC9B,sBAAiC,EACjC,qBAAgC,EAChC,wBAAkC,EAClC,yBAAmC;IAEnC,oDAAoD;IACpD,6EAA6E;IAC7E,oCAAoC;IACpC,MAAM,OAAO,GAAG,kBAAkB,CAChC,IAAI,EAC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provides an isolated TracerProvider that shares the same
5
- * span processors (like PingopsSpanProcessor) with the main OpenTelemetry SDK.
6
- * This ensures manual spans created via startSpan are properly processed.
7
- *
8
- * Architecture follows Langfuse's pattern with global state management.
9
- */
10
- import type { TracerProvider } from "@opentelemetry/api";
11
- import { NodeTracerProvider } from "@opentelemetry/sdk-trace-node";
12
- import type { SpanProcessor } from "@opentelemetry/sdk-trace-base";
13
- /**
14
- * Sets an isolated TracerProvider for PingOps tracing operations.
15
- *
16
- * This allows PingOps to use its own TracerProvider instance, separate from
17
- * the global OpenTelemetry TracerProvider. This is useful for avoiding conflicts
18
- * with other OpenTelemetry instrumentation in the application.
19
- *
20
- * @param provider - The TracerProvider instance to use, or null to clear the isolated provider
21
- * @public
22
- */
23
- export declare function setPingopsTracerProvider(provider: TracerProvider | null): void;
24
- /**
25
- * Gets the TracerProvider for PingOps tracing operations.
26
- *
27
- * Returns the isolated TracerProvider if one has been set via setPingopsTracerProvider(),
28
- * otherwise falls back to the global OpenTelemetry TracerProvider.
29
- *
30
- * @returns The TracerProvider instance to use for PingOps tracing
31
- * @public
32
- */
33
- export declare function getPingopsTracerProvider(): TracerProvider;
34
- /**
35
- * Initializes the isolated TracerProvider with the given span processors
36
- *
37
- * This creates a separate TracerProvider that shares the same span processors
38
- * (like PingopsSpanProcessor) with the main SDK. This ensures manual spans
39
- * are processed correctly.
40
- *
41
- * @param spanProcessors - Array of span processors to use (e.g., PingopsSpanProcessor)
42
- * @param serviceName - Service name for resource attributes
43
- * @deprecated Use setPingopsTracerProvider instead
44
- */
45
- export declare function initializeTracerProvider(spanProcessors: SpanProcessor[], serviceName: string): void;
46
- /**
47
- * Gets the isolated TracerProvider instance
48
- *
49
- * @returns The TracerProvider instance, or null if not initialized
50
- * @deprecated Use getPingopsTracerProvider instead
51
- */
52
- export declare function getTracerProvider(): NodeTracerProvider | null;
53
- /**
54
- * Shuts down the TracerProvider and flushes remaining spans
55
- */
56
- export declare function shutdownTracerProvider(): Promise<void>;
57
- //# sourceMappingURL=tracer-provider.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"tracer-provider.d.ts","sourceRoot":"","sources":["../src/tracer-provider.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAEzD,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AACnE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AA4EnE;;;;;;;;;GASG;AACH,wBAAgB,wBAAwB,CACtC,QAAQ,EAAE,cAAc,GAAG,IAAI,GAC9B,IAAI,CAgBN;AAED;;;;;;;;GAQG;AACH,wBAAgB,wBAAwB,IAAI,cAAc,CAezD;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,wBAAwB,CACtC,cAAc,EAAE,aAAa,EAAE,EAC/B,WAAW,EAAE,MAAM,GAClB,IAAI,CA4BN;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,IAAI,kBAAkB,GAAG,IAAI,CAG7D;AAED;;GAEG;AACH,wBAAsB,sBAAsB,IAAI,OAAO,CAAC,IAAI,CAAC,CA6B5D"}