Ktor 3: CallLogging and StatusPages don't have Trace IDs #13237
Labels
bug
Something isn't working
contribution welcome
Request makes sense, maintainers probably won't have time, contribution would be welcome
Describe the bug
I have a Ktor 3 based project I want to use tracing with, but the
CallLogging
andStatusPages
logs don't have tracing data included in them.Steps to reproduce
Run a basic Ktor application with the module configuration like this:
Expected behavior
In case of a successful call (200 status), the log statements from
CallLogging
plugin should include tracing data.In case of an error, log statements from the status page configuration should include tracing data as well.
Actual behavior
Neither of the above cases have tracing data in their log statements
Javaagent or library instrumentation version
io.opentelemetry.instrumentation:opentelemetry-ktor-3.0:2.12.0-alpha
Environment
JDK: Temurin 21
OS: Ubuntu 24.04
Additional context
I did a whole bunch of debugging and what I've noticed is that the
io.opentelemetry.instrumentation.ktor.v2_0.common.internal.KtorServerTelemetryUtil#configureTelemetry
function sets up tracing before the monitoring phase, which is way too late in the pipeline.Both the above mentioned
CallLogging
andStatusPages
plugins use hooks that run BEFORE theMonitoring
and therefore theOpenTelemetry
phases. In case ofStatusPages
, the hook used isCallFailed
which intercepts theBeforeSetup
phase.I think, that tracing should start as early in the pipeline as possible, therefore I suggest inserting the
OpenTelemetry
phase before theBeforeSetup
phase, or at least before theSetup
phase (I realize BeforeSetup isn't guaranteed to exist).The text was updated successfully, but these errors were encountered: