From f15cb8b37b9b70056bc82a8eb7151f75fad27a71 Mon Sep 17 00:00:00 2001 From: Cody Rose Date: Wed, 5 Nov 2025 09:24:37 -0500 Subject: [PATCH] Add source type label to chunk size metric (#4543) We're tracking chunk size - but not by source type, which means we can't use the metric to locate potential chunking anomalies by source type. It's really easy to add a source type label, so I did. --- pkg/engine/engine.go | 2 +- pkg/engine/metrics.go | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/pkg/engine/engine.go b/pkg/engine/engine.go index f5de6cb3b..ffc69e91b 100644 --- a/pkg/engine/engine.go +++ b/pkg/engine/engine.go @@ -832,7 +832,7 @@ func (e *Engine) scannerWorker(ctx context.Context) { dataSize := float64(len(chunk.Data)) - scanBytesPerChunk.Observe(dataSize) + scanBytesPerChunk.WithLabelValues(chunk.SourceType.String()).Observe(dataSize) jobBytesScanned.WithLabelValues( chunk.SourceType.String(), chunk.SourceName, diff --git a/pkg/engine/metrics.go b/pkg/engine/metrics.go index 8cded174c..212061ca9 100644 --- a/pkg/engine/metrics.go +++ b/pkg/engine/metrics.go @@ -55,13 +55,15 @@ var ( []string{"source_type", "source_name"}, ) - scanBytesPerChunk = promauto.NewHistogram(prometheus.HistogramOpts{ + scanBytesPerChunk = promauto.NewHistogramVec(prometheus.HistogramOpts{ Namespace: common.MetricsNamespace, Subsystem: common.MetricsSubsystem, Name: "scan_bytes_per_chunk", Help: "Total number of bytes in a chunk.", Buckets: prometheus.ExponentialBuckets(1, 2, 18), - }) + }, + []string{"source_type"}, + ) jobChunksScanned = promauto.NewCounterVec(prometheus.CounterOpts{ Namespace: common.MetricsNamespace,