-
Notifications
You must be signed in to change notification settings - Fork 713
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This reverts commit 44e4081 temporarily for a 5.18.1 release.
- Loading branch information
Adrian Cole
committed
Jan 8, 2024
1 parent
f99265d
commit 5c977a2
Showing
349 changed files
with
19,171 additions
and
641 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
brave-tests/src/main/java/brave/test/propagation/PropagationSetterTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
brave-tests/src/test/java/brave/propagation/B3PropagationTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
102 changes: 102 additions & 0 deletions
102
brave-tests/src/test/java/brave/propagation/B3SinglePropagationTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
/* | ||
* Copyright 2013-2023 The OpenZipkin Authors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except | ||
* in compliance with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software distributed under the License | ||
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express | ||
* or implied. See the License for the specific language governing permissions and limitations under | ||
* the License. | ||
*/ | ||
package brave.propagation; | ||
|
||
import brave.internal.Nullable; | ||
import brave.test.propagation.PropagationTest; | ||
import java.util.Map; | ||
import java.util.function.Supplier; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
class B3SinglePropagationTest extends PropagationTest { | ||
@Override protected Class<? extends Supplier<Propagation<String>>> propagationSupplier() { | ||
return PropagationSupplier.class; | ||
} | ||
|
||
static class PropagationSupplier implements Supplier<Propagation<String>> { | ||
@Override public Propagation<String> get() { | ||
return Propagation.B3_SINGLE_STRING; | ||
} | ||
} | ||
|
||
@Override protected void inject(Map<String, String> map, @Nullable String traceId, | ||
@Nullable String parentId, @Nullable String spanId, @Nullable Boolean sampled, | ||
@Nullable Boolean debug) { | ||
StringBuilder builder = new StringBuilder(); | ||
char sampledChar = sampledChar(sampled, debug); | ||
if (traceId == null) { | ||
if (sampledChar != 0) builder.append(sampledChar); | ||
} else { | ||
builder.append(traceId).append('-').append(spanId); | ||
if (sampledChar != 0) builder.append('-').append(sampledChar); | ||
if (parentId != null) builder.append('-').append(parentId); | ||
} | ||
if (builder.length() != 0) map.put("b3", builder.toString()); | ||
} | ||
|
||
/** returns 0 if there's no sampling status */ | ||
static char sampledChar(@Nullable Boolean sampled, @Nullable Boolean debug) { | ||
if (Boolean.TRUE.equals(debug)) return 'd'; | ||
if (sampled != null) return sampled ? '1' : '0'; | ||
return 0; | ||
} | ||
|
||
@Override protected void inject(Map<String, String> request, SamplingFlags flags) { | ||
char sampledChar = sampledChar(flags.sampled(), flags.debug()); | ||
if (sampledChar != 0) request.put("b3", String.valueOf(sampledChar)); | ||
} | ||
|
||
@Test void extractTraceContext_sampledFalse() { | ||
MapEntry mapEntry = new MapEntry(); | ||
map.put("b3", "0"); | ||
|
||
SamplingFlags result = propagation.extractor(mapEntry).extract(map).samplingFlags(); | ||
|
||
assertThat(result) | ||
.isEqualTo(SamplingFlags.NOT_SAMPLED); | ||
} | ||
|
||
@Test void extractTraceContext_malformed() { | ||
MapEntry mapEntry = new MapEntry(); | ||
map.put("b3", "not-a-tumor"); | ||
|
||
SamplingFlags result = propagation.extractor(mapEntry).extract(map).samplingFlags(); | ||
|
||
assertThat(result) | ||
.isEqualTo(SamplingFlags.EMPTY); | ||
} | ||
|
||
@Test void extractTraceContext_malformed_uuid() { | ||
MapEntry mapEntry = new MapEntry(); | ||
map.put("b3", "b970dafd-0d95-40aa-95d8-1d8725aebe40"); | ||
|
||
SamplingFlags result = propagation.extractor(mapEntry).extract(map).samplingFlags(); | ||
|
||
assertThat(result) | ||
.isEqualTo(SamplingFlags.EMPTY); | ||
} | ||
|
||
@Test void extractTraceContext_debug_with_ids() { | ||
MapEntry mapEntry = new MapEntry(); | ||
|
||
map.put("b3", "4bf92f3577b34da6a3ce929d0e0e4736-00f067aa0ba902b7-d"); | ||
|
||
TraceContext result = propagation.extractor(mapEntry).extract(map).context(); | ||
|
||
assertThat(result.debug()) | ||
.isTrue(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.