Skip to content

Commit

Permalink
Fix registering of kafka read client metrics (grafana#4502)
Browse files Browse the repository at this point in the history
  • Loading branch information
mapno committed Jan 10, 2025
1 parent 6ba89c0 commit 3ae19f8
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion modules/blockbuilder/blockbuilder.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ func (b *BlockBuilder) starting(ctx context.Context) (err error) {

b.kafkaClient, err = ingest.NewReaderClient(
b.cfg.IngestStorageConfig.Kafka,
ingest.NewReaderClientMetrics(blockBuilderServiceName, nil),
ingest.NewReaderClientMetrics(blockBuilderServiceName, prometheus.DefaultRegisterer),
b.logger,
)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion modules/generator/generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ func (g *Generator) starting(ctx context.Context) (err error) {
if g.cfg.Ingest.Enabled {
g.kafkaClient, err = ingest.NewReaderClient(
g.cfg.Ingest.Kafka,
ingest.NewReaderClientMetrics("generator", nil),
ingest.NewReaderClientMetrics("generator", prometheus.DefaultRegisterer),
g.logger,
)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion pkg/ingest/reader_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func NewReaderClient(kafkaCfg KafkaConfig, metrics *kprom.Metrics, logger log.Lo
}

func NewReaderClientMetrics(component string, reg prometheus.Registerer) *kprom.Metrics {
return kprom.NewMetrics("loki_ingest_storage_reader",
return kprom.NewMetrics("tempo_ingest_storage_reader",
kprom.Registerer(prometheus.WrapRegistererWith(prometheus.Labels{"component": component}, reg)),
// Do not export the client ID, because we use it to specify options to the backend.
kprom.FetchAndProduceDetail(kprom.Batches, kprom.Records, kprom.CompressedBytes, kprom.UncompressedBytes))
Expand Down
4 changes: 4 additions & 0 deletions pkg/ingest/writer_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ func NewProducer(client *kgo.Client, maxBufferedBytes int64, reg prometheus.Regi
bufferedProduceBytes: promauto.With(reg).NewSummary(
prometheus.SummaryOpts{
Namespace: "tempo",
Subsystem: "distributor",
Name: "buffered_produce_bytes",
Help: "The buffered produce records in bytes. Quantile buckets keep track of buffered records size over the last 60s.",
Objectives: map[float64]float64{0.5: 0.05, 0.99: 0.001, 1: 0.001},
Expand All @@ -210,16 +211,19 @@ func NewProducer(client *kgo.Client, maxBufferedBytes int64, reg prometheus.Regi
bufferedProduceBytesLimit: promauto.With(reg).NewGauge(
prometheus.GaugeOpts{
Namespace: "tempo",
Subsystem: "distributor",
Name: "buffered_produce_bytes_limit",
Help: "The bytes limit on buffered produce records. Produce requests fail once this limit is reached.",
}),
produceRequestsTotal: promauto.With(reg).NewCounter(prometheus.CounterOpts{
Namespace: "tempo",
Subsystem: "distributor",
Name: "produce_requests_total",
Help: "Total number of produce requests issued to Kafka.",
}),
produceFailuresTotal: promauto.With(reg).NewCounterVec(prometheus.CounterOpts{
Namespace: "tempo",
Subsystem: "distributor",
Name: "produce_failures_total",
Help: "Total number of failed produce requests issued to Kafka.",
}, []string{"reason"}),
Expand Down

0 comments on commit 3ae19f8

Please sign in to comment.