GithubHelp home page GithubHelp logo

classicvalues / kluzo Goto Github PK

View Code? Open in Web Editor NEW

This project forked from avast/kluzo

0.0 1.0 0.0 145 KB

Library for passing tracing ID between threads in multi-threaded applications

Scala 54.00% Java 44.08% Shell 1.92%

kluzo's Introduction

Build Status Download

Kluzo

Kluzo as in inspector Clouseau

The goal of this library is to add tracing capabilities to our backends. It defines TraceId which needs to be passed throughout the call chain and between backends to connect different calls and actions that were initiated by some initial request. Trace ID is alternatively called correlation ID. This library is based upon the Continuity library.

The idea is that the trace ID should appear in all log messages related to the request, it should be passed between backends (e.g. via HTTP headers) and hopefully it should also be somehow connected to database or queue calls. The end result should be an overview of communication spurred by a single request. Zipkin could be used for that.

It has both Scala and Java APIs.

Most of you won't need to work with this library as it should be integrated into other libraries for seamless cooperation. The only thing that is required and you might need to do yourself is to wrap all your executors (Executor, ExecutorService, ExecutionContext, EventLoopGroup) in Continuity wrappers.

Gradle

dependencies {
    compile 'com.avast:kluzo_?:1.0-SNAPSHOT'
}

Maven

<dependency>
    <groupId>com.avast</groupId>
    <artifactId>kluzo_${build.scala.version}</artifactId>
    <version>1.0-SNAPSHOT</version>
</dependency>

Logback

This is a recommended format for the Kluzo trace ID:

<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} %-5level [%-10mdc{traceId}] [%thread] %-35logger{35}: %msg \(%file:%line\)%n%xThrowable{full}</pattern>

Example

val executor = Continuity.wrapExecutionContext(ExecutionContext.global)(Kluzo.ThreadNamer)

Kluzo.withTraceId(Some(TraceId.generate)) {
  executor.execute(new Runnable {
    override def run(): Unit = {
      println(Kluzo.getTraceId)
      logger.info("logging message")
    }
  })
}

kluzo's People

Contributors

avast-scala-builder avatar jendakol avatar

Watchers

 avatar

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.