Skip to content

Commit

Permalink
refactor(metrics): improve metrics naming and docs
Browse files Browse the repository at this point in the history
  • Loading branch information
gsantos-hc committed Nov 26, 2024
1 parent a095cc4 commit 687121f
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions agent-inject/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const (
metricsSubsystem = "agent_injector"
metricsLabelNamespace = "namespace"
metricsLabelType = "injection_type"
metricsLabelTypeDefault = "default"
metricsLabelTypeBoth = "init_and_sidecar"
metricsLabelTypeInitOnly = "init_only"
metricsLabelTypeSidecarOnly = "sidecar_only"
)
Expand All @@ -21,15 +21,14 @@ var (
requestQueue = prometheus.NewGauge(prometheus.GaugeOpts{
Namespace: metricsNamespace,
Subsystem: metricsSubsystem,
Name: "request_queue_total",
Help: "Total count of webhook requests in the queue",
Name: "request_queue_length",
Help: "Count of webhook requests in the injector's queue",
})

requestProcessingTime = prometheus.NewHistogram(prometheus.HistogramOpts{
Namespace: metricsNamespace,
Subsystem: metricsSubsystem,
Name: "request_processing_duration_ms",
Help: "Histogram of webhook request processing times in milliseconds",
Buckets: []float64{5, 10, 25, 50, 75, 100, 250, 500, 1000, 2500, 5000, 7500, 10000},
})

Expand All @@ -49,8 +48,8 @@ var (
)

func incrementInjections(namespace string, res MutateResponse) {
// Injection type can be one of: default (both initContainer and sidecar); init_only; or sidecar_only
typeLabel := metricsLabelTypeDefault
// Injection type can be one of: init_and_sidecar (default); init_only; or sidecar_only
typeLabel := metricsLabelTypeBoth
if res.InjectedInit && !res.InjectedSidecar {
typeLabel = metricsLabelTypeInitOnly
} else if res.InjectedSidecar && !res.InjectedInit {
Expand Down

0 comments on commit 687121f

Please sign in to comment.