-
Notifications
You must be signed in to change notification settings - Fork 387
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: fetch chain-specific metrics in standalone task #3214
Conversation
|
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## main #3214 +/- ##
=========================================
+ Coverage 0 67.65% +67.65%
=========================================
Files 0 99 +99
Lines 0 1014 +1014
Branches 0 106 +106
=========================================
+ Hits 0 686 +686
- Misses 0 284 +284
- Partials 0 44 +44
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you're right that this removes the metrics from the validator and scraper. is there a way to spawn the metric updater task in agent agnostic code?
…to dan/optimize-chain-metrics-fetching
…to dan/optimize-chain-metrics-fetching
### Description Spawning a tokio task to fetch chain-specific metrics in provider middleware was wasteful because we ended up with 15 tasks doing the same job. Now there is a single task that is spawned inside the relayer, which I added in the struct that used to only fetch relayer balance. Some questions: - I'm realising in the current state I'm probably removing these metrics from validators. Lmk if yes and I'll add back - the chain-specific metrics were moved out of `MiddlewareMetrics` because they're no longer part of middleware, but I wasn't sure where to place them. Maybe `CoreMetrics` is a better place than the current `custom_metrics.rs` file? `tokio-metrics` turned out not to be useful because we'd need to instrument every call site of `tokio::spawn` with it. We should still do it but as a separate task imo. ### Drive-by changes - This PR also makes it very easy to add the metrics tasks for new chains, by extending the `HyperlaneProvider` trait with a `get_chain_metrics` call which seems reasonably general to me to have implemented by all providers. (Bc we currently only track these for evm chains) - the description, naming and logic of the `gas_price` metric was also changed to support new chains ### Related issues - Fixes #3047 ### Backward compatibility Yes ### Testing Still need to manually test
…3214) ### Description Spawning a tokio task to fetch chain-specific metrics in provider middleware was wasteful because we ended up with 15 tasks doing the same job. Now there is a single task that is spawned inside the relayer, which I added in the struct that used to only fetch relayer balance. Some questions: - I'm realising in the current state I'm probably removing these metrics from validators. Lmk if yes and I'll add back - the chain-specific metrics were moved out of `MiddlewareMetrics` because they're no longer part of middleware, but I wasn't sure where to place them. Maybe `CoreMetrics` is a better place than the current `custom_metrics.rs` file? `tokio-metrics` turned out not to be useful because we'd need to instrument every call site of `tokio::spawn` with it. We should still do it but as a separate task imo. ### Drive-by changes - This PR also makes it very easy to add the metrics tasks for new chains, by extending the `HyperlaneProvider` trait with a `get_chain_metrics` call which seems reasonably general to me to have implemented by all providers. (Bc we currently only track these for evm chains) - the description, naming and logic of the `gas_price` metric was also changed to support new chains ### Related issues - Fixes hyperlane-xyz#3047 ### Backward compatibility Yes ### Testing Still need to manually test
Description
Spawning a tokio task to fetch chain-specific metrics in provider middleware was wasteful because we ended up with 15 tasks doing the same job. Now there is a single task that is spawned inside the relayer, which I added in the struct that used to only fetch relayer balance.
Some questions:
MiddlewareMetrics
because they're no longer part of middleware, but I wasn't sure where to place them. MaybeCoreMetrics
is a better place than the currentcustom_metrics.rs
file?tokio-metrics
turned out not to be useful because we'd need to instrument every call site oftokio::spawn
with it. We should still do it but as a separate task imo.Drive-by changes
HyperlaneProvider
trait with aget_chain_metrics
call which seems reasonably general to me to have implemented by all providers. (Bc we currently only track these for evm chains)gas_price
metric was also changed to support new chainsRelated issues
Backward compatibility
Yes
Testing
Still need to manually test