Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,11 @@ private ExtractedContext strip(
ctx.getTraceId(),
ctx.getSpanId(),
PrioritySampling.UNSET,
/* origin */ null,
null,
ctx.getEndToEndStartTime(),
ctx.getBaggage(),
ctx.getTags(),
/* httpHeaders */ null,
null,
stripped,
ctx.getTraceConfig(),
ctx.getPropagationStyle());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import datadog.logging.RatelimitedLogger;
import datadog.trace.api.ProductTraceSource;
import datadog.trace.api.internal.VisibleForTesting;
import datadog.trace.api.sampling.PrioritySampling;
import datadog.trace.core.propagation.PropagationTags;
import datadog.trace.core.propagation.ptags.PTagsFactory.PTags;
Expand All @@ -26,7 +27,7 @@ public class W3CPTagsCodec extends PTagsCodec {
private static final char KEY_VALUE_SEPARATOR = ':';
private static final int MIN_ALLOWED_CHAR = 32;
private static final int MAX_ALLOWED_CHAR = 126;
private static final int MAX_MEMBER_COUNT = 32;
@VisibleForTesting public static final int MAX_MEMBER_COUNT = 32;

@Override
PropagationTags fromHeaderValue(PTagsFactory tagsFactory, String value) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,12 @@ void teardown() {
}

@TableTest({
"scenario | traceIdHex | spanIdHex | samplingPriority | expectedSamplingPriority ",
"no priority | '1' | '2' | | PrioritySampling.UNSET ",
"sampler keep | '2' | '3' | 1 | PrioritySampling.SAMPLER_KEEP",
"sampler drop | '3' | '4' | 0 | PrioritySampling.SAMPLER_DROP",
"uint64 max drop | 'ffffffffffffffff' | 'fffffffffffffffe' | 0 | PrioritySampling.SAMPLER_DROP",
"uint64 max-1 keep | 'fffffffffffffffe' | 'ffffffffffffffff' | 1 | PrioritySampling.SAMPLER_KEEP"
"scenario | traceIdHex | spanIdHex | samplingPriority | expectedSamplingPriority",
"no priority | '1' | '2' | | UNSET ",
"sampler keep | '2' | '3' | 1 | SAMPLER_KEEP ",
"sampler drop | '3' | '4' | 0 | SAMPLER_DROP ",
"uint64 max drop | 'ffffffffffffffff' | 'fffffffffffffffe' | 0 | SAMPLER_DROP ",
"uint64 max-1 keep | 'fffffffffffffffe' | 'ffffffffffffffff' | 1 | SAMPLER_KEEP "
})
void extractHttpHeaders(
String traceIdHex,
Expand All @@ -95,11 +95,11 @@ void extractHttpHeaders(
}

@TableTest({
"scenario | b3 | expectedTraceIdHex | expectedSpanId | expectedSamplingPriority ",
"b3 takes precedence | '2-3-0' | '2' | 3 | PrioritySampling.SAMPLER_DROP",
"b3 without priority | '2-3' | '2' | 3 | PrioritySampling.UNSET ",
"invalid b3 falls back | '0' | '1' | 2 | PrioritySampling.SAMPLER_KEEP",
"absent b3 falls back | | '1' | 2 | PrioritySampling.SAMPLER_KEEP"
"scenario | b3 | expectedTraceIdHex | expectedSpanId | expectedSamplingPriority",
"b3 takes precedence | '2-3-0' | '2' | 3 | SAMPLER_DROP ",
"b3 without priority | '2-3' | '2' | 3 | UNSET ",
"invalid b3 falls back | '0' | '1' | 2 | SAMPLER_KEEP ",
"absent b3 falls back | | '1' | 2 | SAMPLER_KEEP "
})
void extractHttpHeadersWithB3HeaderAtTheBeginning(
String b3,
Expand Down Expand Up @@ -127,11 +127,11 @@ void extractHttpHeadersWithB3HeaderAtTheBeginning(
}

@TableTest({
"scenario | b3 | expectedTraceIdHex | expectedSpanId | expectedSamplingPriority ",
"b3 takes precedence | '2-3-0' | '2' | 3 | PrioritySampling.SAMPLER_DROP",
"b3 without priority | '2-3' | '2' | 3 | PrioritySampling.UNSET ",
"invalid b3 falls back | '0' | '1' | 2 | PrioritySampling.SAMPLER_KEEP",
"absent b3 falls back | | '1' | 2 | PrioritySampling.SAMPLER_KEEP"
"scenario | b3 | expectedTraceIdHex | expectedSpanId | expectedSamplingPriority",
"b3 takes precedence | '2-3-0' | '2' | 3 | SAMPLER_DROP ",
"b3 without priority | '2-3' | '2' | 3 | UNSET ",
"invalid b3 falls back | '0' | '1' | 2 | SAMPLER_KEEP ",
"absent b3 falls back | | '1' | 2 | SAMPLER_KEEP "
})
void extractHttpHeadersWithB3HeaderAtTheEnd(
String b3,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,14 @@ void tearDown() {
}

@TableTest({
"scenario | traceId | spanId | samplingPriority | expectedSamplingPriority ",
"unset | 1 | 2 | PrioritySampling.UNSET | ",
"sampler keep | 2 | 3 | PrioritySampling.SAMPLER_KEEP | PrioritySampling.SAMPLER_KEEP",
"sampler drop | 4 | 5 | PrioritySampling.SAMPLER_DROP | PrioritySampling.SAMPLER_DROP",
"user keep | 5 | 6 | PrioritySampling.USER_KEEP | PrioritySampling.SAMPLER_KEEP",
"user drop | 6 | 7 | PrioritySampling.USER_DROP | PrioritySampling.SAMPLER_DROP",
"uint64 max unset | -1 | -2 | PrioritySampling.UNSET | ",
"uint64 max-1 keep | -2 | -1 | PrioritySampling.SAMPLER_KEEP | PrioritySampling.SAMPLER_KEEP"
"scenario | traceId | spanId | samplingPriority | expectedSamplingPriority",
"unset | 1 | 2 | UNSET | ",
"sampler keep | 2 | 3 | SAMPLER_KEEP | SAMPLER_KEEP ",
"sampler drop | 4 | 5 | SAMPLER_DROP | SAMPLER_DROP ",
"user keep | 5 | 6 | USER_KEEP | SAMPLER_KEEP ",
"user drop | 6 | 7 | USER_DROP | SAMPLER_DROP ",
"uint64 max unset | -1 | -2 | UNSET | ",
"uint64 max-1 keep | -2 | -1 | SAMPLER_KEEP | SAMPLER_KEEP "
})
void injectHttpHeaders(
long traceId,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
package datadog.trace.core.propagation;

import datadog.trace.api.sampling.PrioritySampling;
import datadog.trace.api.sampling.SamplingMechanism;
import static datadog.trace.api.sampling.PrioritySampling.SAMPLER_KEEP;
import static datadog.trace.api.sampling.SamplingMechanism.DEFAULT;

import datadog.trace.common.sampling.PrioritySampler;
import datadog.trace.common.sampling.Sampler;
import datadog.trace.core.CoreSpan;

public class ControllableSampler implements Sampler, PrioritySampler {
protected int nextSamplingPriority = PrioritySampling.SAMPLER_KEEP;
protected int nextSamplingPriority = SAMPLER_KEEP;

@Override
public <T extends CoreSpan<T>> void setSamplingPriority(T span) {
span.setSamplingPriority(nextSamplingPriority, SamplingMechanism.DEFAULT);
span.setSamplingPriority(nextSamplingPriority, DEFAULT);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,11 @@ void teardown() {
}

@TableTest({
"scenario | traceId | spanId | samplingPriority | origin ",
"unset no origin | '1' | '2' | PrioritySampling.UNSET | ",
"keep with origin | '2' | '3' | PrioritySampling.SAMPLER_KEEP | 'saipan'",
"uint64 max unset | 'TRACE_ID_MAX' | 'TRACE_ID_MAX-1' | PrioritySampling.UNSET | 'saipan'",
"uint64 max-1 keep | 'TRACE_ID_MAX-1' | 'TRACE_ID_MAX' | PrioritySampling.SAMPLER_KEEP | 'saipan'"
"scenario | traceId | spanId | samplingPriority | origin ",
"unset no origin | '1' | '2' | UNSET | ",
"keep with origin | '2' | '3' | SAMPLER_KEEP | 'saipan'",
"uint64 max unset | 'TRACE_ID_MAX' | 'TRACE_ID_MAX-1' | UNSET | 'saipan'",
"uint64 max-1 keep | 'TRACE_ID_MAX-1' | 'TRACE_ID_MAX' | SAMPLER_KEEP | 'saipan'"
})
void extractHttpHeaders(
@ConvertWith(TraceIdConverter.class) String traceId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,11 @@ void tearDown() {
}

@TableTest({
"scenario | traceId | spanId | samplingPriority | origin ",
"unset no origin | '1' | '2' | PrioritySampling.UNSET | ",
"keep with origin | '1' | '2' | PrioritySampling.SAMPLER_KEEP | 'saipan'",
"uint64 max unset | 'TRACE_ID_MAX' | 'TRACE_ID_MAX-1' | PrioritySampling.UNSET | 'saipan'",
"uint64 max-1 keep | 'TRACE_ID_MAX-1' | 'TRACE_ID_MAX' | PrioritySampling.SAMPLER_KEEP | "
"scenario | traceId | spanId | samplingPriority | origin ",
"unset no origin | '1' | '2' | UNSET | ",
"keep with origin | '1' | '2' | SAMPLER_KEEP | 'saipan'",
"uint64 max unset | 'TRACE_ID_MAX' | 'TRACE_ID_MAX-1' | UNSET | 'saipan'",
"uint64 max-1 keep | 'TRACE_ID_MAX-1' | 'TRACE_ID_MAX' | SAMPLER_KEEP | "
})
void injectHttpHeaders(
@ConvertWith(TraceIdConverter.class) String traceId,
Expand Down
Loading
Loading