Skip to content

Commit

Permalink
Allowing labels to be passed in rather than metric name prefixes - th…
Browse files Browse the repository at this point in the history
…ese can be configured on the registerer

Signed-off-by: Danny Kopping <[email protected]>
  • Loading branch information
Danny Kopping committed Jun 29, 2022
1 parent d8e9182 commit 59a8c64
Showing 1 changed file with 29 additions and 31 deletions.
60 changes: 29 additions & 31 deletions exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import (
"github.com/prometheus/client_golang/prometheus"
)

const subsystem = "groupcache"

type Exporter struct {
groups []GroupStatistics

Expand Down Expand Up @@ -63,92 +61,92 @@ type GroupStatistics interface {
HotCacheEvictions() int64
}

func NewExporter(namespace string, groups ...GroupStatistics) *Exporter {
func NewExporter(labels map[string]string, groups ...GroupStatistics) *Exporter {
return &Exporter{
groups: groups,
groupGets: prometheus.NewDesc(
prometheus.BuildFQName(namespace, subsystem, "gets_total"),
"gets_total",
"todo",
[]string{"group"},
nil,
labels,
),
groupCacheHits: prometheus.NewDesc(
prometheus.BuildFQName(namespace, subsystem, "hits_total"),
"hits_total",
"todo",
[]string{"group"},
nil,
labels,
),
groupPeerLoads: prometheus.NewDesc(
prometheus.BuildFQName(namespace, subsystem, "peer_loads_total"),
"peer_loads_total",
"todo",
[]string{"group"},
nil,
labels,
),
groupPeerErrors: prometheus.NewDesc(
prometheus.BuildFQName(namespace, subsystem, "peer_errors_total"),
"peer_errors_total",
"todo",
[]string{"group"},
nil,
labels,
),
groupLoads: prometheus.NewDesc(
prometheus.BuildFQName(namespace, subsystem, "loads_total"),
"loads_total",
"todo",
[]string{"group"},
nil,
labels,
),
groupLoadsDeduped: prometheus.NewDesc(
prometheus.BuildFQName(namespace, subsystem, "loads_deduped_total"),
"loads_deduped_total",
"todo",
[]string{"group"},
nil,
labels,
),
groupLocalLoads: prometheus.NewDesc(
prometheus.BuildFQName(namespace, subsystem, "local_load_total"),
"local_load_total",
"todo",
[]string{"group"},
nil,
labels,
),
groupLocalLoadErrs: prometheus.NewDesc(
prometheus.BuildFQName(namespace, subsystem, "local_load_errs_total"),
"local_load_errs_total",
"todo",
[]string{"group"},
nil,
labels,
),
groupServerRequests: prometheus.NewDesc(
prometheus.BuildFQName(namespace, subsystem, "server_requests_total"),
"server_requests_total",
"todo",
[]string{"group"},
nil,
labels,
),
cacheBytes: prometheus.NewDesc(
prometheus.BuildFQName(namespace, subsystem, "cache_bytes"),
"cache_bytes",
"todo",
[]string{"group", "type"},
nil,
labels,
),
cacheItems: prometheus.NewDesc(
prometheus.BuildFQName(namespace, subsystem, "cache_items"),
"cache_items",
"todo",
[]string{"group", "type"},
nil,
labels,
),
cacheGets: prometheus.NewDesc(
prometheus.BuildFQName(namespace, subsystem, "cache_gets_total"),
"cache_gets_total",
"todo",
[]string{"group", "type"},
nil,
labels,
),
cacheHits: prometheus.NewDesc(
prometheus.BuildFQName(namespace, subsystem, "cache_hits_total"),
"cache_hits_total",
"todo",
[]string{"group", "type"},
nil,
labels,
),
cacheEvictions: prometheus.NewDesc(
prometheus.BuildFQName(namespace, subsystem, "cache_evictions_total"),
"cache_evictions_total",
"todo",
[]string{"group", "type"},
nil,
labels,
),
}
}
Expand Down

0 comments on commit 59a8c64

Please sign in to comment.