mirror of
https://github.com/unpoller/unpoller.git
synced 2026-09-29 19:11:17 +02:00
fix(otelunifi): callback memory leak
This commit is contained in:
+3
-14
@@ -207,14 +207,14 @@ func (u *OtelOutput) exportDevices(ctx context.Context, meter metric.Meter, m *p
|
|||||||
|
|
||||||
// recordGauge is a helper that records a single float64 gauge observation.
|
// recordGauge is a helper that records a single float64 gauge observation.
|
||||||
func (u *OtelOutput) recordGauge(
|
func (u *OtelOutput) recordGauge(
|
||||||
_ context.Context,
|
ctx context.Context,
|
||||||
meter metric.Meter,
|
meter metric.Meter,
|
||||||
r *Report,
|
r *Report,
|
||||||
name, description string,
|
name, description string,
|
||||||
value float64,
|
value float64,
|
||||||
attrs attribute.Set,
|
attrs attribute.Set,
|
||||||
) {
|
) {
|
||||||
g, err := meter.Float64ObservableGauge(name, metric.WithDescription(description))
|
g, err := meter.Float64Gauge(name, metric.WithDescription(description))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
r.Errors++
|
r.Errors++
|
||||||
|
|
||||||
@@ -223,18 +223,7 @@ func (u *OtelOutput) recordGauge(
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err = meter.RegisterCallback(func(_ context.Context, o metric.Observer) error {
|
g.Record(ctx, value, metric.WithAttributeSet(attrs))
|
||||||
o.ObserveFloat64(g, value, metric.WithAttributeSet(attrs))
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}, g)
|
|
||||||
if err != nil {
|
|
||||||
r.Errors++
|
|
||||||
|
|
||||||
u.LogDebugf("otel: registering callback for %s: %v", name, err)
|
|
||||||
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
r.Total++
|
r.Total++
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user