plug-sdk/pkg/telemetry/metrics.go

29 lines
497 B
Go
Raw Permalink Normal View History

package telemetry
import (
"go.opentelemetry.io/otel"
"go.opentelemetry.io/otel/exporters/prometheus"
"go.opentelemetry.io/otel/sdk/metric"
)
func SetupMeterProvider(plugName string) error {
res, err := newResource(plugName)
if err != nil {
return err
}
promReader, err := prometheus.New()
if err != nil {
return err
}
meterProvider := metric.NewMeterProvider(
metric.WithResource(res),
metric.WithReader(promReader),
)
otel.SetMeterProvider(meterProvider)
return nil
}