Skip to content

Commit b52921f

Browse files
committed
extend test
1 parent f0e6c82 commit b52921f

File tree

5 files changed

+40
-21
lines changed

5 files changed

+40
-21
lines changed

instrumentation/pekko/pekko-actor-1.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/pekkoactor/v1_0/ExecutionContextWrapper.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,8 @@
55

66
package io.opentelemetry.javaagent.instrumentation.pekkoactor.v1_0;
77

8-
import scala.concurrent.ExecutionContext;
9-
108
import io.opentelemetry.context.Context;
9+
import scala.concurrent.ExecutionContext;
1110

1211
public class ExecutionContextWrapper implements ExecutionContext {
1312
private final ExecutionContext executionContext;

instrumentation/pekko/pekko-actor-1.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/pekkoactor/v1_0/PekkoScheduleInstrumentation.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
import net.bytebuddy.asm.Advice;
1616
import net.bytebuddy.description.type.TypeDescription;
1717
import net.bytebuddy.matcher.ElementMatcher;
18-
1918
import scala.concurrent.ExecutionContext;
2019

2120
public class PekkoScheduleInstrumentation implements TypeInstrumentation {

instrumentation/pekko/pekko-actor-1.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/pekkoactor/v1_0/PekkoScheduleOnceInstrumentation.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
import net.bytebuddy.asm.Advice;
1616
import net.bytebuddy.description.type.TypeDescription;
1717
import net.bytebuddy.matcher.ElementMatcher;
18-
1918
import scala.concurrent.ExecutionContext;
2019

2120
public class PekkoScheduleOnceInstrumentation implements TypeInstrumentation {

instrumentation/pekko/pekko-http-1.0/javaagent/src/test/scala/io/opentelemetry/javaagent/instrumentation/pekkohttp/v1_0/PekkoHttpServerInstrumentationTestAsync.scala

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,20 @@ package io.opentelemetry.javaagent.instrumentation.pekkohttp.v1_0
77

88
import io.opentelemetry.instrumentation.testing.junit.InstrumentationExtension
99
import io.opentelemetry.instrumentation.testing.junit.http.ServerEndpoint.SUCCESS
10-
import io.opentelemetry.instrumentation.testing.junit.http.{HttpServerInstrumentationExtension, HttpServerTestOptions}
11-
import io.opentelemetry.testing.internal.armeria.common.{AggregatedHttpRequest, AggregatedHttpResponse}
10+
import io.opentelemetry.instrumentation.testing.junit.http.{
11+
HttpServerInstrumentationExtension,
12+
HttpServerTestOptions
13+
}
14+
import io.opentelemetry.testing.internal.armeria.common.{
15+
AggregatedHttpRequest,
16+
AggregatedHttpResponse
17+
}
1218
import org.assertj.core.api.Assertions.assertThat
1319
import org.junit.jupiter.api.Test
1420
import org.junit.jupiter.api.extension.RegisterExtension
1521

1622
class PekkoHttpServerInstrumentationTestAsync
17-
extends AbstractHttpServerInstrumentationTest {
23+
extends AbstractHttpServerInstrumentationTest {
1824

1925
@RegisterExtension val extension: InstrumentationExtension =
2026
HttpServerInstrumentationExtension.forAgent()
@@ -28,8 +34,8 @@ class PekkoHttpServerInstrumentationTestAsync
2834
PekkoHttpTestAsyncWebServer.stop()
2935

3036
override protected def configure(
31-
options: HttpServerTestOptions
32-
): Unit = {
37+
options: HttpServerTestOptions
38+
): Unit = {
3339
super.configure(options)
3440
options.setTestHttpPipelining(false)
3541
}
@@ -39,9 +45,13 @@ class PekkoHttpServerInstrumentationTestAsync
3945
val method = "POST"
4046
val traceId = "00000000000000000000000000000123"
4147
val parentId = "0000000000000456"
42-
val aggregatedHttpRequest = AggregatedHttpRequest.of( // intentionally sending mixed-case "tracePARENT" to make sure that TextMapGetters are
43-
// not case-sensitive
44-
request(SUCCESS, method).headers.toBuilder.set("tracePARENT", "00-" + traceId + "-" + parentId + "-01").build)
48+
val aggregatedHttpRequest = AggregatedHttpRequest
49+
.of( // intentionally sending mixed-case "tracePARENT" to make sure that TextMapGetters are
50+
// not case-sensitive
51+
request(SUCCESS, method).headers.toBuilder
52+
.set("tracePARENT", "00-" + traceId + "-" + parentId + "-01")
53+
.build
54+
)
4555
val response = client.execute(aggregatedHttpRequest).aggregate.join
4656
assertThat(response.status.code).isEqualTo(SUCCESS.getStatus)
4757
assertThat(response.contentUtf8).isEqualTo(SUCCESS.getBody)

instrumentation/pekko/pekko-http-1.0/javaagent/src/test/scala/io/opentelemetry/javaagent/instrumentation/pekkohttp/v1_0/PekkoHttpTestAsyncWebServer.scala

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@ package io.opentelemetry.javaagent.instrumentation.pekkohttp.v1_0
77

88
import io.opentelemetry.api.trace.Span
99
import io.opentelemetry.instrumentation.testing.junit.http.ServerEndpoint._
10-
import io.opentelemetry.instrumentation.testing.junit.http.{AbstractHttpServerTest, ServerEndpoint}
10+
import io.opentelemetry.instrumentation.testing.junit.http.{
11+
AbstractHttpServerTest,
12+
ServerEndpoint
13+
}
1114
import org.apache.pekko.actor.ActorSystem
1215
import org.apache.pekko.http.scaladsl.Http
1316
import org.apache.pekko.http.scaladsl.Http.ServerBinding
@@ -60,14 +63,23 @@ object PekkoHttpTestAsyncWebServer {
6063
}
6164
case HttpRequest(POST, uri: Uri, _, _, _) =>
6265
val endpoint = ServerEndpoint.forPath(uri.path.toString())
63-
AbstractHttpServerTest.controller(endpoint, () =>
64-
for {
65-
_ <- Future.successful(2)
66-
firstTraceId = Span.current().getSpanContext().getTraceId()
67-
_ <- after(1.second, system.scheduler)(Future.successful(1))
68-
secondTraceId = Span.current().getSpanContext().getTraceId()
69-
_ = require(firstTraceId eq secondTraceId, s"TraceId $firstTraceId did not match $secondTraceId")
70-
} yield HttpResponse(status = OK, entity = endpoint.getBody)
66+
AbstractHttpServerTest.controller(
67+
endpoint,
68+
() =>
69+
for {
70+
_ <- Future.successful(2)
71+
firstSpanContext = Span.current().getSpanContext()
72+
_ <- after(1.second, system.scheduler)(Future.successful(1))
73+
secondSpanContext = Span.current().getSpanContext()
74+
_ = require(
75+
firstSpanContext.getTraceId() == secondSpanContext.getTraceId(),
76+
s"TraceId ${firstSpanContext.getTraceId()} did not match ${secondSpanContext.getTraceId()}"
77+
)
78+
_ = require(
79+
firstSpanContext.getSpanId() == secondSpanContext.getSpanId(),
80+
s"SpanId ${firstSpanContext.getSpanId()} did not match ${secondSpanContext.getSpanId()}"
81+
)
82+
} yield HttpResponse(status = OK, entity = endpoint.getBody)
7183
)
7284
}
7385

0 commit comments

Comments
 (0)