Skip to content

Commit

Permalink
Fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
shantanualsi committed Nov 18, 2024
1 parent 1eb1735 commit 46c03b4
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
24 changes: 23 additions & 1 deletion pkg/pattern/aggregation/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import (
)

type Metrics struct {
reg prometheus.Registerer

chunks *prometheus.GaugeVec
samples *prometheus.CounterVec

Expand All @@ -24,7 +26,10 @@ type Metrics struct {
}

func NewMetrics(r prometheus.Registerer, metricsNamespace string) *Metrics {
return &Metrics{
var m Metrics
m.reg = r

m = Metrics{
chunks: promauto.With(r).NewGaugeVec(prometheus.GaugeOpts{
Namespace: metricsNamespace,
Subsystem: "pattern_ingester",
Expand Down Expand Up @@ -96,4 +101,21 @@ func NewMetrics(r prometheus.Registerer, metricsNamespace string) *Metrics {
Help: "Total number of write timeouts.",
}, []string{"tenant_id"}),
}

if m.reg != nil {
m.reg.MustRegister(
m.chunks,
m.samples,
m.pushErrors,
m.pushRetries,
m.pushSuccesses,
m.payloadSize,
m.streamsPerPush,
m.entriesPerPush,
m.servicesTracked,
m.writeTimeout,
)
}

return &m
}
1 change: 1 addition & 0 deletions pkg/pattern/aggregation/push_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ func Test_Push(t *testing.T) {
quit: make(chan struct{}),
backoff: &backoff,
entries: entries{},
metrics: NewMetrics(nil, ""),
}

lbls1 := labels.New(labels.Label{Name: "test", Value: "test"})
Expand Down

0 comments on commit 46c03b4

Please sign in to comment.