Support for Akka HTTP connection source
See original GitHub issueCurrently, the Akka HTTP instrumentation only supports using .bindAndHandleSync
and .bindAndHandleAsync
methods (.bind
and .bindAsync
in Akka HTTP 10.2’s new ServerBuilder methods). I’d like to add support for the connection source method (Http().bind
in 10.0 and 10.1, builder.connectionSource()
in 10.2).
The connection source method works by providing the user with a Source[Http.IncomingConnection]. We can instrument this class’s .handleWith function to wrap the handler in instrumentation.
The instrumentation required to wrap .handleWith can also be used to complete #5137, as they require wrapping a handler of type Flow.
We’re currently internally testing an implementation of this instrumentation, but decided to create this issue first for feedback as recommended in the contributing guidelines.
Issue Analytics
- State:
- Created a year ago
- Reactions:2
- Comments:5 (2 by maintainers)
That sounds very plausible, I know Akka doesn’t play well with ThreadLocals. The comment on the existing Akka instrumentation about there being no clean way to handle closing scopes is making more sense now as well.
We’ll keep looking into this, see if we can find a way around it.
hi @zackman0010, it sounds most likely that you are leaking a Scope, meaning you are setting the context as current (which binds it to thread local) and then not closing the associated scope in the same thread.
it’s best to always call makeCurrent in a try-with-resources block, or if you are inside of bytebuddy advice it’s a little tricker, but make sure you are starting the scope in OnMethodEnter, passing the Scope object to OnMethodExit and closing it there