Skip to content

Commit bb0ec0a

Browse files
committed
Introduce ParentBasedAlwaysOnSampler and make this the default sampler for otlp mode, instead of priority sampling or traces rate based sampler. plus tests
1 parent 51fe2ea commit bb0ec0a

9 files changed

Lines changed: 300 additions & 111 deletions

File tree

components/json/src/test/java/datadog/json/JsonMapperTest.java

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,12 @@
2424

2525
class JsonMapperTest {
2626
@TableTest({
27-
"Scenario | Input | Expected ",
28-
"null input | | '{}' ",
29-
"empty map | [:] | '{}' ",
30-
"single entry | [key1: value1] | '{\"key1\":\"value1\"}' ",
31-
"two entries | [key1: value1, key2: value2] | '{\"key1\":\"value1\",\"key2\":\"value2\"}' ",
32-
"quoted entries | [key1: va\"lu\"e1, ke\"y2: value2] | '{\"key1\":\"va\\\"lu\\\"e1\",\"ke\\\"y2\":\"value2\"}'"
27+
"Scenario | Input | Expected ",
28+
"null input | | '{}' ",
29+
"empty map | [:] | '{}' ",
30+
"single entry | [key1: value1] | '{\"key1\":\"value1\"}' ",
31+
"two entries | [key1: value1, key2: value2] | '{\"key1\":\"value1\",\"key2\":\"value2\"}' ",
32+
"quoted entries | [key1: va\"lu\"e1, ke\"y2: value2] | '{\"key1\":\"va\\\"lu\\\"e1\",\"ke\\\"y2\":\"value2\"}'"
3333
})
3434
@ParameterizedTest(name = "test mapping to JSON object: {0}")
3535
@MethodSource("testMappingToJsonObjectArguments")
@@ -94,12 +94,12 @@ void testMappingToMapFromNonObjectJson(String json) {
9494
}
9595

9696
@TableTest({
97-
"Scenario | Input | Expected ",
98-
"null input | | '[]' ",
99-
"empty list | [] | '[]' ",
100-
"single value | [value1] | '[\"value1\"]' ",
101-
"two values | [value1, value2] | '[\"value1\",\"value2\"]' ",
102-
"quoted values | [va\"lu\"e1, value2] | '[\"va\\\"lu\\\"e1\",\"value2\"]'"
97+
"Scenario | Input | Expected ",
98+
"null input | | '[]' ",
99+
"empty list | [] | '[]' ",
100+
"single value | [value1] | '[\"value1\"]' ",
101+
"two values | [value1, value2] | '[\"value1\",\"value2\"]' ",
102+
"quoted values | [va\"lu\"e1, value2] | '[\"va\\\"lu\\\"e1\",\"value2\"]'"
103103
})
104104
@ParameterizedTest(name = "test mapping iterable to JSON array: {0}")
105105
void testMappingIterableToJsonArray(List<String> input, String expected) throws IOException {
@@ -111,12 +111,12 @@ void testMappingIterableToJsonArray(List<String> input, String expected) throws
111111
}
112112

113113
@TableTest({
114-
"Scenario | Input | Expected ",
115-
"null input | | '[]' ",
116-
"empty array | [] | '[]' ",
117-
"single element | [value1] | '[\"value1\"]' ",
118-
"two elements | [value1, value2] | '[\"value1\",\"value2\"]' ",
119-
"escaped quotes | [va\"lu\"e1, value2] | '[\"va\\\"lu\\\"e1\",\"value2\"]'"
114+
"Scenario | Input | Expected ",
115+
"null input | | '[]' ",
116+
"empty array | [] | '[]' ",
117+
"single element | [value1] | '[\"value1\"]' ",
118+
"two elements | [value1, value2] | '[\"value1\",\"value2\"]' ",
119+
"escaped quotes | [va\"lu\"e1, value2] | '[\"va\\\"lu\\\"e1\",\"value2\"]'"
120120
})
121121
@ParameterizedTest(name = "test mapping array to JSON array: {0}")
122122
void testMappingArrayToJsonArray(String ignoredScenario, String[] input, String expected)
@@ -137,14 +137,14 @@ void testMappingToListFromEmptyJsonObject(String json) throws IOException {
137137
}
138138

139139
@TableTest({
140-
"Scenario | input | expected ",
141-
"null value | | '' ",
142-
"empty string | '' | '' ",
143-
"\\b | '\b' | '\"\\b\"'",
144-
"\\t | '\t' | '\"\\t\"'",
145-
"\\f | '\f' | '\"\\f\"'",
146-
"a | 'a' | '\"a\"' ",
147-
"/ | '/' | '\"\\/\"'"
140+
"Scenario | input | expected ",
141+
"null value | | '' ",
142+
"empty string | '' | '' ",
143+
"\\b | '\b' | '\"\\b\"'",
144+
"\\t | '\t' | '\"\\t\"'",
145+
"\\f | '\f' | '\"\\f\"'",
146+
"a | 'a' | '\"a\"' ",
147+
"/ | '/' | '\"\\/\"'"
148148
})
149149
@ParameterizedTest(name = "test mapping to JSON string: {0}")
150150
@MethodSource("testMappingToJsonStringArguments")

dd-trace-api/src/test/java/datadog/trace/api/DDSpanIdTest.java

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@
1919
class DDSpanIdTest {
2020

2121
@TableTest({
22-
"scenario | stringId | expectedId ",
23-
"zero | '0' | 0 ",
24-
"one | '1' | 1 ",
25-
"max | '18446744073709551615' | DDSpanId.MAX ",
26-
"long max | '9223372036854775807' | Long.MAX_VALUE",
27-
"long max plus one | '9223372036854775808' | Long.MIN_VALUE"
22+
"scenario | stringId | expectedId ",
23+
"zero | '0' | 0 ",
24+
"one | '1' | 1 ",
25+
"max | '18446744073709551615' | DDSpanId.MAX ",
26+
"long max | '9223372036854775807' | Long.MAX_VALUE",
27+
"long max plus one | '9223372036854775808' | Long.MIN_VALUE"
2828
})
2929
@ParameterizedTest(name = "convert ids from/to String [{index}]")
3030
void convertIdsFromToString(String stringId, long expectedId) {
@@ -51,15 +51,15 @@ void failOnIllegalString(String stringId) {
5151
}
5252

5353
@TableTest({
54-
"scenario | hexId | expectedId ",
55-
"zero | '0' | 0 ",
56-
"one | '1' | 1 ",
57-
"max | 'ffffffffffffffff' | DDSpanId.MAX ",
58-
"long max | '7fffffffffffffff' | Long.MAX_VALUE ",
59-
"long min | '8000000000000000' | Long.MIN_VALUE ",
60-
"long min with leading zeros | '00008000000000000000' | Long.MIN_VALUE ",
61-
"hex sample | 'cafebabe' | 3405691582 ",
62-
"fifteen hex digits | '123456789abcdef' | 81985529216486895"
54+
"scenario | hexId | expectedId ",
55+
"zero | '0' | 0 ",
56+
"one | '1' | 1 ",
57+
"max | 'ffffffffffffffff' | DDSpanId.MAX ",
58+
"long max | '7fffffffffffffff' | Long.MAX_VALUE ",
59+
"long min | '8000000000000000' | Long.MIN_VALUE ",
60+
"long min with leading zeros | '00008000000000000000' | Long.MIN_VALUE ",
61+
"hex sample | 'cafebabe' | 3405691582 ",
62+
"fifteen hex digits | '123456789abcdef' | 81985529216486895"
6363
})
6464
@ParameterizedTest(name = "convert ids from/to hex String [{index}]")
6565
void convertIdsFromToHexString(String hexId, long expectedId) {
@@ -77,17 +77,17 @@ void convertIdsFromToHexString(String hexId, long expectedId) {
7777
}
7878

7979
@TableTest({
80-
"scenario | hexId | start | length | lowerCaseOnly | expectedId ",
81-
"null input | | 1 | 1 | false | ",
82-
"empty input | '' | 1 | 1 | false | ",
83-
"negative start | '00' | -1 | 1 | false | ",
84-
"zero length | '00' | 0 | 0 | false | ",
85-
"single zero at index 0 | '00' | 0 | 1 | false | DDSpanId.ZERO",
86-
"single zero at index 1 | '00' | 1 | 1 | false | DDSpanId.ZERO",
87-
"single zero at index 1 duplicate | '00' | 1 | 1 | false | DDSpanId.ZERO",
88-
"max lower-case | 'ffffffffffffffff' | 0 | 16 | true | DDSpanId.MAX ",
89-
"upper-case rejected when lower-case only | 'ffffffffffffFfff' | 0 | 16 | true | ",
90-
"upper-case accepted when lower disabled | 'ffffffffffffFfff' | 0 | 16 | false | DDSpanId.MAX "
80+
"scenario | hexId | start | length | lowerCaseOnly | expectedId ",
81+
"null input | | 1 | 1 | false | ",
82+
"empty input | '' | 1 | 1 | false | ",
83+
"negative start | '00' | -1 | 1 | false | ",
84+
"zero length | '00' | 0 | 0 | false | ",
85+
"single zero at index 0 | '00' | 0 | 1 | false | DDSpanId.ZERO",
86+
"single zero at index 1 | '00' | 1 | 1 | false | DDSpanId.ZERO",
87+
"single zero at index 1 duplicate | '00' | 1 | 1 | false | DDSpanId.ZERO",
88+
"max lower-case | 'ffffffffffffffff' | 0 | 16 | true | DDSpanId.MAX ",
89+
"upper-case rejected when lower-case only | 'ffffffffffffFfff' | 0 | 16 | true | ",
90+
"upper-case accepted when lower disabled | 'ffffffffffffFfff' | 0 | 16 | false | DDSpanId.MAX "
9191
})
9292
@ParameterizedTest(name = "convert ids from part of hex String [{index}]")
9393
void convertIdsFromPartOfHexString(

0 commit comments

Comments
 (0)