From 5f977ad584409f66cde6b173a95dfa883d6d751d Mon Sep 17 00:00:00 2001 From: Cem Mergenci Date: Tue, 26 Mar 2024 20:21:57 +0300 Subject: [PATCH] Add external API calls metric. Signed-off-by: Cem Mergenci --- pkg/metrics/metrics.go | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/pkg/metrics/metrics.go b/pkg/metrics/metrics.go index 762c80b6..bed904b7 100644 --- a/pkg/metrics/metrics.go +++ b/pkg/metrics/metrics.go @@ -44,6 +44,20 @@ var ( Buckets: []float64{1, 5, 10, 15, 30, 60, 120, 300, 600, 1800, 3600}, }, []string{"operation"}) + // ExternalAPICalls is a counter metric of the number of external + // API calls. "service" and "operation" labels could be used to + // classify calls into a two-level hierarchy, in which calls are + // "operations" that belong to a "service". Users should beware of + // performance implications of high cardinality that could occur + // when there are many services and operations. See: + // https://prometheus.io/docs/practices/naming/#labels + ExternalAPICalls = prometheus.NewCounterVec(prometheus.CounterOpts{ + Namespace: promNSUpjet, + Subsystem: promSysResource, + Name: "external_api_calls_total", + Help: "The number of external API calls.", + }, []string{"service", "operation"}) + // DeletionTime is the histogram metric for collecting statistics on the // intervals between the deletion timestamp and the moment when // the resource is observed to be missing (actually deleted). @@ -174,5 +188,5 @@ func (r *MetricRecorder) Start(ctx context.Context) error { } func init() { - metrics.Registry.MustRegister(CLITime, CLIExecutions, TFProcesses, TTRMeasurements, ExternalAPITime, DeletionTime, ReconcileDelay) + metrics.Registry.MustRegister(CLITime, CLIExecutions, TFProcesses, TTRMeasurements, ExternalAPITime, ExternalAPICalls, DeletionTime, ReconcileDelay) }