mirror of
https://github.com/zitadel/zitadel.git
synced 2025-01-08 18:37:39 +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 {
|
type Metrics struct {
|
||||||
Exporter *prometheus.Exporter
|
Provider metric.MeterProvider
|
||||||
Meter metric.Meter
|
Meter metric.Meter
|
||||||
Counters sync.Map
|
Counters sync.Map
|
||||||
UpDownSumObserver sync.Map
|
UpDownSumObserver sync.Map
|
||||||
@ -34,12 +34,13 @@ func NewMetrics(meterName string) (metrics.Metrics, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return &Metrics{}, err
|
return &Metrics{}, err
|
||||||
}
|
}
|
||||||
return &Metrics{
|
meterProvider := sdk_metric.NewMeterProvider(
|
||||||
Exporter: exporter,
|
|
||||||
Meter: sdk_metric.NewMeterProvider(
|
|
||||||
sdk_metric.WithReader(exporter),
|
sdk_metric.WithReader(exporter),
|
||||||
sdk_metric.WithResource(resource),
|
sdk_metric.WithResource(resource),
|
||||||
).Meter(meterName),
|
)
|
||||||
|
return &Metrics{
|
||||||
|
Provider: meterProvider,
|
||||||
|
Meter: meterProvider.Meter(meterName),
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -48,7 +49,7 @@ func (m *Metrics) GetExporter() http.Handler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (m *Metrics) GetMetricsProvider() metric.MeterProvider {
|
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 {
|
func (m *Metrics) RegisterCounter(name, description string) error {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user