opentelemetry-go
opentelemetry-go copied to clipboard
OpenCensus Metrics bridge doesn't work with the OpenTelemetry prometheus exporter
Problem Statement
I'd like to be able to send metrics from OpenCensus and OpenTelemetry SDKs to the same prometheus endpoint. This will allow me to migrate my OpenCensus metrics to OpenTelemetry over time.
Proposed Solution
Still investigating
Additional Context
From https://github.com/open-telemetry/opentelemetry-collector/pull/3816
@dashpole thanks for the suggestion! I tried the bridge, but ran into two problems:
- It looks like the otel Prometheus
Exporterdoes not implement metric.Exporter, so I'm not able to pass it intoopencensus.NewMetricExporter()- The
metricexport.Exporterreturned byopencensus.NewMetricExportercan't be passed intoview.RegisterExporterwhich expects aview.Exporterinstead.Any idea where I'm going wrong?
This one blocks collector transition as well. Consider to prioritize this.
Agreed. Once the SDK is rewritten to be spec-compliant, I'll make sure the prometheus exporter works well with the otel SDK. I'll also want to make sure the prometheus exporter for go is compliant with the prom <-> otlp spec I wrote.
Once #3541 lands, the following will work to use the OpenCensus bridge with the prometheus exporter:
exporter, err := prometheus.New()
// handle err
// Register the OpenCensus producer with the Prometheus exporter
exporter.RegisterProducer(opencensus.NewMetricProducer())
provider := metric.NewMeterProvider(metric.WithReader(exporter))
// use meter provider