-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Resolve end strategy after WithSpan method instead of before. (open-t…
…elemetry#5756) * WIP * Resolve end strategy after WithSpan method instead of before.
- Loading branch information
Showing
3 changed files
with
70 additions
and
6 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
49 changes: 49 additions & 0 deletions
49
...alization/java/io/opentelemetry/javaagent/instrumentation/reactor/InitializationTest.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,49 @@ | ||
/* | ||
* Copyright The OpenTelemetry Authors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package io.opentelemetry.javaagent.instrumentation.reactor; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
import io.opentelemetry.extension.annotations.WithSpan; | ||
import java.util.stream.Collectors; | ||
import org.junit.jupiter.api.Test; | ||
import reactor.core.Scannable; | ||
import reactor.core.publisher.Mono; | ||
|
||
// Isolated test to use clean classloader because reactor instrumentation is applied on static | ||
// initialization. | ||
class InitializationTest { | ||
|
||
@Test | ||
void contextPropagated() { | ||
Mono<String> mono = new Traced().traceMe(); | ||
|
||
// If reactor augmentation of WithSpan is working correctly, we will end up with these | ||
// implementation details. | ||
// TODO(anuraaga): This should just check actual context propagation instead of implementation | ||
// but couldn't figure out how. | ||
assertThat(((Scannable) mono).parents().collect(Collectors.toList())) | ||
.anySatisfy( | ||
op -> { | ||
assertThat(op.getClass().getSimpleName()).isEqualTo("MonoFlatMap"); | ||
assertThat(op) | ||
.extracting("source") | ||
.satisfies( | ||
source -> | ||
assertThat(source.getClass().getSimpleName()) | ||
.isEqualTo("ScalarPropagatingMono")); | ||
}); | ||
|
||
assertThat(mono.block()).isEqualTo("foo"); | ||
} | ||
|
||
static class Traced { | ||
@WithSpan | ||
Mono<String> traceMe() { | ||
return Mono.just("foo"); | ||
} | ||
} | ||
} |