Anders Sveen
02/18/2021, 1:52 PMContinuationInterceptor
to KTor Server execution context? I am trying to add one just by doing GlobalScope.embeddedServer(factory = Jetty, ... , parentCoroutineContext = MyContinuationInterceptor())
, but the interceptor never seems to trigger. I have done something similar with an Interceptor and withContext(MyContinuationInterceptor()) { ... }
. That works, but thought I would "plug it in" at the "top" to see if I could do that. Is it at all possible?cy
02/18/2021, 1:57 PMcy
02/18/2021, 1:58 PMcy
02/18/2021, 1:58 PMAnders Sveen
02/18/2021, 2:12 PMJettyHandler
) to the rest of the call stack in a way that New Relic ties into the same Transaction. It kind of works now by intercepting the ApplicationPipeline
and doing a withContext(MyContinuationInterceptor()) { ... }
. This handles a token.link()
call for each resume.
But the first transaction (JettyHandler
) is "logged" as a separate transaction from the ApplicationPipeline intercept. I was hoping I would be able to do something similar from the "top" level with the parentCoroutineContext
.
Any other approaches that might work? 🙂mp
02/18/2021, 2:14 PMmp
02/18/2021, 2:15 PMcy
02/18/2021, 2:16 PMmp
02/18/2021, 2:18 PMmp
02/18/2021, 2:19 PMcy
02/18/2021, 2:22 PMcy
02/18/2021, 2:23 PMAnders Sveen
02/18/2021, 2:28 PMmp
02/18/2021, 2:32 PMAnders Sveen
02/18/2021, 2:35 PMmp
02/18/2021, 2:35 PMmp
02/18/2021, 2:35 PMmp
02/18/2021, 2:36 PMmp
02/18/2021, 2:38 PMclass_transformer
section:
# NR doesn't know what to do with ktor, so it just lumps everything into NettyDispatcher.
# However, we use a separate ktor / NR integration.
# Per <https://docs.newrelic.com/docs/agents/java-agent/async-instrumentation/disable-scala-netty-akka-play-2-instrumentation>
com.newrelic.instrumentation.netty-3.4:
enabled: false
com.newrelic.instrumentation.netty-3.8:
enabled: false
com.newrelic.instrumentation.netty-4.0.0:
enabled: false
com.newrelic.instrumentation.netty-4.0.8:
enabled: false
Anders Sveen
02/18/2021, 2:40 PMAnders Sveen
02/18/2021, 2:43 PMmp
02/18/2021, 2:50 PMmp
02/18/2021, 2:52 PMmp
02/18/2021, 2:52 PMmp
02/18/2021, 2:55 PMAnders Sveen
02/22/2021, 2:03 PMtransaction.token();launch{...token.link()...}.invokeOnCompletion {token.expire()}
. I am also adding the token to the coroutineContext of launch so it's picked up by a copy of your code @mp that names the transaction correctly "inside" Ktor. So now the entire thing shows up as one transaction in NR with a proper naming. But... I am getting a "AsyncProcessing" part (basically a duplication of the time of the rest of the transaction) that I am not sure how to get rid of. You wouldn't have an idea @mp? I know it's hard to day, but I had to ask on the off chance you did. 🙂mp
02/22/2021, 2:06 PMAnders Sveen
02/22/2021, 2:07 PMAnders Sveen
03/14/2022, 12:45 PMAnders Sveen
10/28/2022, 12:24 PM