Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Tracing phase should surround call logging #27

Open
hannomalie opened this issue Mar 31, 2021 · 6 comments
Open

Tracing phase should surround call logging #27

hannomalie opened this issue Mar 31, 2021 · 6 comments

Comments

@hannomalie
Copy link

Hi there, it's me again :)

I integrated your library successfully and for the "normal use case" everything is fine. However, we have the following requirement: Our service has to include trace ids in all log statements coming from the service.

I have a Layout implementation for logback and everything works fine for regular logging - I just use GlobalTracer.get().activeSpan() in the Layout and fine. However, when the CallLogging is done (Ktor included feature), the span/trace is already closed. That's likely because the finishTracingPhase is happening before the call logging is done.

Is there any chance we can have the span (given by an external trace id through the request) active until the CallLogging phase is done?

My current workaround is to evaluate the MDC in case there is no active span, and the MDC is populated in an early phase manually. That works, but it's not the nicest thing I ever implemented :)

Thank you in advance!

@fstien
Copy link
Contributor

fstien commented Apr 1, 2021

Hey Hannes, Thanks for your message.
Yes so CallLogging intercepts before the monitoring phase, whereas this ktor-opentracing feature was intercepting (and creating the server span) before the features phase, which happens after the monitoring phase. Hence when you try to read the span from GlobalTracer in CallLogging, it hasn't been created yet.

I just released a change where i move back where i intercept to after the setup phase. Do you want to try again with v0.3.2 and let me know ? :)

@hannomalie
Copy link
Author

As soon as we can, thanks in advance!

@ajcastillo301
Copy link

Hi @fstien. Thank you for this nice project, I encountered a similar issue regarding CallLogging in one of my projects. Could you let me know where I can grab the 0.3.2 or 0.3.3 version, I could run a test for you.

@ajcastillo301
Copy link

Just to let you know that we got the 0.3.3 and it is working as expected for our project. Just something to note, the generated POM file you published doesn't include any of the transitive dependencies so we had to add the kotlin-logging-jvm dependency manually. But aside from that, all good!

Thanks you very much!

@fstien
Copy link
Contributor

fstien commented Jun 3, 2021

hey @hannomalie , @ajcastillo301 , Thanks. I had a play around with CallLogging issue, indeed the trace cannot be read when that feature intercepts. I'm not sure why, there's clearly something about CallLogging I don't understand. 🤷‍♂️ I will leave this issue open for now.

@ajcastillo301 Thanks for bringing this up. If you try version 0.3.5 , that has the dependencies in the pom.xml ; https://repo1.maven.org/maven2/com/zopa/ktor-opentracing/0.3.5/ktor-opentracing-0.3.5.pom .

@ajcastillo301
Copy link

That is good to hear. We will surely upgrade on our next iteration, thanks @fstien for all the effort!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants