Skip to content

Commit

Permalink
fix context bridge test
Browse files Browse the repository at this point in the history
  • Loading branch information
Mateusz Rzeszutek committed Jul 25, 2022
1 parent b76d250 commit 7772362
Showing 1 changed file with 17 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import io.opentelemetry.context.Context
import io.opentelemetry.context.ContextKey
import io.opentelemetry.extension.annotations.WithSpan
import io.opentelemetry.instrumentation.test.AgentInstrumentationSpecification
import io.opentelemetry.semconv.trace.attributes.SemanticAttributes

import java.util.concurrent.CountDownLatch
import java.util.concurrent.Executors
Expand All @@ -34,8 +35,8 @@ class ContextBridgeTest extends AgentInstrumentationSpecification {
}

def "application propagates agent's context"() {
when:
new Runnable() {
given:
def runnable = new Runnable() {
@WithSpan("test")
@Override
void run() {
Expand All @@ -49,7 +50,10 @@ class ContextBridgeTest extends AgentInstrumentationSpecification {
}
}
}
}.run()
}

when:
runnable.run()

then:
assertTraces(1) {
Expand All @@ -58,6 +62,8 @@ class ContextBridgeTest extends AgentInstrumentationSpecification {
name "test"
hasNoParent()
attributes {
"$SemanticAttributes.CODE_NAMESPACE" runnable.class.name
"$SemanticAttributes.CODE_FUNCTION" "run"
"cat" "yes"
}
}
Expand Down Expand Up @@ -92,8 +98,8 @@ class ContextBridgeTest extends AgentInstrumentationSpecification {
}

def "application propagates agent's span"() {
when:
new Runnable() {
given:
def runnable = new Runnable() {
@WithSpan("test")
@Override
void run() {
Expand All @@ -107,7 +113,10 @@ class ContextBridgeTest extends AgentInstrumentationSpecification {
}
}
}
}.run()
}

when:
runnable.run()

then:
assertTraces(1) {
Expand All @@ -116,6 +125,8 @@ class ContextBridgeTest extends AgentInstrumentationSpecification {
name "test"
hasNoParent()
attributes {
"$SemanticAttributes.CODE_NAMESPACE" runnable.class.name
"$SemanticAttributes.CODE_FUNCTION" "run"
"cat" "yes"
}
}
Expand Down

0 comments on commit 7772362

Please sign in to comment.