From a8cc68960854b6df13360ebd48469fd5432afb54 Mon Sep 17 00:00:00 2001 From: itsdevbear Date: Wed, 6 Dec 2023 14:46:12 -0500 Subject: [PATCH] rename --- telemetry/metrics.go | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/telemetry/metrics.go b/telemetry/metrics.go index e6d51fa2aa6..f551250a308 100644 --- a/telemetry/metrics.go +++ b/telemetry/metrics.go @@ -25,6 +25,11 @@ const ( FormatText = "text" ) +// DisplayableSink is an interface that defines a method for displaying metrics. +type DisplayableSink interface { + DisplayMetrics(resp http.ResponseWriter, req *http.Request) (interface{}, error) +} + // Config defines the configuration options for application telemetry. type Config struct { // Prefixed with keys to separate services @@ -73,7 +78,7 @@ type Config struct { // by the operator. In addition to the sinks, when a process gets a SIGUSR1, a // dump of formatted recent metrics will be sent to STDERR. type Metrics struct { - memSink metrics.MetricSink + sink metrics.MetricSink prometheusEnabled bool } @@ -127,7 +132,7 @@ func New(cfg Config) (_ *Metrics, rerr error) { } } - m := &Metrics{memSink: sink} + m := &Metrics{sink: sink} fanout := metrics.FanoutSink{sink} if cfg.PrometheusRetentionTime > 0 { @@ -151,10 +156,6 @@ func New(cfg Config) (_ *Metrics, rerr error) { return m, nil } -type DisplayableMetrics interface { - DisplayMetrics(resp http.ResponseWriter, req *http.Request) (interface{}, error) -} - // Gather collects all registered metrics and returns a GatherResponse where the // metrics are encoded depending on the type. Metrics are either encoded via // Prometheus or JSON if in-memory. @@ -198,7 +199,7 @@ func (m *Metrics) gatherPrometheus() (GatherResponse, error) { } func (m *Metrics) gatherGeneric() (GatherResponse, error) { - gm, ok := m.memSink.(DisplayableMetrics) + gm, ok := m.sink.(DisplayableSink) if !ok { return GatherResponse{}, fmt.Errorf("non in-memory metrics sink does not support generic format") }