Skip to content

Commit

Permalink
opencensus.NewMetricProducer returns a struct instead of the metric.P…
Browse files Browse the repository at this point in the history
…roducer interface
  • Loading branch information
dashpole committed Oct 3, 2023
1 parent c7f53cc commit fd8a3ba
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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].
Expand Down
12 changes: 8 additions & 4 deletions bridge/opencensus/metric.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit fd8a3ba

Please sign in to comment.