mirror of
https://github.com/zitadel/zitadel.git
synced 2025-01-06 12:47:37 +00:00
fix: use singleton meter provider (#5725)
This commit is contained in:
parent
c12c2f09a4
commit
923f691d77
@ -18,7 +18,7 @@ import (
|
||||
)
|
||||
|
||||
type Metrics struct {
|
||||
Exporter *prometheus.Exporter
|
||||
Provider metric.MeterProvider
|
||||
Meter metric.Meter
|
||||
Counters sync.Map
|
||||
UpDownSumObserver sync.Map
|
||||
@ -34,12 +34,13 @@ func NewMetrics(meterName string) (metrics.Metrics, error) {
|
||||
if err != nil {
|
||||
return &Metrics{}, err
|
||||
}
|
||||
meterProvider := sdk_metric.NewMeterProvider(
|
||||
sdk_metric.WithReader(exporter),
|
||||
sdk_metric.WithResource(resource),
|
||||
)
|
||||
return &Metrics{
|
||||
Exporter: exporter,
|
||||
Meter: sdk_metric.NewMeterProvider(
|
||||
sdk_metric.WithReader(exporter),
|
||||
sdk_metric.WithResource(resource),
|
||||
).Meter(meterName),
|
||||
Provider: meterProvider,
|
||||
Meter: meterProvider.Meter(meterName),
|
||||
}, nil
|
||||
}
|
||||
|
||||
@ -48,7 +49,7 @@ func (m *Metrics) GetExporter() http.Handler {
|
||||
}
|
||||
|
||||
func (m *Metrics) GetMetricsProvider() metric.MeterProvider {
|
||||
return sdk_metric.NewMeterProvider(sdk_metric.WithReader(m.Exporter))
|
||||
return m.Provider
|
||||
}
|
||||
|
||||
func (m *Metrics) RegisterCounter(name, description string) error {
|
||||
|
Loading…
x
Reference in New Issue
Block a user