Giter VIP home page Giter VIP logo

Comments (8)

randers-bit avatar randers-bit commented on June 21, 2024

I will add that on previous kamon version (2.5.12) i didn't saw this double logging.

from kamon.

ivantopo avatar ivantopo commented on June 21, 2024

Before we were logging that banner from Kanela (the javaagent) but since 2.6.0 we moved it to Kamon Kamon itself, so my guess is that your code is calling Kamon.init twice, the question is how if you are only calling init in the application loader 🤔

Is this happening when running in K8s or SBT, or both?

from kamon.

randers-bit avatar randers-bit commented on June 21, 2024

Im running only on kubernetes (kubeadm deploy or minikube). On sbt run my project would not run (because of service discovery configuration). Im sure im only running it once in application loader of lagom. Maybe Lagom is calling twice for service creation? Now i don't have time to do research on this but next time i will check what i can find about it.

If kamon is called twice with init it will create second monitoring or it is like singleton and second call will be ignored?

from kamon.

randers-bit avatar randers-bit commented on June 21, 2024

Hello,
i created simple lagom application with deployment to minikube (it is based on sbt new lagom/lagom-scala.g8).

I added kanela and kamon dependency and added logger before initializing kamon and i found something.

First attempt looks like this:

    override def load( context: LagomApplicationContext ): LagomApplication = {
        logger.info( "Initializing Kamon" )
        Kamon.initWithoutAttaching( context.playContext.initialConfiguration.underlying )

        context.playContext.lifecycle.addStopHook( ( ) => {
            Kamon.stop()
        } )

        new HelloWorldApplication( context ) {
            override def serviceLocator: ServiceLocator = NoServiceLocator
        }
    }

After running in minikube i saw that kamon is double printed in pod console.
image

Then i tried to change initialization without parameters.
After change i used just this:

Kamon.initWithoutAttaching()

And after deployment only one Kamon log appeared in console.
image

It seems like passing context.playContext.initialConfiguration.underlying to initialization is creating second kamon instance or is forcing second printing of Kamon logo.

from kamon.

randers-bit avatar randers-bit commented on June 21, 2024

I propably found why Kamon is double printed.
When using initWithoutAttaching with configuration then this function is called in Kamon project (Init.scala):

  def initWithoutAttaching(config: Config): Unit = {
    self.reconfigure(config)

    if(enabled()) {
      self.initWithoutAttaching()
    } else {
      self.disableInstrumentation()
    }

    self.logInitStatusInfo()
  }

On the end of function logging is done.
If kamon is enabled then self.initWithoutAttaching() is called and this is executed:

  def initWithoutAttaching(): Unit = {
    if(enabled()) {
      self.initScheduler()
      self.loadModules()
      self.moduleRegistry().init()
    } else {
      self.disableInstrumentation()
    }

    self.logInitStatusInfo()
  }

And again in this function logging is called on the end.
So for me it seems like when passing config logging is called twice.

from kamon.

ivantopo avatar ivantopo commented on June 21, 2024

Yeah, that's exactly it. Fixed it on #1256

from kamon.

ivantopo avatar ivantopo commented on June 21, 2024

All in all, it's just the banner printed twice, but Kamon is not initialized twice.

from kamon.

randers-bit avatar randers-bit commented on June 21, 2024

For me this is a very small issue and can be ignored.
Im closing this issue.

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.