GithubHelp home page GithubHelp logo

isabella232 / opentracing-basic Goto Github PK

View Code? Open in Web Editor NEW

This project forked from ebay/opentracing-basic

0.0 0.0 0.0 147 KB

Basic OpenTracing bridge library for Java

License: Apache License 2.0

Java 100.00%

opentracing-basic's Introduction

Basic OpenTracing API Implementation for Java

Build Status Download Code Quality

Introduction

The OpenTracing API for Java defines the interfaces for how a user interacts with a compliant OpenTracing back-end but leaves it up to the OpenTracing backend implementation to fulfill the API requirements. When creating simple bridge implementations, tracing data ETL operations, or integrating OpenTracing support in constrained environments this can amount to a significant effort in order to define and consistently adhere to the API.

The goal of this library is to attempt to implement the generic semantics of the OpenTracing API and allow for the main implementation details to be provided into the library by the consumer.

Status

This project is currently in beta. The API should be considered to be unstable and the implementation is not yet optimized.

Obtaining the Library

This library is distributed via both jcenter and maven central repositories. The latest version number is represented in the "Download" badge at the top of this page. To use the library, include it as a dependency in your project as follows:

Gradle:

dependencies {
    compile 'com.ebay.opentracing:opentracing-basic:${version}'
}

Maven:

<dependencies>
    <dependency>
        <groupId>com.ebay.opentracing</groupId>
        <artifactId>opentracing-basic</artifactId>
        <version>${version}</version>
    </dependency>
</dependencies>

Usage

At a high level, the use of this library requires the developer to do the following:

  1. Define a "trace context" object which encapsulates the data which is specific to the tracing implementation back-end (e.g., Trace ID, Span ID, sampling information, etc.). This "trace context" object may be a plain old Java object (POJO). An example implementation is provided in the test code: TestTraceContext
  2. Create an implementation of the TraceContextHandler interface which creates instances of InternalSpanContext<?> which integrate the custom trace context data. An example implementation is provided in the test code: TestTraceContextHandler
  3. Create an implementation of the FinishedSpanReceiver interface to take finished spans' data and use the data as appropriate for the consumer's use case. An example implementation is provided in the test code:

Once the above have been setup, usage of the library may be as simple as the following:

TraceContextHandler traceContextHandler = ...
FinishedSpanReceiver receiver = ...
Tracer tracer = new BasicTracerBuilder<>(traceContextHandler, receiver)
    .build();

try (Scope scope = tracer.buildSpan("operation").startActive(true)) {
    // Measured work
}

Optional Features

Formatters

To achieve cross-process operation, one or more implementation(s) of the Formatter interface may be supplied in order to define how the trace/span context is applied to a data carrier of a particular type. Once defined, the formatter should be registered at Tracer- creation time as in the following example, replacing the Format with the appropriate type.

Tracer tracer = new BasicTracerBuilder<>(traceContextHandler, receiver)
    .registerFormatter(Format.Builtin.TEXT_MAP, formatter)
    .build();

The Basic Tracer implementation will then leverage the provided formatter for inject and extract operations.

Span Initiators

When the tracer implementation is creating a new span instance, it provides the opportunity to hook into the creation process by providing a SpanInitiator instance. This allows integration at the front-end of the span whereas the span receiver allows for integration at the back-end.

When called, the initiator should leverage the provided initiator context to create and return the Span instance. The initiator instance can use this opportunity to decorate or populate data within the span before being used at the call point.

Custom initiators are registered with the Tracer though the BasicTracerBuilder:

SpanInitiator initiator = ...
Tracer tracer = new BasicTracerBuilder<>(traceContextHandler, receiver)
    .spanInitiator(initiator)
    .build();

References

opentracing-basic's People

Contributors

edent avatar josephchern avatar mcumings 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.