From 88fdd5432c14e90e37692327b039a66b358620b4 Mon Sep 17 00:00:00 2001 From: hfuss Date: Thu, 5 Dec 2024 11:27:05 -0500 Subject: [PATCH] fix for backwards compatibility Signed-off-by: hfuss --- pkg/ffresty/metrics.go | 1 - pkg/metric/metric.go | 12 +++++++----- 2 files changed, 7 insertions(+), 6 deletions(-) delete mode 100644 pkg/ffresty/metrics.go diff --git a/pkg/ffresty/metrics.go b/pkg/ffresty/metrics.go deleted file mode 100644 index 6857822..0000000 --- a/pkg/ffresty/metrics.go +++ /dev/null @@ -1 +0,0 @@ -package ffresty diff --git a/pkg/metric/metric.go b/pkg/metric/metric.go index 3b20243..2546db6 100644 --- a/pkg/metric/metric.go +++ b/pkg/metric/metric.go @@ -94,7 +94,11 @@ type Options struct { MetricsPrefix string } -func NewPrometheusMetricsRegistry(componentName string /*component name will be added to all metrics as a label*/, opts *Options) MetricsRegistry { +func NewPrometheusMetricsRegistry(componentName string /*component name will be added to all metrics as a label*/) MetricsRegistry { + return NewPrometheusMetricsRegistryWithOptions(componentName, Options{}) +} + +func NewPrometheusMetricsRegistryWithOptions(componentName string /*component name will be added to all metrics as a label*/, opts Options) MetricsRegistry { registry := prometheus.NewRegistry() registerer := prometheus.WrapRegistererWith(prometheus.Labels{compulsoryComponentLabel: componentName}, registry) @@ -103,10 +107,8 @@ func NewPrometheusMetricsRegistry(componentName string /*component name will be registerer.MustRegister(collectors.NewProcessCollector(collectors.ProcessCollectorOpts{})) metricsPrefix := ffMetricsPrefix - if opts != nil { - if opts.MetricsPrefix != "" { - metricsPrefix = opts.MetricsPrefix - } + if opts.MetricsPrefix != "" { + metricsPrefix = opts.MetricsPrefix } return &prometheusMetricsRegistry{