Skip to content

lightstep/lightstep-census-java

Repository files navigation

Circle CI Released Version Apache-2.0 license

LightStep OpenCensus Trace Exporter

The LightStep OpenCensus Trace Exporter is a trace exporter that exports data to LightStep.

Installation

pom.xml

<dependency>
    <groupId>com.lightstep.opencensus</groupId>
    <artifactId>lightstep-opencensus-exporter</artifactId>
    <version>VERSION</version>
</dependency>

<dependency>
    <groupId>io.opencensus</groupId>
    <artifactId>opencensus-impl</artifactId>
    <version>0.19.0</version>
    <scope>runtime</scope>
</dependency>

Also add dependencies required for LightStep tracer

Usage

Initialization

// Instantiate LightStep tracer
JRETracer jreTracer = ... 

// Register the exporter
LightStepTraceExporter.createAndRegister(jreTracer);

// Optionally configure 100% sample rate, otherwise, few traces will be sampled
TraceConfig traceConfig = Tracing.getTraceConfig();
    traceConfig.updateActiveTraceParams(
        traceConfig.getActiveTraceParams()
            .toBuilder()
            .setSampler(Samplers.probabilitySampler(1))
            .build());

Shutdown

// To shutdown the exporter
Tracing.getExportComponent().shutdown();

// Close the tracer, so that it'll flush queued traces
jreTracer.close();

Example

There is an example which demonstrate basic usage of the exporter.

License

Apache 2.0 License.