UNPKG

@ogcio/o11y-sdk-node

Version:

Opentelemetry standard instrumentation SDK for NodeJS based project

37 lines (36 loc) 1.31 kB
import type { Context } from "@opentelemetry/api"; import type { ReadableSpan, Span, SpanProcessor } from "@opentelemetry/sdk-trace-base"; /** * A SpanProcessor that provides a hook to execute custom logic * just before a span is ended. * * This allows for capturing or modifying span data at the precise moment * the span is about to be finished, while it is still writable. * * Usage: * Extend this class and implement the onEnding method with custom logic. * Override the onStart method if needed to set up any required state. * The onEnding method will be called just before the span's end() method * is invoked. * * Example: * ```typescript * class CustomSpanProcessor extends OnEndingHookSpanProcessor { * onEnding(span: Span, context: Context): void { * // Custom logic to execute before the span ends * span.setAttribute("custom.attribute", "value"); * } * } * ``` */ export declare abstract class OnEndingHookSpanProcessor implements SpanProcessor { /** * Hook method called just before a span is ended. * @param span The span that is about to end. */ abstract onEnding(span: Span): void; onStart(span: Span, _context: Context): void; onEnd(_span: ReadableSpan): void; forceFlush(): Promise<void>; shutdown(): Promise<void>; }