99
1010 "github.com/Layr-Labs/eigensdk-go/chainio/clients/eth"
1111 sdklogging "github.com/Layr-Labs/eigensdk-go/logging"
12+ rpccalls "github.com/Layr-Labs/eigensdk-go/metrics/collectors/rpc_calls"
1213 sdkutils "github.com/Layr-Labs/eigensdk-go/utils"
14+ "github.com/prometheus/client_golang/prometheus"
1315 "github.com/urfave/cli/v2"
1416)
1517
@@ -27,10 +29,10 @@ type BaseConfig struct {
2729 Logger sdklogging.Logger
2830 EthRpcUrl string
2931 EthWsUrl string
30- EthRpcClient eth.Client
31- EthRpcClientFallback eth.Client
32- EthWsClient eth.Client
33- EthWsClientFallback eth.Client
32+ EthRpcClient eth.InstrumentedClient
33+ EthRpcClientFallback eth.InstrumentedClient
34+ EthWsClient eth.InstrumentedClient
35+ EthWsClientFallback eth.InstrumentedClient
3436 EigenMetricsIpPortAddress string
3537 ChainId * big.Int
3638}
@@ -96,12 +98,15 @@ func NewBaseConfig(configFilePath string) *BaseConfig {
9698 log .Fatal ("Eth ws url or fallback is empty" )
9799 }
98100
99- ethWsClient , err := eth .NewClient (baseConfigFromYaml .EthWsUrl )
101+ reg := prometheus .NewRegistry ()
102+ rpcCallsCollector := rpccalls .NewCollector ("ethWs" , reg )
103+ ethWsClient , err := eth .NewInstrumentedClient (baseConfigFromYaml .EthWsUrl , rpcCallsCollector )
100104 if err != nil {
101105 log .Fatal ("Error initializing eth ws client: " , err )
102106 }
103-
104- ethWsClientFallback , err := eth .NewClient (baseConfigFromYaml .EthWsUrlFallback )
107+ reg = prometheus .NewRegistry ()
108+ rpcCallsCollector = rpccalls .NewCollector ("ethWsFallback" , reg )
109+ ethWsClientFallback , err := eth .NewInstrumentedClient (baseConfigFromYaml .EthWsUrlFallback , rpcCallsCollector )
105110 if err != nil {
106111 log .Fatal ("Error initializing eth ws client fallback: " , err )
107112 }
@@ -110,12 +115,16 @@ func NewBaseConfig(configFilePath string) *BaseConfig {
110115 log .Fatal ("Eth rpc url is empty" )
111116 }
112117
113- ethRpcClient , err := eth .NewClient (baseConfigFromYaml .EthRpcUrl )
118+ reg = prometheus .NewRegistry ()
119+ rpcCallsCollector = rpccalls .NewCollector ("ethRpc" , reg )
120+ ethRpcClient , err := eth .NewInstrumentedClient (baseConfigFromYaml .EthRpcUrl , rpcCallsCollector )
114121 if err != nil {
115122 log .Fatal ("Error initializing eth rpc client: " , err )
116123 }
117124
118- ethRpcClientFallback , err := eth .NewClient (baseConfigFromYaml .EthRpcUrlFallback )
125+ reg = prometheus .NewRegistry ()
126+ rpcCallsCollector = rpccalls .NewCollector ("ethRpc" , reg )
127+ ethRpcClientFallback , err := eth .NewInstrumentedClient (baseConfigFromYaml .EthRpcUrlFallback , rpcCallsCollector )
119128 if err != nil {
120129 log .Fatal ("Error initializing eth rpc client fallback: " , err )
121130 }
@@ -136,10 +145,10 @@ func NewBaseConfig(configFilePath string) *BaseConfig {
136145 Logger : logger ,
137146 EthRpcUrl : baseConfigFromYaml .EthRpcUrl ,
138147 EthWsUrl : baseConfigFromYaml .EthWsUrl ,
139- EthRpcClient : ethRpcClient ,
140- EthRpcClientFallback : ethRpcClientFallback ,
141- EthWsClient : ethWsClient ,
142- EthWsClientFallback : ethWsClientFallback ,
148+ EthRpcClient : * ethRpcClient ,
149+ EthRpcClientFallback : * ethRpcClientFallback ,
150+ EthWsClient : * ethWsClient ,
151+ EthWsClientFallback : * ethWsClientFallback ,
143152 EigenMetricsIpPortAddress : baseConfigFromYaml .EigenMetricsIpPortAddress ,
144153 ChainId : chainId ,
145154 }
0 commit comments