Akka NoSuchElementException in RouteConcatenation$RouteWithConcatenation #13049
Open
Description
Hi,
I'm getting following error when using akka + tapir integration:
[otel.javaagent 2025-01-03 16:36:51:073 +0000] [xyz-akka.actor.default-dispatcher-28] DEBUG io.opentelemetry.javaagent.bootstrap.ExceptionLogger - Failed to handle exception in instrumentation for akka.http.scaladsl.server.RouteConcatenation$RouteWithConcatenation
java.util.NoSuchElementException
at java.base/java.util.ArrayDeque.removeFirst(Unknown Source)
at java.base/java.util.ArrayDeque.pop(Unknown Source)
at io.opentelemetry.javaagent.instrumentation.akkahttp.server.route.AkkaRouteHolder.restore(AkkaRouteHolder.java:68)
at akka.http.scaladsl.server.RouteConcatenation$RouteWithConcatenation.$anonfun$$tilde$1(RouteConcatenation.scala:44)
at akka.http.scaladsl.server.RouteConcatenation$RouteWithConcatenation.$anonfun$$tilde$2(RouteConcatenation.scala:47)
at akka.http.scaladsl.util.FastFuture$.strictTransform$1(FastFuture.scala:40)
at akka.http.scaladsl.util.FastFuture$.$anonfun$transformWith$3(FastFuture.scala:50)
at scala.concurrent.impl.Promise$Transformation.run(Promise.scala:484)
at akka.dispatch.BatchingExecutor$AbstractBatch.processBatch(BatchingExecutor.scala:64)
at akka.dispatch.BatchingExecutor$BlockableBatch.$anonfun$run$1(BatchingExecutor.scala:101)
at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.scala:18)
at scala.concurrent.BlockContext$.withBlockContext(BlockContext.scala:94)
at akka.dispatch.BatchingExecutor$BlockableBatch.run(BatchingExecutor.scala:101)
at akka.dispatch.TaskInvocation.run(AbstractDispatcher.scala:49)
at akka.dispatch.ForkJoinExecutorConfigurator$AkkaForkJoinTask.exec(ForkJoinExecutorConfigurator.scala:48)
at java.base/java.util.concurrent.ForkJoinTask.doExec(Unknown Source)
at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(Unknown Source)
at java.base/java.util.concurrent.ForkJoinPool.scan(Unknown Source)
at java.base/java.util.concurrent.ForkJoinPool.runWorker(Unknown Source)
at java.base/java.util.concurrent.ForkJoinWorkerThread.run(Unknown Source)
As a result traces are recorded only with http method without path.
For the same endpoint defined without tapir it works fine.
tapir version 1.11.12
akka version 2.8.5
Tapir endpoint definition looks more or less like that:
val definition =
baseEndpoint.get
.in("catalog" / "api" / "v1" / "actions")
.in(QueryParams.actionIdOpt)
.mapInTo[ActionEnpointInput]
.out(statusCode.and(jsonBody[Seq[ActionMessage]]))
Steps to reproduce
Create scala application with tapir + akka http server. Instrument it with otel agent. Set OTEL_JAVAAGENT_DEBUG=true.
Expected behavior
OTEL will record span with http method and path.
Actual behavior
As a span name I get only method name without path.
Javaagent or library instrumentation version
2.11.0
Environment
JDK: AdoptOpenJDK OpenJDK 64-Bit Server VM 11.0.7+10
OS: Linux 5.10.230-223.885.amzn2.x86_64
Additional context
No response