Skip to content

Commit

Permalink
ccip-exec: lbtc histogram (#1573)
Browse files Browse the repository at this point in the history
Separate LBTC attestation api latency bucket from USDC
  • Loading branch information
bukata-sa committed Dec 13, 2024
1 parent 0207e5f commit ddc7613
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
)

var (
usdcLatencyBuckets = []float64{
latencyBuckets = []float64{
float64(10 * time.Millisecond),
float64(25 * time.Millisecond),
float64(50 * time.Millisecond),
Expand All @@ -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"})
)

Expand All @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion core/services/ocr2/plugins/ccip/tokendata/lbtc/lbtc.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion core/services/ocr2/plugins/ccip/tokendata/usdc/usdc.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit ddc7613

Please sign in to comment.