Back to all reviewers

Standardize metrics collection

kubeflow/kubeflow
Based on 2 comments
Go

Use the appropriate metric types for the data being collected and consider centralizing monitoring code to ensure consistency across components. For accumulating values like request counts, use counters rather than gauges:

Observability Go

Reviewer Prompt

Use the appropriate metric types for the data being collected and consider centralizing monitoring code to ensure consistency across components.

For accumulating values like request counts, use counters rather than gauges:

// CORRECT: Request counts should use counter metrics
requestCounter = prometheus.NewCounterVec(
    prometheus.CounterOpts{
        Name: "request_counter",
        Help: "Number of request_counter",
    },
    []string{COMPONENT, KIND, NAMESPACE, ACTION, SEVERITY},
)

// INCORRECT: Don't use gauges for request counts
// requestGauge = prometheus.NewGaugeVec(...)

To promote consistency, consider extracting common monitoring patterns into a shared library when multiple components need similar metrics. This ensures standardized naming conventions, label sets, and metric types across your application. Standard label keys (like component, namespace, severity) should be defined once and shared to prevent duplication and inconsistency.

2
Comments Analyzed
Go
Primary Language
Observability
Category

Source Discussions