Giter VIP home page Giter VIP logo

Comments (5)

ivantopo avatar ivantopo commented on July 3, 2024

Hey @scheleaap 👋

I looked into this and the problem I found is that sometimes the Play instrumentation gets loaded before the logback instrumentation (see image below). When that happens, the Play instrumentation loads the logback classes before they get instrumented and nothing gets copied.

image
(you can get the same output adding -Dkanela.debug-mode=YES -Dkanela.log-level=DEBUG to your JVM options)

Running your reproducer several times should work every now and then, depending on the order the modules are loaded. You can workaround it with this setting:

kanela.modules.play-framework.order = 3

I'll be opening a PR with that same change, assuming that's the only thing we need to fix it 🙏

from kamon.

scheleaap avatar scheleaap commented on July 3, 2024

Hi @ivantopo, thank you for taking a look. I am getting consistent results when I run the example project.

When I add the setting you mentioned I can see that the Logback instrumentation gets loaded before the Play Framework instrumentation, but it does not bring the MDC tag back.

I have updated example project accordingly. Does the application log the MDC tag when you run it on your machine?

For reference, here's my log output:

...
[info] [Attach Listener] INFO 2022-12-14 17:15:13  Logger : The Module: Executor Service Capture on Submit Instrumentation is disabled 
[info] [Attach Listener] INFO 2022-12-14 17:15:13  Logger : The Module: Scala Future Chaining Instrumentation (Deprecated) is disabled 
[info] [Attach Listener] INFO 2022-12-14 17:15:13  Logger : Loading Logback Instrumentation  
[info] [Attach Listener] INFO 2022-12-14 17:15:13  Logger :  ==> Loading kamon.instrumentation.logback.LogbackInstrumentation  
[info] [Attach Listener] INFO 2022-12-14 17:15:13  Logger : Retransformation Strategy activated for: Logback Instrumentation 
[info] [Attach Listener] INFO 2022-12-14 17:15:13  Logger : Periodic Resubmitter activated. 
[info] [Attach Listener] INFO 2022-12-14 17:15:13  Logger : Loading Play Framework Instrumentation  
[info] [Attach Listener] INFO 2022-12-14 17:15:13  Logger :  ==> Loading kamon.instrumentation.play.PlayServerInstrumentation  
[info] [Attach Listener] INFO 2022-12-14 17:15:13  Logger :  ==> Loading kamon.instrumentation.play.PlayClientInstrumentation  
[info] [Attach Listener] INFO 2022-12-14 17:15:13  Logger : Retransformation Strategy activated for: Play Framework Instrumentation 
...
[info] {"@timestamp":"2022-12-14T16:17:31.052Z","level":"INFO","level_value":20000,"message":"Application starting...","logger_name":"foo.Application$","thread_name":"main","caller_class_name":"foo.Application$","caller_method_name":"$anonfun$new$1","caller_file_name":"Application.scala","caller_line_number":8}
[success] Total time: 3 s, completed Dec 14, 2022, 5:17:31 PM

from kamon.

ivantopo avatar ivantopo commented on July 3, 2024

I see you are running this from SBT and that might be the issue. Even though you have the fork and javaAgents settings, the only way I was able to make it work when running with SBT was by adding our SBT plugin:

addSbtPlugin("io.kamon" % "sbt-kanela-runner" % "2.0.14")

My previous tests were directly from IntelliJ. You can see two runs here, before/after adding the plugin:
image

I think it is fair to assume that the ordering change fixes the issue 💪

from kamon.

scheleaap avatar scheleaap commented on July 3, 2024

We were able to get everything to work thanks to your suggestions @ivantopo. To summarize, in the end we had to make two changes:

  1. Add kanela.modules.logback.order = 1 to our configuration to ensure that the Logback instrumentation is loaded as soon as possible.
  2. Add the sbt-kanela-runner Sbt plugin (addSbtPlugin("io.kamon" % "sbt-kanela-runner" % "2.0.14"))

Thank you for your valuable support @ivantopo! 💯

I believe we can close this issue now.

from kamon.

ivantopo avatar ivantopo commented on July 3, 2024

Thanks for sharing your results @scheleaap. Have a great day!

from kamon.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.