Kamon icon indicating copy to clipboard operation
Kamon copied to clipboard

[Pekko] Tracing and context propagation are not supported in Scala 3

Open biandratti opened this issue 1 year ago • 0 comments

I have a small PoC for context propagation using the following configuration:

  • kanela-agent: 1.0.18
  • Play Framework with Pekko.
  • Scala 3.x

The example here. The issue is not reproducible with scala 2.13.x. It is only reproducible through scala 3.x. Even in the configuration I'm using implicitly join-remote-parents-with-same-span-id = yes

In this example for Scala 2.13.x, I'm using the following sequence: request to -> app1 -> app2

app1-1    | 2024-06-30T16:28:33.265Z [info] [context-id=mycontextid] a40ac35b63c4a4d3 28cc88a08c4c22ac  services.TraceService [kamonTraceId=a40ac35b63c4a4d3, kamonSpanId=28cc88a08c4c22ac, kamonSpanName=/api/v1/trace] - request to app2
app2-1    | 2024-06-30T16:28:33.832Z [info] [context-id=mycontextid] a40ac35b63c4a4d3 cad21de88f6c6f55  controllers.AppController [upstream.name=app1, kamonTraceId=a40ac35b63c4a4d3, kamonSpanId=cad21de88f6c6f55, kamonSpanName=/api/v1/trace] - trace request with headers: List((Timeout-Access,<function1>), (Remote-Address,172.18.0.4:41114), (Raw-Request-URI,/api/v1/trace), (Tls-Session-Info,Session(1719764907014|SSL_NULL_WITH_NULL_NULL)), (context-id,mycontextid), (X-B3-SpanId,cad21de88f6c6f55), (context-tags,upstream.name=app1;), (X-B3-Sampled,1), (X-B3-TraceId,a40ac35b63c4a4d3), (X-B3-ParentSpanId,28cc88a08c4c22ac), (Host,app2:9002), (Accept,*/*), (user-agent,AHC/2.1))
app1-1    | 2024-06-30T16:28:34.148Z [info] [context-id=mycontextid] a40ac35b63c4a4d3 28cc88a08c4c22ac  services.TraceService [kamonTraceId=a40ac35b63c4a4d3, kamonSpanId=28cc88a08c4c22ac, kamonSpanName=/api/v1/trace] - app2 response: {"id":"a40ac35b63c4a4d3"}

While the Scala 3 example uses the same sequence: request to -> app1 -> app2

app1-1    | 2024-06-30T16:57:18.387Z [info] [context-id=mycontextid] c3a698bd8a416a9e 4b011d22dd49b927  services.TraceService [kamonTraceId=c3a698bd8a416a9e, kamonSpanId=4b011d22dd49b927, kamonSpanName=http.server.request] - request to app2
app2-1    | 2024-06-30T16:57:18.793Z [info] [context-id=mycontextid] 0c4d9dc14cfb6a27 08c095f03d895064  controllers.AppController [kamonTraceId=0c4d9dc14cfb6a27, kamonSpanId=08c095f03d895064, kamonSpanName=http.server.request] - trace request with headers: List((Timeout-Access,<function1>), (Remote-Address,172.18.0.4:43272), (Raw-Request-URI,/api/v1/trace), (Tls-Session-Info,Session(1719766633746|SSL_NULL_WITH_NULL_NULL)), (context-id,mycontextid), (Host,app2:9002), (Accept,*/*), (user-agent,AHC/2.1))
app1-1    | 2024-06-30T16:57:18.943Z [info] [context-id=mycontextid] c3a698bd8a416a9e 4b011d22dd49b927  services.TraceService [kamonTraceId=c3a698bd8a416a9e, kamonSpanId=4b011d22dd49b927, kamonSpanName=http.server.request] - app2 response: {"id":"0c4d9dc14cfb6a27"}

It's visible how for Scala 3 the headers X-B3-Sampled, X-B3-TraceId, X-B3-ParentSpanId are missing in the propagation, and thus the propagation of kamonTraceId is lost.

biandratti avatar Jun 30 '24 17:06 biandratti