Skip to content

fstien/kotlin-logging-opentracing-decorator

Repository files navigation

Maven Central GitHub Unit Tests Actions Status

kotlin-logging OpenTracing Decorator

Small library on top of kotlin-logging which writes OpenTracing logs in addition to regular logs, by the means of a decorator.

Getting Started

In an application with a tracer registered in GlobalTracer, extend your regular logger instance with OpenTracing logs:

val logger = KotlinLogging.logger {}.withOpenTracingLogs()

Alternatively you instantiate an identical logger as such:

val logger = Logging.logger {}

You can now use the logger as before as it still implements the KLogger interfaces. Hence, if you are already using kotlin-logging, you do not need to make any further changes to your application.

Installation

From Maven Central.

Maven

Add the following dependency to your pom.xml:

<dependency>
  <groupId>com.github.fstien</groupId>
  <artifactId>kotlin-logging-opentracing-decorator</artifactId>
  <version>VERSION_NUMBER</version>
  <type>pom</type>
</dependency>

Gradle

Add the following to your dependencies in your build.gradle:

implementation 'com.github.fstien:kotlin-logging-opentracing-decorator:VERSION_NUMBER'

Example

For use in a Ktor application, see kotlin-logging-opentracing-decorator-example.

image