From 6f4779da009207636b16d5cd542351397611c7f1 Mon Sep 17 00:00:00 2001 From: Kristina Pathak Date: Wed, 21 Jun 2023 17:08:39 -0700 Subject: [PATCH] apply MeasurementProcessor --- .../sdk/metric/internal/syncstate/sync.go | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/lightstep/sdk/metric/internal/syncstate/sync.go b/lightstep/sdk/metric/internal/syncstate/sync.go index 40b5fedd..3e518ac4 100644 --- a/lightstep/sdk/metric/internal/syncstate/sync.go +++ b/lightstep/sdk/metric/internal/syncstate/sync.go @@ -327,7 +327,7 @@ func (inst *Observer) ObserveFloat64(ctx context.Context, num float64, cfg OpCon } // Observe performs a generic update for any synchronous instrument. -func Observe[N number.Any, Traits number.Traits[N]](_ context.Context, inst *Observer, num N, cfg OpConfig) { +func Observe[N number.Any, Traits number.Traits[N]](ctx context.Context, inst *Observer, num N, cfg OpConfig) { if inst == nil { // Instrument was completely disabled by the view. return @@ -339,19 +339,19 @@ func Observe[N number.Any, Traits number.Traits[N]](_ context.Context, inst *Obs return } - // TODO: Here, apply the measurement processor if it is non-nil - if inst.performance.MeasurementProcessor != nil { - - } - - var rec *recordKV + var keyValues []attribute.KeyValue if cfg.KeyValues != nil { - rec = acquireUninitializedKV[N](inst, cfg.KeyValues) + keyValues = cfg.KeyValues } else { // TODO: This is a new code path for optimization, // for now fall back to the slow path. - rec = acquireUninitializedKV[N](inst, cfg.Attributes.ToSlice()) + keyValues = cfg.Attributes.ToSlice() + } + + if inst.performance.MeasurementProcessor != nil { + keyValues = inst.performance.MeasurementProcessor.Process(ctx, keyValues) } + rec := acquireUninitializedKV[N](inst, keyValues) defer rec.refMapped.unref()