generated from micronaut-projects/micronaut-project-template
-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* moved OpenTracingInvocationInstrumenterSpec from core * add bom
- Loading branch information
1 parent
2ce19b5
commit eea16ca
Showing
10 changed files
with
88 additions
and
31 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
plugins { | ||
id 'io.micronaut.build.internal.bom' | ||
} |
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
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
42 changes: 42 additions & 0 deletions
42
.../src/test/groovy/io/micronaut/tracing/jaeger/OpenTracingInvocationInstrumenterSpec.groovy
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,42 @@ | ||
package io.micronaut.tracing.jaeger | ||
|
||
import io.micronaut.context.ApplicationContext | ||
import io.opentracing.Scope | ||
import io.opentracing.Span | ||
import io.opentracing.Tracer | ||
import reactor.core.publisher.Flux | ||
import reactor.core.publisher.Mono | ||
import spock.lang.Specification | ||
|
||
/** | ||
* Regression test: when executing certain reactive operations the ScopeManager's internal state can become permanently | ||
* corrupted resulting in incorrect tracing. | ||
* | ||
* @author lgathy | ||
*/ | ||
class OpenTracingInvocationInstrumenterSpec extends Specification { | ||
|
||
void "test regression of corrupted ScopeManager state"() { | ||
given: 'Jaeger tracer is enabled' | ||
ApplicationContext context = ApplicationContext.run('tracing.jaeger.enabled': true) | ||
Tracer tracer = context.getBean(Tracer) | ||
String[] words = ['one', 'two', 'three'] | ||
|
||
expect: 'no active span' | ||
tracer.activeSpan() == null | ||
|
||
when: 'reactive operations are executed inside a span' | ||
Span rootSpan = tracer.buildSpan('root').start() | ||
Scope scope = tracer.activateSpan(rootSpan) | ||
String combined = Flux | ||
.merge(words.collect { Mono.just(it).flux() }) | ||
.reduce { a, b -> "$a, $b" } | ||
.block() | ||
scope.close() | ||
rootSpan.finish() | ||
|
||
then: 'there should be no active span after it was finished' | ||
combined.split(", ").sort() == words.sort() | ||
tracer.activeSpan() == null | ||
} | ||
} |