fix(otelunifi): callback memory leak

This commit is contained in:
Jonathan Delgado
2026-09-17 13:44:48 -07:00
parent 58d01430ef
commit 160b46d616
+3 -14
View File
@@ -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++
} }