Git Product home page Git Product logo

trace's Introduction

trace

Scan with Detekt Build License Kotlin Maven Central

trace-core

trace is a lightweight kotlin dsl wrapper around the OpenTracing api. both normal blocking code as well as kotlin coroutines are supported.

Installation

implementation("io.github.virusbear.trace:trace-core:$traceVersion")

Usage

GlobalTracer defined in opentracing-util is used to get access to a tracer when using the coroutine api. Make sure to register a Tracer instance to the GlobalTracer to ensure proper propagation of this instance.

//Blocking
span("your-operation", tags = mapOf("optional" to "tags"), parent = optionalParentSpanContext) {
    //Code to be traced
}

//Coroutines
withSpan("your-operation", tags = mapOf("optional" to "tags"), parent = optionalParentSpanContext) {
  //Suspending code to be traced
}

SpanScope

Every span or withSpan function receives a SpanScope for the tracing lambda. SpanScope provides a way to add tags to a given span or log certain events.

//span receives SpanScope as receiver for lambda.
span("spanScope") {
  tag("your-tag", "tag-value")
  log(msg)
}

//withSpan receives SpanScope as parameter for lambda. Receiver will be CoroutineScope
span("spanScope") { scope ->
  scope.tag("your-tag", "tag-value")
  scope.log(msg)
}

trace client builder dsl

Currently trace provides a typesafe builder dsl for creating new instances of the jaeger tracing client using the official JaegerTracing java client library.

It is planned to implement builders for more OpenTracing client implementations in the future

Installation

implementation("io.github.virusbear.trace:trace-jaeger:$traceVersion")

Usage

val tracer: Tracer = tracer("tracerName") {
    sampler {
        //set properties for sampler
    }
    reporter {
        //set properties for reporter
        sender {
            //set properties for sender
        }
    }
    scopeManager {
        customScopeManager
    }
}

trace ktor

trace provides Features for both ktor-client and ktor-server. Just call install(Tracing) when setting up the server or client with the corresponding Feature implementation. Trace takes care of the rest

Installation

implementation("io.github.virusbear.trace:trace-ktor-server:$traceVersion")
implementation("io.github.virusbear.trace:trace-ktor-client:$traceVersion")

trace's People

Contributors

virusbear avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

trace's Issues

Dependency Resolution for trace-ktor-server not working

Module: trace-ktor-server
Version: 1.0.3

When adding the above mentioned dependency in gradle the "trace:trace-ktor-core:unpecified" dependency is added.
This dependency is not published on maven causing compile time errors as seen in the gradle output below:

Execution failed for task ':compileKotlin'.
> Error while evaluating property 'filteredArgumentsMap' of task ':compileKotlin'
   > Could not resolve all files for configuration ':compileClasspath'.
      > Could not find trace:trace-ktor-core:unspecified.
        Searched in the following locations:
          - https://repo.maven.apache.org/maven2/trace/trace-ktor-core/unspecified/trace-ktor-core-unspecified.pom
        If the artifact you are trying to retrieve can be found in the repository but without metadata in 'Maven POM' format, you need to adjust the 'metadataSources { ... }' of the repository declaration.
        Required by:
            project : > io.github.virusbear.trace:trace-ktor-server:1.0.3

Possible solution:
 - Declare repository providing the artifact, see the documentation at https://docs.gradle.org/current/userguide/declaring_repositories.html

The publishing.gradle.kts file adds all api dependencies of the published module to the dependencies of the maven artifact.
The dependency section does not check if the api dependency is a project local dependency to bundle or if it is an external dependency to be added to the pom.xml.

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.