ApplicationInsightsSampler class

ApplicationInsightsSampler is responsible for the following: Implements same trace id hashing algorithm so that traces are sampled the same across multiple nodes Adds item count to span attribute if span is sampled (needed for ingestion service)

Constructors

ApplicationInsightsSampler(number)

Initializes a new instance of the ApplicationInsightsSampler class.

Methods

shouldSample(Context, string, string, SpanKind, Attributes, Link[])

Checks whether span needs to be created and tracked.

toString()

Return Sampler description

Constructor Details

ApplicationInsightsSampler(number)

Initializes a new instance of the ApplicationInsightsSampler class.

new ApplicationInsightsSampler(samplingRatio?: number)

Parameters

samplingRatio

number

Value in the range [0,1], 1 meaning all data will sampled and 0 all Tracing data will be sampled out.

Method Details

shouldSample(Context, string, string, SpanKind, Attributes, Link[])

Checks whether span needs to be created and tracked.

function shouldSample(context: Context, traceId: string, spanName: string, spanKind: SpanKind, attributes: Attributes, links: Link[]): SamplingResult

Parameters

context

Context

Parent Context which may contain a span.

traceId

string

traceif of the span to be created. It can be different from the traceId in the <xref:SpanContext>. Typically in situations when the span to be created starts a new trace.

spanName

string

Name of the span to be created.

spanKind

SpanKind

Kind of the span to be created.

attributes

Attributes

Initial set of SpanAttributes for the Span being constructed.

links

Link[]

Collection of links that will be associated with the Span to be created. Typically useful for batch operations.

Returns

SamplingResult

a <xref:SamplingResult>.

toString()

Return Sampler description

function toString(): string

Returns

string