Skip to content
This repository has been archived by the owner on Apr 2, 2024. It is now read-only.

Commit

Permalink
Add histogram to track number samples/metadata/span sent per request
Browse files Browse the repository at this point in the history
This commit also removes the metric promscale_ingest_items_received_total
which is not used anywhere and the same information can be now obtained
using the newly introduced `promscale_ingest_items_received_*` histogram metric.

Signed-off-by: Arunprasad Rajkumar <ar.arunprasad@gmail.com>
  • Loading branch information
arajkumar committed Nov 29, 2022
1 parent ac1cf99 commit d028f46
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
4 changes: 2 additions & 2 deletions pkg/api/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ type Metrics struct {
func updateIngestMetrics(code string, duration, receivedSamples, receivedMetadata float64) {
pgMetrics.IngestorRequests.With(prometheus.Labels{"type": "metric", "code": code}).Inc()
pgMetrics.IngestorDuration.With(prometheus.Labels{"type": "metric", "code": code}).Observe(duration)
pgMetrics.IngestorItemsReceived.With(prometheus.Labels{"type": "metric", "kind": "sample"}).Add(receivedSamples)
pgMetrics.IngestorItemsReceived.With(prometheus.Labels{"type": "metric", "kind": "metadata"}).Add(receivedMetadata)
pgMetrics.IngestorItemsReceived.With(prometheus.Labels{"type": "metric", "kind": "sample"}).Observe(receivedSamples)
pgMetrics.IngestorItemsReceived.With(prometheus.Labels{"type": "metric", "kind": "metadata"}).Observe(receivedMetadata)
}

func updateQueryMetrics(handler, code string, duration float64) {
Expand Down
2 changes: 1 addition & 1 deletion pkg/pgmodel/ingestor/trace/writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ func (t *traceWriterImpl) InsertTraces(ctx context.Context, traces ptrace.Traces
startIngest := time.Now() // Time taken for complete ingestion => Processing + DB insert.
code := "500"
metrics.IngestorActiveWriteRequests.With(traceSpanLabel).Inc()
metrics.IngestorItemsReceived.With(traceSpanLabel).Add(float64(traces.SpanCount()))
metrics.IngestorItemsReceived.With(traceSpanLabel).Observe(float64(traces.SpanCount()))
defer func() {
metrics.IngestorDuration.With(prometheus.Labels{"type": "trace", "code": code}).Observe(time.Since(startIngest).Seconds())
metrics.IngestorActiveWriteRequests.With(traceSpanLabel).Dec()
Expand Down
12 changes: 7 additions & 5 deletions pkg/pgmodel/metrics/ingest.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,13 +141,15 @@ var (
Help: "Total number of items (sample/metadata/span) ingested",
}, []string{"type", "kind", "subsystem"},
)
IngestorItemsReceived = prometheus.NewCounterVec(
prometheus.CounterOpts{
IngestorItemsReceived = prometheus.NewHistogramVec(
prometheus.HistogramOpts{
Namespace: util.PromNamespace,
Subsystem: "ingest",
Name: "items_received_total",
Help: "Total items (samples/exemplars/spans) received.",
}, []string{"type", "kind"},
Name: "items_received",
Help: "Number of (samples/exemplars/spans) received",
Buckets: []float64{10, 50, 100, 200, 500, 1000, 2000, 4000, 6000, 8000, 10000, 20000, 30000},
},
[]string{"type", "kind"},
)
IngestorBytes = prometheus.NewCounterVec(
prometheus.CounterOpts{
Expand Down

0 comments on commit d028f46

Please # to comment.