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 (#4583)
  • Loading branch information
dashpole authored Oct 9, 2023
1 parent 56766ca commit 68241af
Show file tree
Hide file tree
Showing 2 changed files with 14 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
14 changes: 10 additions & 4 deletions bridge/opencensus/metric.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,25 @@ import (
"go.opentelemetry.io/otel/sdk/metric/metricdata"
)

type producer struct {
// MetricProducer implements the [go.opentelemetry.io/otel/sdk/metric.Producer] 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)

// Produce fetches metrics from the OpenCensus manager,
// translates them to OpenTelemetry's data model, and returns them.
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 68241af

Please sign in to comment.