Don't double instrument when using instrumented Ktor client with OkHttp engine
Problem Statement
We're about to release a Ktor client integration for sentry-java.
If a customer uses Ktor client with our integration, OkHttp as the engine for Ktor client, and SAGP with auto-instrumentation for OkHttp, they will end up with doubly instrumented HTTP calls.
While we're going to document very clearly that they should instrument either one or the other, users might still run into this.
There might be a way to detect if calls are being doubly instrumented and deactivate one of the two instrumentations.
Solution Brainstorm
I'm not sure if this is possible in the first place. The bytecode manipulation code would basically have to detect whether OkHttp is running inside Ktor or on its own.
Let's keep this as is for now, as soon as we see people having issues we could start investigating.
Alternative solutions:
- Detect duplicate spans at runtime
- Instrument Ktor engine config blocks to remove our listeners/interceptors again