Skip to content

Commit

Permalink
rename
Browse files Browse the repository at this point in the history
  • Loading branch information
itsdevbear committed Dec 6, 2023
1 parent da47c25 commit a8cc689
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions telemetry/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
}

Expand Down Expand Up @@ -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 {
Expand All @@ -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.
Expand Down Expand Up @@ -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")
}
Expand Down

0 comments on commit a8cc689

Please sign in to comment.