-
Notifications
You must be signed in to change notification settings - Fork 124
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix lifecycle to support the Maven Daemon (#169)
- Loading branch information
1 parent
b7e290b
commit 4c2ee90
Showing
2 changed files
with
41 additions
and
1 deletion.
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
33 changes: 33 additions & 0 deletions
33
maven-extension/src/test/java/io/opentelemetry/maven/SpanRegistryTest.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,33 @@ | ||
/* | ||
* Copyright The OpenTelemetry Authors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package io.opentelemetry.maven; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
import io.opentelemetry.api.OpenTelemetry; | ||
import io.opentelemetry.api.trace.Span; | ||
import io.opentelemetry.api.trace.Tracer; | ||
import org.junit.jupiter.api.Test; | ||
|
||
public class SpanRegistryTest { | ||
|
||
/** MVND reuses the same Maven process and thus the Span Registry is reused. */ | ||
@Test | ||
public void testSpanRegistryReuseWhenUsingMvnDaemon() { | ||
SpanRegistry spanRegistry = new SpanRegistry(); | ||
|
||
Tracer tracer = OpenTelemetry.noop().getTracer("test"); | ||
Span firstRootSpan = tracer.spanBuilder("com.example:my-jar-1.1.0-SNAPSHOT").startSpan(); | ||
spanRegistry.setRootSpan(firstRootSpan); | ||
Span firstRemovedRootSpan = spanRegistry.removeRootSpan(); | ||
assertThat(firstRemovedRootSpan).isEqualTo(firstRootSpan); | ||
|
||
Span secondRootSpan = tracer.spanBuilder("com.example:my-jar-2.1.0-SNAPSHOT").startSpan(); | ||
spanRegistry.setRootSpan(secondRootSpan); | ||
Span secondRemovedSpan = spanRegistry.removeRootSpan(); | ||
assertThat(secondRemovedSpan).isEqualTo(secondRootSpan); | ||
} | ||
} |