diff --git a/pkg/metrics/metrics.go b/pkg/metrics/metrics.go index 20ac7da..141cf38 100644 --- a/pkg/metrics/metrics.go +++ b/pkg/metrics/metrics.go @@ -13,38 +13,40 @@ func init() { m = kybermetric.Meter() } -func RecordFloat64Histogram(ctx context.Context, name string, value float64) error { +func RecordFloat64Histogram(ctx context.Context, name string, value float64, options ...metric.RecordOption) error { hist, err := m.Float64Histogram(name) if err != nil { return err } - hist.Record(ctx, value) + hist.Record(ctx, value, options...) return nil } -func RecordFloat64Gause(ctx context.Context, name string, value float64) error { - _, err := m.Float64ObservableGauge(name, - metric.WithFloat64Callback(func(ctx context.Context, fo metric.Float64Observer) error { - fo.Observe(value) - return nil - })) - return err -} - -func RecordCounter(ctx context.Context, name string, value int64) error { +func RecordCounter(ctx context.Context, name string, value int64, options ...metric.AddOption) error { counter, err := m.Int64Counter(name) if err != nil { return err } - counter.Add(ctx, value) + counter.Add(ctx, value, options...) return nil } -func RecordUpdownCounter(ctx context.Context, name string, value int64) error { +func RecordUpdownCounter(ctx context.Context, name string, value int64, options ...metric.AddOption) error { counter, err := m.Int64UpDownCounter(name) if err != nil { return err } - counter.Add(ctx, value) + counter.Add(ctx, value, options...) + return nil +} + +func RecordInt64HistogramWithMetricOption(ctx context.Context, name string, value int64, + options ...metric.Int64HistogramOption, +) error { + hist, err := m.Int64Histogram(name, options...) + if err != nil { + return err + } + hist.Record(ctx, value) return nil }