diff --git a/CHANGELOG.md b/CHANGELOG.md index 7e551679270..94870c638d6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,10 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm - Deprecate `go.opentelemetry.io/otel/bridge/opencensus.NewTracer` in favor of `opencensus.InstallTraceBridge`. (#4567) +### Changed + +- `go.opentelemetry.io/otel/bridge/opencensus.NewMetricProducer` returns a `*MetricProducer` struct instead of the metric.Producer interface. (#4583) + ## [1.19.0/0.42.0/0.0.7] 2023-09-28 This release contains the first stable release of the OpenTelemetry Go [metric SDK]. diff --git a/bridge/opencensus/metric.go b/bridge/opencensus/metric.go index d11b1de21ba..67e7c2fabb3 100644 --- a/bridge/opencensus/metric.go +++ b/bridge/opencensus/metric.go @@ -26,19 +26,23 @@ import ( "go.opentelemetry.io/otel/sdk/metric/metricdata" ) -type producer struct { +// MetricProducer implements the metric.Producer interface to provide metrics +// from OpenCensus to the OpenTelemetry SDK. +type MetricProducer struct { manager *metricproducer.Manager } // NewMetricProducer returns a metric.Producer that fetches metrics from // OpenCensus. -func NewMetricProducer(opts ...MetricOption) metric.Producer { - return &producer{ +func NewMetricProducer(opts ...MetricOption) *MetricProducer { + return &MetricProducer{ manager: metricproducer.GlobalManager(), } } -func (p *producer) Produce(context.Context) ([]metricdata.ScopeMetrics, error) { +var _ metric.Producer = (*MetricProducer)(nil) + +func (p *MetricProducer) Produce(context.Context) ([]metricdata.ScopeMetrics, error) { producers := p.manager.GetAll() data := []*ocmetricdata.Metric{} for _, ocProducer := range producers {