From 8d974b4d689bb1972ed99eef04a6df47cfc1f1c9 Mon Sep 17 00:00:00 2001 From: Aleksandr Bukata <96521086+bukata-sa@users.noreply.github.com> Date: Fri, 13 Dec 2024 17:32:11 +0000 Subject: [PATCH] ccip-exec: lbtc histogram (#1573) Separate LBTC attestation api latency bucket from USDC --- .../tokendata/http/observed_http_client.go | 18 ++++++++++++++---- .../ocr2/plugins/ccip/tokendata/lbtc/lbtc.go | 2 +- .../ocr2/plugins/ccip/tokendata/usdc/usdc.go | 2 +- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/core/services/ocr2/plugins/ccip/tokendata/http/observed_http_client.go b/core/services/ocr2/plugins/ccip/tokendata/http/observed_http_client.go index d8fb9b1c57..bac36abf7e 100644 --- a/core/services/ocr2/plugins/ccip/tokendata/http/observed_http_client.go +++ b/core/services/ocr2/plugins/ccip/tokendata/http/observed_http_client.go @@ -11,7 +11,7 @@ import ( ) var ( - usdcLatencyBuckets = []float64{ + latencyBuckets = []float64{ float64(10 * time.Millisecond), float64(25 * time.Millisecond), float64(50 * time.Millisecond), @@ -29,7 +29,12 @@ var ( usdcClientHistogram = promauto.NewHistogramVec(prometheus.HistogramOpts{ Name: "ccip_usdc_client_request_total", Help: "Latency of calls to the USDC client", - Buckets: usdcLatencyBuckets, + Buckets: latencyBuckets, + }, []string{"status", "success"}) + lbtcClientHistogram = promauto.NewHistogramVec(prometheus.HistogramOpts{ + Name: "ccip_lbtc_client_request_total", + Help: "Latency of calls to the LBTC client", + Buckets: latencyBuckets, }, []string{"status", "success"}) ) @@ -38,11 +43,16 @@ type ObservedIHttpClient struct { histogram *prometheus.HistogramVec } -// NewObservedIHttpClient Create a new ObservedIHttpClient with the USDC client metric. -func NewObservedIHttpClient(origin IHttpClient) *ObservedIHttpClient { +// NewObservedUsdcIHttpClient Create a new ObservedIHttpClient with the USDC client metric. +func NewObservedUsdcIHttpClient(origin IHttpClient) *ObservedIHttpClient { return NewObservedIHttpClientWithMetric(origin, usdcClientHistogram) } +// NewObservedLbtcIHttpClient Create a new ObservedIHttpClient with the LBTC client metric. +func NewObservedLbtcIHttpClient(origin IHttpClient) *ObservedIHttpClient { + return NewObservedIHttpClientWithMetric(origin, lbtcClientHistogram) +} + func NewObservedIHttpClientWithMetric(origin IHttpClient, histogram *prometheus.HistogramVec) *ObservedIHttpClient { return &ObservedIHttpClient{ IHttpClient: origin, diff --git a/core/services/ocr2/plugins/ccip/tokendata/lbtc/lbtc.go b/core/services/ocr2/plugins/ccip/tokendata/lbtc/lbtc.go index 94df0c76ad..86d3c71e62 100644 --- a/core/services/ocr2/plugins/ccip/tokendata/lbtc/lbtc.go +++ b/core/services/ocr2/plugins/ccip/tokendata/lbtc/lbtc.go @@ -135,7 +135,7 @@ func NewLBTCTokenDataReader( return &TokenDataReader{ lggr: lggr, - httpClient: http.NewObservedIHttpClient(&http.HttpClient{}), + httpClient: http.NewObservedLbtcIHttpClient(&http.HttpClient{}), attestationApi: lbtcAttestationApi, attestationApiTimeout: timeout, lbtcTokenAddress: lbtcTokenAddress, diff --git a/core/services/ocr2/plugins/ccip/tokendata/usdc/usdc.go b/core/services/ocr2/plugins/ccip/tokendata/usdc/usdc.go index fe3a86d2af..89bb17e844 100644 --- a/core/services/ocr2/plugins/ccip/tokendata/usdc/usdc.go +++ b/core/services/ocr2/plugins/ccip/tokendata/usdc/usdc.go @@ -133,7 +133,7 @@ func NewUSDCTokenDataReader( return &TokenDataReader{ lggr: lggr, usdcReader: usdcReader, - httpClient: http.NewObservedIHttpClient(&http.HttpClient{}), + httpClient: http.NewObservedUsdcIHttpClient(&http.HttpClient{}), attestationApi: usdcAttestationApi, attestationApiTimeout: timeout, usdcTokenAddress: usdcTokenAddress,