shouldSample method
SamplingResult
shouldSample(
- Context context,
- TraceId traceId,
- String? spanName,
- SpanKind? spanKind,
- List<
Attribute> spanAttributes, - List<
SpanLink> ? spanLinks,
override
Implementation
@override
sdk.SamplingResult shouldSample(
api.Context context,
api.TraceId traceId,
String? spanName,
api.SpanKind? spanKind,
List<api.Attribute> spanAttributes,
List<api.SpanLink>? spanLinks) {
final parentSpanContext = context.spanContext;
if (parentSpanContext == null || !parentSpanContext.isValid) {
return _root.shouldSample(
context, traceId, spanName, spanKind, spanAttributes, spanLinks);
}
if (parentSpanContext.isRemote) {
return ((parentSpanContext.traceFlags & api.TraceFlags.sampled) ==
api.TraceFlags.sampled)
? _remoteParentSampled.shouldSample(
context, traceId, spanName, spanKind, spanAttributes, spanLinks)
: _remoteParentNotSampled.shouldSample(
context, traceId, spanName, spanKind, spanAttributes, spanLinks);
}
return (parentSpanContext.traceFlags & api.TraceFlags.sampled) ==
api.TraceFlags.sampled
? _localParentSampled.shouldSample(
context, traceId, spanName, spanKind, spanAttributes, spanLinks)
: _localParentNotSampled.shouldSample(
context, traceId, spanName, spanKind, spanAttributes, spanLinks);
}