metrics: sift_batch_* series (jobs, targets, depth, in-flight, durations, bytes)
New internal/metrics/batch.go adds the batch series to metrics.Set, registered in New: BatchJobsTotal and BatchTargetsTotal counters (label "outcome", any value outside the known set folded to "other" so a raw string never becomes a label), BatchQueueDepth and BatchTargetsInflight gauges, BatchJobSeconds and BatchTargetSeconds histograms (the existing request buckets) and BatchResultBytes (1K,4K,16K,64K,256K,1M). The Observe…/Set… methods are nil-receiver safe like ObservePDF and flow through the existing /metrics handler; no new endpoint or Snapshot change. Co-Authored-By: ornith-1.5-35b-a3b <ornith-1.5-35b-a3b@llama.cpp.invalid>
This commit is contained in:
+66
-19
@@ -50,15 +50,22 @@ var pdfOutcomes = map[string]struct{}{
|
||||
|
||||
// Set is a private registry of sift_* series.
|
||||
type Set struct {
|
||||
Reg *prometheus.Registry
|
||||
Requests *prometheus.CounterVec
|
||||
Duration *prometheus.HistogramVec
|
||||
PDFTotal *prometheus.CounterVec
|
||||
PDFSeconds prometheus.Histogram
|
||||
PDFPages prometheus.Counter
|
||||
PDFWait prometheus.Histogram
|
||||
PDFCacheHits prometheus.Counter
|
||||
handler http.Handler
|
||||
Reg *prometheus.Registry
|
||||
Requests *prometheus.CounterVec
|
||||
Duration *prometheus.HistogramVec
|
||||
PDFTotal *prometheus.CounterVec
|
||||
PDFSeconds prometheus.Histogram
|
||||
PDFPages prometheus.Counter
|
||||
PDFWait prometheus.Histogram
|
||||
PDFCacheHits prometheus.Counter
|
||||
BatchJobsTotal *prometheus.CounterVec
|
||||
BatchTargetsTotal *prometheus.CounterVec
|
||||
BatchQueueDepth prometheus.Gauge
|
||||
BatchTargetsInflight prometheus.Gauge
|
||||
BatchJobSeconds prometheus.Histogram
|
||||
BatchTargetSeconds prometheus.Histogram
|
||||
BatchResultBytes prometheus.Histogram
|
||||
handler http.Handler
|
||||
}
|
||||
|
||||
func New(src Source) *Set {
|
||||
@@ -94,17 +101,57 @@ func New(src Source) *Set {
|
||||
Name: "sift_pdf_cache_hits_total",
|
||||
Help: "PDF answers served from the document cache.",
|
||||
})
|
||||
reg.MustRegister(requests, duration, pdfTotal, pdfSeconds, pdfPages, pdfWait, pdfCacheHits, &collector{src: src})
|
||||
batchJobs := prometheus.NewCounterVec(prometheus.CounterOpts{
|
||||
Name: "sift_batch_jobs_total",
|
||||
Help: "Batch jobs by outcome.",
|
||||
}, []string{"outcome"})
|
||||
batchTargets := prometheus.NewCounterVec(prometheus.CounterOpts{
|
||||
Name: "sift_batch_targets_total",
|
||||
Help: "Batch targets by outcome.",
|
||||
}, []string{"outcome"})
|
||||
batchQueueDepth := prometheus.NewGauge(prometheus.GaugeOpts{
|
||||
Name: "sift_batch_queue_depth",
|
||||
Help: "Live batch jobs (queued+running).",
|
||||
})
|
||||
batchTargetsInflight := prometheus.NewGauge(prometheus.GaugeOpts{
|
||||
Name: "sift_batch_targets_inflight",
|
||||
Help: "Batch targets currently being fetched.",
|
||||
})
|
||||
batchJobSeconds := prometheus.NewHistogram(prometheus.HistogramOpts{
|
||||
Name: "sift_batch_job_seconds",
|
||||
Help: "Batch wall time from submit to terminal status.",
|
||||
Buckets: durationBuckets,
|
||||
})
|
||||
batchTargetSeconds := prometheus.NewHistogram(prometheus.HistogramOpts{
|
||||
Name: "sift_batch_target_seconds",
|
||||
Help: "Batch target fetch wall time.",
|
||||
Buckets: durationBuckets,
|
||||
})
|
||||
batchResultBytes := prometheus.NewHistogram(prometheus.HistogramOpts{
|
||||
Name: "sift_batch_result_bytes",
|
||||
Help: "Stored bytes per batch target result.",
|
||||
Buckets: batchResultBytesBuckets,
|
||||
})
|
||||
reg.MustRegister(requests, duration, pdfTotal, pdfSeconds, pdfPages, pdfWait, pdfCacheHits,
|
||||
batchJobs, batchTargets, batchQueueDepth, batchTargetsInflight,
|
||||
batchJobSeconds, batchTargetSeconds, batchResultBytes, &collector{src: src})
|
||||
return &Set{
|
||||
Reg: reg,
|
||||
Requests: requests,
|
||||
Duration: duration,
|
||||
PDFTotal: pdfTotal,
|
||||
PDFSeconds: pdfSeconds,
|
||||
PDFPages: pdfPages,
|
||||
PDFWait: pdfWait,
|
||||
PDFCacheHits: pdfCacheHits,
|
||||
handler: promhttp.HandlerFor(reg, promhttp.HandlerOpts{EnableOpenMetrics: false}),
|
||||
Reg: reg,
|
||||
Requests: requests,
|
||||
Duration: duration,
|
||||
PDFTotal: pdfTotal,
|
||||
PDFSeconds: pdfSeconds,
|
||||
PDFPages: pdfPages,
|
||||
PDFWait: pdfWait,
|
||||
PDFCacheHits: pdfCacheHits,
|
||||
BatchJobsTotal: batchJobs,
|
||||
BatchTargetsTotal: batchTargets,
|
||||
BatchQueueDepth: batchQueueDepth,
|
||||
BatchTargetsInflight: batchTargetsInflight,
|
||||
BatchJobSeconds: batchJobSeconds,
|
||||
BatchTargetSeconds: batchTargetSeconds,
|
||||
BatchResultBytes: batchResultBytes,
|
||||
handler: promhttp.HandlerFor(reg, promhttp.HandlerOpts{EnableOpenMetrics: false}),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user