Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OpenCensus to OpenTelemetry metric exporter #2085

Merged
merged 9 commits into from
Dec 7, 2020

Conversation

zoercai
Copy link
Contributor

@zoercai zoercai commented Nov 17, 2020

The OpenTelemetry merger announcement promised straightforward backwards compatibility with OpenCensus.

This PR adds an OpenCensus bridge for metrics, which allows applications and libraries that are instrumented with OpenTelemetry, but depend on other libraries instrumented with OpenCensus, to export metrics from both OpenTelemetry and OpenCensus.

The bridge maps all OpenCensus metric data to OpenTelemetry metric data, which are then exported by any configured OpenTelemetry exporter.

For OpenCensus spans to be exported as OpenTelemetry spans, this bridge needs to be added as a dependency. An extra line of configuration is also necessary in addition to configuring the OpenTelemetry exporter. For example

// Normal OpenTelemetry exporter configuration
LoggingMetricExporter loggingMetricExporter = new LoggingMetricExporter();
// Extra line, creating the bridge exporter, with the OpenTelemetry exporter
OpenTelemetryMetricsExporter exporter = OpenTelemetryMetricsExporter.createAndRegister(loggingMetricExporter);

cc @nilebox @james-bebbington

@anuraaga
Copy link
Contributor

Just curious is there anything special about metrics that let's us handle it at the export layer instead of instrumentation layer like we did for traces?

@zoercai
Copy link
Contributor Author

zoercai commented Nov 19, 2020

@anuraaga mainly that metrics don't have parent-child relationships, which was the main reason for not handling traces at the export layer. Label propagation hasn't been implemented in OpenTelemetry either (https:/open-telemetry/opentelemetry-specification/blob/master/specification/metrics/api.md#baggage-into-metric-labels) so it seems that it would be fine (and much easier) to export the metric data output rather than modifying the context.

Copy link
Contributor

@anuraaga anuraaga left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks

… into metric-migration

# Conflicts:
#	build.gradle
#	opencensus-shim/src/test/java/io/opentelemetry/opencensusshim/TraceInteroperabilityTest.java
@zoercai zoercai requested a review from nilebox November 26, 2020 08:17
Copy link
Contributor

@anuraaga anuraaga left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor

@jkwatson jkwatson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just one small refactoring needed; otherwise looks good to go.

@zoercai zoercai requested a review from jkwatson December 7, 2020 09:15
Copy link
Contributor

@jkwatson jkwatson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@jkwatson jkwatson merged commit b478493 into open-telemetry:master Dec 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants