MCPcopy Index your code
hub / github.com/coder/coder / NewMetrics

Function NewMetrics

coderd/agentapi/metadatabatcher/metadata_batcher_metrics.go:17–71  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

15}
16
17func NewMetrics() Metrics {
18 return Metrics{
19 BatchUtilization: prometheus.NewHistogram(prometheus.HistogramOpts{
20 Namespace: "coderd",
21 Subsystem: "agentapi",
22 Name: "metadata_batch_utilization",
23 Help: "Number of metadata keys per agent in each batch, updated before flushes.",
24 Buckets: []float64{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 15, 20, 40, 80, 160},
25 }),
26
27 BatchSize: prometheus.NewHistogram(prometheus.HistogramOpts{
28 Namespace: "coderd",
29 Subsystem: "agentapi",
30 Name: "metadata_batch_size",
31 Help: "Total number of metadata entries in each batch, updated before flushes.",
32 Buckets: []float64{10, 25, 50, 100, 150, 200, 250, 300, 350, 400, 450, 500},
33 }),
34
35 FlushDuration: prometheus.NewHistogramVec(prometheus.HistogramOpts{
36 Namespace: "coderd",
37 Subsystem: "agentapi",
38 Name: "metadata_flush_duration_seconds",
39 Help: "Time taken to flush metadata batch to database and pubsub.",
40 Buckets: []float64{0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1.0, 2.5, 5.0},
41 }, []string{"reason"}),
42
43 BatchesTotal: prometheus.NewCounterVec(prometheus.CounterOpts{
44 Namespace: "coderd",
45 Subsystem: "agentapi",
46 Name: "metadata_batches_total",
47 Help: "Total number of metadata batches flushed.",
48 }, []string{"reason"}),
49
50 DroppedKeysTotal: prometheus.NewCounter(prometheus.CounterOpts{
51 Namespace: "coderd",
52 Subsystem: "agentapi",
53 Name: "metadata_dropped_keys_total",
54 Help: "Total number of metadata keys dropped due to capacity limits.",
55 }),
56
57 MetadataTotal: prometheus.NewCounter(prometheus.CounterOpts{
58 Namespace: "coderd",
59 Subsystem: "agentapi",
60 Name: "metadata_flushed_total",
61 Help: "Total number of unique metadatas flushed.",
62 }),
63
64 PublishErrors: prometheus.NewCounter(prometheus.CounterOpts{
65 Namespace: "coderd",
66 Subsystem: "agentapi",
67 Name: "metadata_publish_errors_total",
68 Help: "Total number of metadata batch pubsub publish calls that have resulted in an error.",
69 }),
70 }
71}
72
73func (m Metrics) Collectors() []prometheus.Collector {
74 return []prometheus.Collector{

Callers 1

NewBatcherFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected