UNPKG

1.48 kBTypeScriptView Raw
1import { Context } from '../context/types';
2import { SpanAttributes } from './attributes';
3import { Link } from './link';
4import { SamplingResult } from './SamplingResult';
5import { SpanKind } from './span_kind';
6/**
7 * This interface represent a sampler. Sampling is a mechanism to control the
8 * noise and overhead introduced by OpenTelemetry by reducing the number of
9 * samples of traces collected and sent to the backend.
10 */
11export interface Sampler {
12 /**
13 * Checks whether span needs to be created and tracked.
14 *
15 * @param context Parent Context which may contain a span.
16 * @param traceId of the span to be created. It can be different from the
17 * traceId in the {@link SpanContext}. Typically in situations when the
18 * span to be created starts a new trace.
19 * @param spanName of the span to be created.
20 * @param spanKind of the span to be created.
21 * @param attributes Initial set of SpanAttributes for the Span being constructed.
22 * @param links Collection of links that will be associated with the Span to
23 * be created. Typically useful for batch operations.
24 * @returns a {@link SamplingResult}.
25 */
26 shouldSample(context: Context, traceId: string, spanName: string, spanKind: SpanKind, attributes: SpanAttributes, links: Link[]): SamplingResult;
27 /** Returns the sampler name or short description with the configuration. */
28 toString(): string;
29}
30//# sourceMappingURL=Sampler.d.ts.map
\No newline at end of file