Skip to content

Commit 4c67d8e

Browse files
authored
Merge pull request crossplane#385 from mergenci/external-api-calls-metric
Add external API calls metric
2 parents 50919fe + 5f977ad commit 4c67d8e

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

pkg/metrics/metrics.go

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,20 @@ var (
4444
Buckets: []float64{1, 5, 10, 15, 30, 60, 120, 300, 600, 1800, 3600},
4545
}, []string{"operation"})
4646

47+
// ExternalAPICalls is a counter metric of the number of external
48+
// API calls. "service" and "operation" labels could be used to
49+
// classify calls into a two-level hierarchy, in which calls are
50+
// "operations" that belong to a "service". Users should beware of
51+
// performance implications of high cardinality that could occur
52+
// when there are many services and operations. See:
53+
// https://prometheus.io/docs/practices/naming/#labels
54+
ExternalAPICalls = prometheus.NewCounterVec(prometheus.CounterOpts{
55+
Namespace: promNSUpjet,
56+
Subsystem: promSysResource,
57+
Name: "external_api_calls_total",
58+
Help: "The number of external API calls.",
59+
}, []string{"service", "operation"})
60+
4761
// DeletionTime is the histogram metric for collecting statistics on the
4862
// intervals between the deletion timestamp and the moment when
4963
// the resource is observed to be missing (actually deleted).
@@ -174,5 +188,5 @@ func (r *MetricRecorder) Start(ctx context.Context) error {
174188
}
175189

176190
func init() {
177-
metrics.Registry.MustRegister(CLITime, CLIExecutions, TFProcesses, TTRMeasurements, ExternalAPITime, DeletionTime, ReconcileDelay)
191+
metrics.Registry.MustRegister(CLITime, CLIExecutions, TFProcesses, TTRMeasurements, ExternalAPITime, ExternalAPICalls, DeletionTime, ReconcileDelay)
178192
}

0 commit comments

Comments
 (0)