Giter VIP home page Giter VIP logo

Comments (9)

hughsimpson avatar hughsimpson commented on July 22, 2024 5

Thanks this was very helpful. I believe I've identified the issue and am working on a patched release - the sl4fj bug wasn't the only issue, although it was certainly the most visible side-effect. It seems that all the pekko dependencies were being pulled in transitively to the produced jar - this produced a funny situation where the 1.7.x slf4j LoggerFactory implementation was being used despite eviction, and broke implementations depending on the 2.x api. It also caused the kamon-bundle jar size to balloon tremendously. Releasing a patch under 2.6.5 now 🤞

from kamon.

hughsimpson avatar hughsimpson commented on July 22, 2024 2

Marking this as resolved now - testing with 2.6.5 shows this to be fixed

from kamon.

Dichotomia avatar Dichotomia commented on July 22, 2024

Exact same problem here

from kamon.

irajhedayati avatar irajhedayati commented on July 22, 2024

Same here. I'm using MDC, and my context variables always return null. Looking at the code, there are some dependency issues. The log4j classes are present in the kammon-bundle. I even tried to exclude the library but didn't work.

image

from kamon.

hughsimpson avatar hughsimpson commented on July 22, 2024

Welp this is unexpected. Let me have a look, and apologies - I was responsible for that release 😅

from kamon.

hughsimpson avatar hughsimpson commented on July 22, 2024

Nothing jumps out... I thought maybe there's a stray akka reference in the pekko branch, but a grep reveals nothing but some copied comments that haven't been suitably adapted...

from kamon.

hughsimpson avatar hughsimpson commented on July 22, 2024

Well the only thing that changed that I could think of as relevant is the sbt version. It's possible that some semantic correction has led to a 'provided' dependency actually.. being... provided. Suggest checking the dependencies of the modules you use, and explicitly including what ever logback libs you were implicitly depending on before...

from kamon.

hughsimpson avatar hughsimpson commented on July 22, 2024

A microproject that emulated this problem would be immensely helpful anyway. Since there are multiple thumbs up on this, I assume that someone should be able to whip one up. I'll dig in as soon as I can.

from kamon.

irajhedayati avatar irajhedayati commented on July 22, 2024

@hughsimpson, thanks for looking into this. Here is my issue:

build.properties

sbt.version = 1.6.2

build.sbt

ThisBuild / version := "0.1.0-SNAPSHOT"

ThisBuild / scalaVersion := "2.13.12"

val LogbackVersion = "1.4.11"
val KamonVersion = "2.6.4"
val ScalaLoggingVersion = "3.9.5"

lazy val root = (project in file("."))
  .settings(
    name := "untitled",
    libraryDependencies ++= Seq(
      "com.typesafe.scala-logging" %% "scala-logging"    % ScalaLoggingVersion,
      "ch.qos.logback"              % "logback-classic"  % LogbackVersion,
      "io.kamon"                   %% "kamon-bundle"     % KamonVersion,
      "io.kamon"                   %% "kamon-prometheus" % KamonVersion
    )
  )

src/main/resources/logback.xml

<configuration>
    <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
        <encoder>
            <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} %-5level%X{runId}%X{requestId} %-36.36logger{36}  %msg%n%rEx</pattern>
        </encoder>
    </appender>

    <root level="INFO">
        <appender-ref ref="STDOUT"/>
    </root>
</configuration>

src/main/scala/Main.scala

import com.typesafe.scalalogging.LazyLogging
import org.slf4j.MDC

import java.util.UUID

object Main extends App with LazyLogging {
  MDC.put("runId", s" [runId=${UUID.randomUUID().toString}]")
  MDC.put("requestId", s" [requestId=${UUID.randomUUID().toString}]")
  logger.info("Sample message")
  MDC.clear()

}

Kamon 2.6.3

Here is the output

2023-10-08 23:02:19.661 INFO  [runId=2c7cc229-afb2-4d8e-9a18-c34eda1af7e9] [requestId=7434964a-e58d-40ce-aae8-d46bb2b13335] Main$                                 Sample message

Process finished with exit code 0

Kamon 2.6.4

Here is the output

SLF4J: Failed to load class "org.slf4j.impl.StaticMDCBinder".
SLF4J: Defaulting to no-operation MDCAdapter implementation.
SLF4J: See http://www.slf4j.org/codes.html#no_static_mdc_binder for further details.
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.

Process finished with exit code 0

I also checked the classpath, and everything is the same. I think your suspicion about some classes creeping into the Kamon is the cause.

Let me know if you want me to upload the project somewhere, but it's basically just these files.

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.