mirror of
https://github.com/imgproxy/imgproxy.git
synced 2025-01-03 10:43:58 +02:00
Fix OTel metrics
This commit is contained in:
parent
ea82ec730b
commit
6f6f27d6a9
@ -408,19 +408,22 @@ func AddGaugeFunc(name, desc, u string, f GaugeFunc) {
|
||||
return
|
||||
}
|
||||
|
||||
gauge, _ := meter.AsyncFloat64().Gauge(
|
||||
gauge, err := meter.Float64ObservableGauge(
|
||||
name,
|
||||
instrument.WithUnit(unit.Unit(u)),
|
||||
instrument.WithDescription(desc),
|
||||
)
|
||||
if err != nil {
|
||||
logrus.Warnf("Can't add %s gauge to OpenTelemetry: %s", name, err)
|
||||
return
|
||||
}
|
||||
|
||||
if err := meter.RegisterCallback(
|
||||
[]instrument.Asynchronous{
|
||||
gauge,
|
||||
},
|
||||
func(ctx context.Context) {
|
||||
gauge.Observe(ctx, f())
|
||||
if _, err = meter.RegisterCallback(
|
||||
func(ctx context.Context, o metric.Observer) error {
|
||||
o.ObserveFloat64(gauge, f())
|
||||
return nil
|
||||
},
|
||||
gauge,
|
||||
); err != nil {
|
||||
logrus.Warnf("Can't add %s gauge to OpenTelemetry: %s", name, err)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user