Skip to content

Commit dd5ea77

Browse files
committed
Update PekkoHttpTestWebServerWithActor.scala
1 parent 1addd43 commit dd5ea77

File tree

1 file changed

+17
-14
lines changed

1 file changed

+17
-14
lines changed

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

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,28 @@ import org.apache.pekko.util.Timeout
1616
import scala.concurrent.{Await, ExecutionContext}
1717
import scala.concurrent.duration.DurationInt
1818

19-
class PekkoHttpTestWebServerWithActor(port: Int) {
20-
implicit val system: ActorSystem = ActorSystem("http-server-with-actor")
21-
// needed for the future flatMap/onComplete in the end
22-
implicit val executionContext: ExecutionContext = system.dispatcher
23-
24-
private case object TestMessage
25-
private class SpanTestActor extends Actor {
19+
object PekkoHttpTestWebServerWithActor {
20+
case object TestMessage
21+
class SpanTestActor extends Actor {
2622
def receive = { case TestMessage =>
2723
sender() ! spanSummary(Span.current())
2824
}
2925
}
3026

31-
val spanTestActor = system.actorOf(Props(new SpanTestActor))
27+
def spanSummary(span: Span): String = {
28+
val spanId = span.getSpanContext().getSpanId()
29+
val traceId = span.getSpanContext().getTraceId()
30+
s"Span(traceId=$traceId, spanId=$spanId)"
31+
}
32+
}
33+
34+
class PekkoHttpTestWebServerWithActor(port: Int) {
35+
import PekkoHttpTestWebServerWithActor._
36+
implicit val system: ActorSystem = ActorSystem("http-server-with-actor")
37+
// needed for the future flatMap/onComplete in the end
38+
implicit val executionContext: ExecutionContext = system.dispatcher
39+
40+
val spanTestActor = system.actorOf(Props[SpanTestActor]())
3241

3342
val route = get {
3443
path("test") {
@@ -52,10 +61,4 @@ class PekkoHttpTestWebServerWithActor(port: Int) {
5261
binding = null
5362
}
5463
}
55-
56-
def spanSummary(span: Span): String = {
57-
val spanId = span.getSpanContext().getSpanId()
58-
val traceId = span.getSpanContext().getTraceId()
59-
s"Span(traceId=$traceId, spanId=$spanId)"
60-
}
6164
}

0 commit comments

Comments
 (0)