UNPKG

enhanced-adot-node-autoinstrumentation

Version:

This package provides Amazon Web Services distribution of the OpenTelemetry Node Instrumentation, which allows for auto-instrumentation of NodeJS applications.

36 lines 2 kB
import { Context } from '@opentelemetry/api'; import { ReadableSpan, BufferConfig, Span } from '@opentelemetry/sdk-trace-base'; import { BatchSpanProcessorBase } from '@opentelemetry/sdk-trace-base/build/src/export/BatchSpanProcessorBase'; /** * This class is a customized version of the `BatchSpanProcessorBase` from the * OpenTelemetry SDK (`@opentelemetry/sdk-trace-base/build/src/export/BatchSpanProcessorBase`). * It inherits much of the behavior of the `BatchSpanProcessorBase` while adding * specific logic to handle unsampled spans. * * It can't directly be inherited `BatchSpanProcessorBase` as child class because * a few stateful fields are private in `BatchSpanProcessorBase` which need to be accessed * in `AwsBatchUnsampledSpanProcessor` and we don't plan to update upstream code for it. * * In particular, the following methods are modified: * * 1. `onStart`: This method is modified to detect unsampled spans and add an * AWS-specific attribute (`AWS_TRACE_FLAG_SAMPLED`) to denote that the span * is unsampled. This is done by checking the `traceFlags` of the span. * * 2. `onEnd`: The logic here is changed to handle unsampled spans. While the * default behavior of `BatchSpanProcessorBase` is to ignore unsampled spans, * this version adds them to the buffer for export. The unsampled spans are * queued and processed similarly to sampled spans. * * This processor ensures that even unsampled spans are exported, which is a * deviation from the typical span processing behavior in OpenTelemetry. * * The rest of the behavior—batch processing, queuing, and exporting spans in * batches—is inherited from the base class and remains largely the same. */ export declare class AwsBatchUnsampledSpanProcessor extends BatchSpanProcessorBase<BufferConfig> { onStart(span: Span, _parentContext: Context): void; onEnd(span: ReadableSpan): void; onShutdown(): void; } //# sourceMappingURL=aws-batch-unsampled-span-processor.d.ts.map