29 lines
497 B
Go
29 lines
497 B
Go
|
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
|
||
|
}
|