UNPKG

autotel

Version:
52 lines (50 loc) 1.43 kB
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); //#region src/filtering-span-processor.ts /** * Span processor that filters spans based on a predicate function. * * The filter is applied on onEnd() when the span has complete data including: * - All attributes * - Status code and message * - Duration * - Events and links * - Instrumentation scope (useful for filtering by library) * * onStart() passes through unchanged to ensure child spans can still be created. * * Error handling: If the filter predicate throws, the span is forwarded (fail-open). */ var FilteringSpanProcessor = class { wrappedProcessor; filter; constructor(wrappedProcessor, options) { this.wrappedProcessor = wrappedProcessor; this.filter = options.filter; } /** * Pass through onStart - we need spans to start so child spans work */ onStart(span, parentContext) { this.wrappedProcessor.onStart(span, parentContext); } /** * Apply filter predicate on span end * If filter returns false, span is dropped (not forwarded) */ onEnd(span) { try { if (this.filter(span)) this.wrappedProcessor.onEnd(span); } catch { this.wrappedProcessor.onEnd(span); } } forceFlush() { return this.wrappedProcessor.forceFlush(); } shutdown() { return this.wrappedProcessor.shutdown(); } }; //#endregion exports.FilteringSpanProcessor = FilteringSpanProcessor; //# sourceMappingURL=filtering-span-processor.cjs.map