Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
893abf1
fix(core): Manually cleaning up AI code
PerfectSlayer Jun 8, 2026
30a073e
WIP
PerfectSlayer Jun 8, 2026
b158ee1
fix(core): Manually cleaning up AI code
PerfectSlayer Jun 8, 2026
7ad1ecc
fix(core): Manually cleaning up AI code
PerfectSlayer Jun 8, 2026
3b72761
fix(core): Manually cleaning up AI code
PerfectSlayer Jun 9, 2026
f5331be
fix(core): Manually cleaning up AI code
PerfectSlayer Jun 9, 2026
6d4a7a5
fix(core): Manually cleaning up AI code
PerfectSlayer Jun 9, 2026
f48e9bc
fix(core): Manually cleaning up AI code
PerfectSlayer Jun 9, 2026
7450e5b
fix(core): Manually cleaning up AI code
PerfectSlayer Jun 9, 2026
cfe5847
fix(core): Manually cleaning up AI code
PerfectSlayer Jun 9, 2026
289d8f2
fix(core): Manually cleaning up AI code
PerfectSlayer Jun 9, 2026
3e37b5e
fix(core): Manually cleaning up AI code
PerfectSlayer Jun 9, 2026
9f400a8
feat(junit): Create class constant type converter
PerfectSlayer Jun 9, 2026
d088e7f
fix(core): Manually cleaning up AI code
PerfectSlayer Jun 9, 2026
dd87e5e
feat(junit): Improve argument converters
PerfectSlayer Jun 10, 2026
a778f75
feat(junit): Improve argument converters
PerfectSlayer Jun 10, 2026
c99b824
feat(junit): Improve argument converters
PerfectSlayer Jun 10, 2026
cc9101d
feat(junit): Improve argument converters
PerfectSlayer Jun 10, 2026
378e2fb
feat(junit): Improve argument converters
PerfectSlayer Jun 10, 2026
a00a78a
feat(junit): Improve argument converters
PerfectSlayer Jun 10, 2026
676866b
feat(junit): Improve argument converters
PerfectSlayer Jun 11, 2026
c4193eb
feat(junit): Improve argument converters
PerfectSlayer Jun 12, 2026
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 @@ -9,7 +9,7 @@
import datadog.trace.core.CoreTracer;
import datadog.trace.core.DDCoreJavaSpecification;
import datadog.trace.core.DDSpan;
import datadog.trace.junit.utils.tabletest.DDSpanTypesConverter;
import datadog.trace.junit.utils.converter.DDSpanTypesConverter;
import java.util.List;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import datadog.trace.api.DynamicConfig;
import datadog.trace.bootstrap.instrumentation.api.TagContext;
import datadog.trace.junit.utils.config.WithConfig;
import datadog.trace.junit.utils.tabletest.PrioritySamplingConverter;
import datadog.trace.junit.utils.converter.PrioritySamplingConverter;
import datadog.trace.test.util.DDJavaSpecification;
import java.util.HashMap;
import java.util.Map;
Expand Down 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 @@ -24,7 +24,7 @@
import datadog.trace.core.CoreTracer;
import datadog.trace.core.DDCoreJavaSpecification;
import datadog.trace.core.DDSpanContext;
import datadog.trace.junit.utils.tabletest.PrioritySamplingConverter;
import datadog.trace.junit.utils.converter.PrioritySamplingConverter;
import java.util.HashMap;
import java.util.Map;
import org.junit.jupiter.api.AfterEach;
Expand Down 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 @@ -14,7 +14,7 @@
import static datadog.trace.core.propagation.DatadogHttpCodec.SPAN_ID_KEY;
import static datadog.trace.core.propagation.DatadogHttpCodec.TRACE_ID_KEY;
import static datadog.trace.core.propagation.HttpCodecTestHelper.headers;
import static datadog.trace.junit.utils.tabletest.TraceIdConverter.TRACE_ID_MAX_PLUS_1;
import static datadog.trace.junit.utils.converter.TraceIdConverter.TRACE_ID_MAX_PLUS_1;
import static java.util.Collections.singletonMap;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
Expand All @@ -31,8 +31,8 @@
import datadog.trace.api.internal.util.LongStringUtils;
import datadog.trace.bootstrap.instrumentation.api.TagContext;
import datadog.trace.junit.utils.config.WithConfig;
import datadog.trace.junit.utils.tabletest.PrioritySamplingConverter;
import datadog.trace.junit.utils.tabletest.TraceIdConverter;
import datadog.trace.junit.utils.converter.PrioritySamplingConverter;
import datadog.trace.junit.utils.converter.TraceIdConverter;
import datadog.trace.test.util.DDJavaSpecification;
import java.util.HashMap;
import java.util.Map;
Expand Down 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 | 'MAX' | 'MAX-1' | UNSET | 'saipan'",
"uint64 max-1 keep | 'MAX-1' | 'MAX' | SAMPLER_KEEP | 'saipan'"
})
void extractHttpHeaders(
@ConvertWith(TraceIdConverter.class) String traceId,
Expand Down Expand Up @@ -362,15 +362,15 @@ void extractHttpHeadersWithOutOfRangeSpanId() {
}

@TableTest({
"scenario | traceId | spanId | expectExtraction",
"negative traceId | '-1' | '1' | false ",
"negative spanId | '1' | '-1' | false ",
"zero traceId | '0' | '1' | false ",
"zero spanId | '1' | '0' | true ",
"uint64 max traceId | 'TRACE_ID_MAX' | '1' | true ",
"out-of-range traceId | 'TRACE_ID_MAX+1' | '1' | false ",
"uint64 max spanId | '1' | 'TRACE_ID_MAX' | true ",
"out-of-range spanId | '1' | 'TRACE_ID_MAX+1' | false "
"scenario | traceId | spanId | expectExtraction",
"negative traceId | '-1' | '1' | false ",
"negative spanId | '1' | '-1' | false ",
"zero traceId | '0' | '1' | false ",
"zero spanId | '1' | '0' | true ",
"uint64 max traceId | 'MAX' | '1' | true ",
"out-of-range traceId | 'MAX+1' | '1' | false ",
"uint64 max spanId | '1' | 'MAX' | true ",
"out-of-range spanId | '1' | 'MAX+1' | false "
})
void moreIdRangeValidation(
@ConvertWith(TraceIdConverter.class) String traceId,
Expand Down Expand Up @@ -430,11 +430,11 @@ void extractHttpHeadersWithEndToEnd(String traceId, String spanId, long endToEnd
}

@TableTest({
"scenario | traceId | spanId | ctxCreated",
"negative traceId | '-1' | '1' | false ",
"negative spanId | '1' | '-1' | false ",
"zero traceId | '0' | '1' | true ",
"uint64 max-1 ids | 'TRACE_ID_MAX-1' | 'TRACE_ID_MAX-1' | true "
"scenario | traceId | spanId | ctxCreated",
"negative traceId | '-1' | '1' | false ",
"negative spanId | '1' | '-1' | false ",
"zero traceId | '0' | '1' | true ",
"uint64 max-1 ids | 'MAX-1' | 'MAX-1' | true "
})
void baggageIsMappedOnContextCreation(
@ConvertWith(TraceIdConverter.class) String traceId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
import datadog.trace.core.CoreTracer;
import datadog.trace.core.DDCoreJavaSpecification;
import datadog.trace.core.DDSpanContext;
import datadog.trace.junit.utils.tabletest.PrioritySamplingConverter;
import datadog.trace.junit.utils.tabletest.TraceIdConverter;
import datadog.trace.junit.utils.converter.PrioritySamplingConverter;
import datadog.trace.junit.utils.converter.TraceIdConverter;
import java.util.HashMap;
import java.util.Map;
import org.junit.jupiter.api.AfterEach;
Expand Down 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 | 'MAX' | 'MAX-1' | UNSET | 'saipan'",
"uint64 max-1 keep | 'MAX-1' | 'MAX' | SAMPLER_KEEP | "
})
void injectHttpHeaders(
@ConvertWith(TraceIdConverter.class) String traceId,
Expand Down
Loading