opentelemetry-java/opencensus-shim
Bogdan Drutu 93dd38a18d
Ensure ParametersAreNonnullByDefault is present in all packages (#2879)
Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>
2021-02-18 08:58:01 -08:00
..
src Ensure ParametersAreNonnullByDefault is present in all packages (#2879) 2021-02-18 08:58:01 -08:00
README.md OpenCensus to OpenTelemetry metric exporter (#2085) 2020-12-07 08:30:22 -08:00
build.gradle.kts Migrate remaining gradle scripts to kotlin (#2820) 2021-02-16 14:11:07 -08:00
gradle.properties Mark a few more modules as alpha release status (#2436) 2021-01-07 20:30:53 -08:00

README.md

OpenTelemetry OpenCensus Shim

The OpenCensus shim allows applications and libraries that are instrumented with OpenTelemetry, but depend on other libraries instrumented with OpenCensus, to export trace spans from both OpenTelemetry and OpenCensus with the correct parent-child relationship. It also allows OpenCensus metrics to be exported by any configured OpenTelemetry metric exporter.

Usage

Traces

To allow the shim to work for traces, add the shim as a dependency.

Nothing else needs to be added to libraries for this to work.

Applications only need to set up OpenTelemetry exporters, not OpenCensus.

Metrics

To allow the shim to work for metrics, add the shim as a dependency.

Applications also need to pass the configured metric exporter to the shim:

OpenTelemetryMetricsExporter exporter =
         OpenTelemetryMetricsExporter.createAndRegister(metricExporter);

For example, if a logging exporter were configured, the following would be added:

LoggingMetricExporter metricExporter = new LoggingMetricExporter();
OpenTelemetryMetricsExporter exporter =
         OpenTelemetryMetricsExporter.createAndRegister(metricExporter);

The export interval can also be set:

OpenTelemetryMetricsExporter exporter =
         OpenTelemetryMetricsExporter.createAndRegister(metricExporter,
                Duration.create(0, 500));

Known Problems

  • OpenCensus links added after an OpenCensus span is created will not be exported, as OpenTelemetry only supports links added when a span is created.