mirror of
https://github.com/open-telemetry/opentelemetry-go.git
synced 2024-11-28 08:38:51 +02:00
opencensus.NewMetricProducer returns a struct instead of the metric.Producer (#4583)
This commit is contained in:
parent
56766cadc0
commit
68241aff1d
@ -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].
|
||||
|
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user