-
Notifications
You must be signed in to change notification settings - Fork 904
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Akka NoSuchElementException in RouteConcatenation$RouteWithConcatenation #13049
Comments
Could you provide a minimal application that reproduces the issue along with any necessary instructions. |
This has been automatically marked as stale because it has been marked as needing author feedback and has not had any activity for 7 days. It will be closed automatically if there is no response from the author within 7 additional days from this comment. |
@laurit Sorry for the delay; I work with @Matzz, and we now have a minimal reproducible example. Here is the reproduction. I'm happy to help try to help fix this issue, though I may need a bit of guidance. |
FWIW, I also added a
So this does appear to be specific to Tapir with using the Pekko integration. |
I've been continuing to dig into this. The ordering between how the advice classes are applied is indeed different between the two programs 🤔. Tapir with tilde print logs
Pekko with tilde print logs
Note: this is the file I added printlns to. |
@trask Is there anyway to "save" the transformed bytecode (that could then be decompiled) to get a clearer sense of why the ordering is different between plain Pekko and Tapir/Pekko applications? |
Disregard, I just discovered the lovely |
@trask @laurit I think I've found the issue, but I'm not sure of how to fix it. RouteConcatenation transforms the def myTilde(other: RequestContext => Future[RouteResult]): RequestContext => Future[RouteResult] = { ctx =>
try {
System.err.println(s"===In tilde1 onEnter=== [${Thread.currentThread().getName}:${Thread.currentThread().getId}]")
MyPekkoRouteHolder.save()
FastFuture // <-- Race condition!
.EnhancedFuture(route(ctx))
.fast
.flatMap { result =>
$anonfun$$tilde$2(other, ctx, result)
}(ctx.executionContext)
} finally {
System.err.println(s"===In tilde1 onExit=== [${Thread.currentThread().getName}:${Thread.currentThread().getId}]")
try
MyPekkoRouteHolder.restore()
catch {
case t: Throwable =>
System.err.println(
"Failed to handle exception in instrumentation for org.apache.pekko.http.scaladsl.server.RouteConcatenation$RouteWithConcatenation"
)
ExceptionLogger.logSuppressedError(
"Failed to handle exception in instrumentation for org.apache.pekko.http.scaladsl.server.RouteConcatenation$RouteWithConcatenation",
t
)
}
}
} The problem is that since the constructed To verify this is the case, I implemented a tilde function that ensures the def myTilde(other: RequestContext => Future[RouteResult]): RequestContext => Future[RouteResult] = { ctx =>
System.err.println(s"===In tilde1 onEnter=== [${Thread.currentThread().getName}:${Thread.currentThread().getId}]")
MyPekkoRouteHolder.save()
implicit val ec: ExecutionContext = ctx.executionContext
FastFuture
.EnhancedFuture(route(ctx))
.fast
.flatMap { result =>
$anonfun$$tilde$2(other, ctx, result)
}(ctx.executionContext)
.andThen { _ =>
System.err.println(
s"===In tilde1 onExit=== [${Thread.currentThread().getName}:${Thread.currentThread().getId}]"
)
MyPekkoRouteHolder.restore()
}
}
With this implementation, everything works as expected--in my "minimal" programs, the ordering of the Advice printlns match. With all of this said, it's unclear what the best way to proceed is since we obviously can't add this finalization logic to the |
Hi,
I'm getting following error when using akka + tapir integration:
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:
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
The text was updated successfully, but these errors were encountered: