@opentelemetry/baggage-span-processor
Version:
OpenTelemetry Baggage Span Processor for Node.js
54 lines • 2.12 kB
TypeScript
import { BaggageKeyPredicate } from './types';
import { Context } from '@opentelemetry/api';
import { SpanProcessor, Span, ReadableSpan } from '@opentelemetry/sdk-trace-base';
/**
* BaggageSpanProcessor is a {@link SpanProcessor} that reads entries stored in {@link Baggage}
* from the parent context and adds the baggage entries' keys and
* values to the span as attributes on span start.
*
* Add this span processor to a tracer provider.
*
* Keys and values added to Baggage will appear on subsequent child
* spans for a trace within this service *and* be propagated to external
* services in accordance with any configured propagation formats
* configured. If the external services also have a Baggage span
* processor, the keys and values will appear in those child spans as
* well.
*
* ⚠ Warning ⚠️
*
* Do not put sensitive information in Baggage.
*
* To repeat: a consequence of adding data to Baggage is that the keys and
* values will appear in all outgoing HTTP headers from the application.
*/
export declare class BaggageSpanProcessor implements SpanProcessor {
private _keyPredicate;
/**
* Constructs a new BaggageSpanProcessor instance.
* @param keyPredicate A predicate that determines whether a baggage key-value pair should be added to new spans as a span attribute.
*/
constructor(keyPredicate: BaggageKeyPredicate);
/**
* Forces to export all finished spans
*/
forceFlush(): Promise<void>;
/**
* Called when a {@link Span} is started, if the `span.isRecording()`
* returns true.
* @param span the Span that just started.
*/
onStart(span: Span, parentContext: Context): void;
/**
* Called when a {@link ReadableSpan} is ended, if the `span.isRecording()`
* returns true.
* @param span the Span that just ended.
*/
onEnd(_: ReadableSpan): void;
/**
* Shuts down the processor. Called when SDK is shut down. This is an
* opportunity for processor to do any cleanup required.
*/
shutdown(): Promise<void>;
}
//# sourceMappingURL=baggage-span-processor.d.ts.map