Skip to content
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

Remove MetricsRegistryTrait and use just struct MetricsRegistry #4470

Merged
merged 1 commit into from
Mar 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions chain/arweave/src/chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ use graph::blockchain::{
EmptyNodeCapabilities, NoopRuntimeAdapter,
};
use graph::cheap_clone::CheapClone;
use graph::components::metrics::MetricsRegistryTrait;
use graph::components::store::DeploymentCursorTracker;
use graph::data::subgraph::UnifiedMappingApiVersion;
use graph::firehose::FirehoseEndpoint;
use graph::prelude::MetricsRegistry;
use graph::{
blockchain::{
block_stream::{
Expand Down Expand Up @@ -40,7 +40,7 @@ pub struct Chain {
name: String,
client: Arc<ChainClient<Self>>,
chain_store: Arc<dyn ChainStore>,
metrics_registry: Arc<dyn MetricsRegistryTrait>,
metrics_registry: Arc<MetricsRegistry>,
}

impl std::fmt::Debug for Chain {
Expand Down
4 changes: 2 additions & 2 deletions chain/cosmos/src/chain.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use graph::blockchain::firehose_block_ingestor::FirehoseBlockIngestor;
use graph::blockchain::BlockIngestor;
use graph::components::metrics::MetricsRegistryTrait;
use graph::prelude::MetricsRegistry;
use std::sync::Arc;

use graph::blockchain::block_stream::FirehoseCursor;
Expand Down Expand Up @@ -36,7 +36,7 @@ pub struct Chain {
name: String,
client: Arc<ChainClient<Self>>,
chain_store: Arc<dyn ChainStore>,
metrics_registry: Arc<dyn MetricsRegistryTrait>,
metrics_registry: Arc<MetricsRegistry>,
}

impl std::fmt::Debug for Chain {
Expand Down
5 changes: 2 additions & 3 deletions chain/ethereum/src/adapter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use anyhow::Error;
use ethabi::{Error as ABIError, Function, ParamType, Token};
use futures::Future;
use graph::blockchain::ChainIdentifier;
use graph::components::metrics::MetricsRegistryTrait;
use graph::firehose::CallToFilter;
use graph::firehose::CombinedFilter;
use graph::firehose::LogFilter;
Expand Down Expand Up @@ -732,7 +731,7 @@ pub struct ProviderEthRpcMetrics {
}

impl ProviderEthRpcMetrics {
pub fn new(registry: Arc<dyn MetricsRegistryTrait>) -> Self {
pub fn new(registry: Arc<MetricsRegistry>) -> Self {
let request_duration = registry
.new_histogram_vec(
"eth_rpc_request_duration",
Expand Down Expand Up @@ -788,7 +787,7 @@ pub struct SubgraphEthRpcMetrics {
}

impl SubgraphEthRpcMetrics {
pub fn new(registry: Arc<dyn MetricsRegistryTrait>, subgraph_hash: &str) -> Self {
pub fn new(registry: Arc<MetricsRegistry>, subgraph_hash: &str) -> Self {
let request_duration = registry
.global_gauge_vec(
"deployment_eth_rpc_request_duration",
Expand Down
11 changes: 5 additions & 6 deletions chain/ethereum/src/chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@ use anyhow::{Context, Error};
use graph::blockchain::client::ChainClient;
use graph::blockchain::firehose_block_ingestor::{FirehoseBlockIngestor, Transforms};
use graph::blockchain::{BlockIngestor, BlockchainKind, TriggersAdapterSelector};
use graph::components::metrics::MetricsRegistryTrait;
use graph::components::store::DeploymentCursorTracker;
use graph::data::subgraph::UnifiedMappingApiVersion;
use graph::firehose::{FirehoseEndpoint, ForkStep};
use graph::prelude::{
BlockHash, ComponentLoggerConfig, ElasticComponentLoggerConfig, EthereumBlock,
EthereumCallCache, LightEthereumBlock, LightEthereumBlockExt,
EthereumCallCache, LightEthereumBlock, LightEthereumBlockExt, MetricsRegistry,
};
use graph::{
blockchain::{
Expand Down Expand Up @@ -192,15 +191,15 @@ impl BlockRefetcher<Chain> for EthereumBlockRefetcher {
pub struct EthereumAdapterSelector {
logger_factory: LoggerFactory,
client: Arc<ChainClient<Chain>>,
registry: Arc<dyn MetricsRegistryTrait>,
registry: Arc<MetricsRegistry>,
chain_store: Arc<dyn ChainStore>,
}

impl EthereumAdapterSelector {
pub fn new(
logger_factory: LoggerFactory,
client: Arc<ChainClient<Chain>>,
registry: Arc<dyn MetricsRegistryTrait>,
registry: Arc<MetricsRegistry>,
chain_store: Arc<dyn ChainStore>,
) -> Self {
Self {
Expand Down Expand Up @@ -242,7 +241,7 @@ pub struct Chain {
logger_factory: LoggerFactory,
name: String,
node_id: NodeId,
registry: Arc<dyn MetricsRegistryTrait>,
registry: Arc<MetricsRegistry>,
client: Arc<ChainClient<Self>>,
chain_store: Arc<dyn ChainStore>,
call_cache: Arc<dyn EthereumCallCache>,
Expand All @@ -268,7 +267,7 @@ impl Chain {
logger_factory: LoggerFactory,
name: String,
node_id: NodeId,
registry: Arc<dyn MetricsRegistryTrait>,
registry: Arc<MetricsRegistry>,
chain_store: Arc<dyn ChainStore>,
call_cache: Arc<dyn EthereumCallCache>,
client: Arc<ChainClient<Self>>,
Expand Down
13 changes: 5 additions & 8 deletions chain/ethereum/src/network.rs
Original file line number Diff line number Diff line change
Expand Up @@ -219,10 +219,7 @@ impl EthereumNetworks {

#[cfg(test)]
mod tests {
use graph::{
components::metrics::MetricsRegistryTrait, firehose::SubgraphLimit,
prelude::MetricsRegistry, tokio, url::Url,
};
use graph::{firehose::SubgraphLimit, prelude::MetricsRegistry, tokio, url::Url};
use http::HeaderMap;
use std::sync::Arc;

Expand Down Expand Up @@ -289,7 +286,7 @@ mod tests {
async fn adapter_selector_selects_eth_call() {
let chain = "mainnet".to_string();
let logger = graph::log::logger(true);
let mock_registry: Arc<dyn MetricsRegistryTrait> = Arc::new(MetricsRegistry::mock());
let mock_registry: Arc<MetricsRegistry> = Arc::new(MetricsRegistry::mock());
let transport =
Transport::new_rpc(Url::parse("http://127.0.0.1").unwrap(), HeaderMap::new());
let provider_metrics = Arc::new(ProviderEthRpcMetrics::new(mock_registry.clone()));
Expand Down Expand Up @@ -392,7 +389,7 @@ mod tests {
async fn adapter_selector_unlimited() {
let chain = "mainnet".to_string();
let logger = graph::log::logger(true);
let mock_registry: Arc<dyn MetricsRegistryTrait> = Arc::new(MetricsRegistry::mock());
let mock_registry: Arc<MetricsRegistry> = Arc::new(MetricsRegistry::mock());
let transport =
Transport::new_rpc(Url::parse("http://127.0.0.1").unwrap(), HeaderMap::new());
let provider_metrics = Arc::new(ProviderEthRpcMetrics::new(mock_registry.clone()));
Expand Down Expand Up @@ -460,7 +457,7 @@ mod tests {
async fn adapter_selector_disable_call_only_fallback() {
let chain = "mainnet".to_string();
let logger = graph::log::logger(true);
let mock_registry: Arc<dyn MetricsRegistryTrait> = Arc::new(MetricsRegistry::mock());
let mock_registry: Arc<MetricsRegistry> = Arc::new(MetricsRegistry::mock());
let transport =
Transport::new_rpc(Url::parse("http://127.0.0.1").unwrap(), HeaderMap::new());
let provider_metrics = Arc::new(ProviderEthRpcMetrics::new(mock_registry.clone()));
Expand Down Expand Up @@ -526,7 +523,7 @@ mod tests {
async fn adapter_selector_no_call_only_fallback() {
let chain = "mainnet".to_string();
let logger = graph::log::logger(true);
let mock_registry: Arc<dyn MetricsRegistryTrait> = Arc::new(MetricsRegistry::mock());
let mock_registry: Arc<MetricsRegistry> = Arc::new(MetricsRegistry::mock());
let transport =
Transport::new_rpc(Url::parse("http://127.0.0.1").unwrap(), HeaderMap::new());
let provider_metrics = Arc::new(ProviderEthRpcMetrics::new(mock_registry.clone()));
Expand Down
5 changes: 2 additions & 3 deletions chain/near/src/chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@ use graph::blockchain::{
BasicBlockchainBuilder, BlockIngestor, BlockchainBuilder, BlockchainKind, NoopRuntimeAdapter,
};
use graph::cheap_clone::CheapClone;
use graph::components::metrics::MetricsRegistryTrait;
use graph::components::store::DeploymentCursorTracker;
use graph::data::subgraph::UnifiedMappingApiVersion;
use graph::firehose::FirehoseEndpoint;
use graph::prelude::TryFutureExt;
use graph::prelude::{MetricsRegistry, TryFutureExt};
use graph::{
anyhow::Result,
blockchain::{
Expand Down Expand Up @@ -98,7 +97,7 @@ pub struct Chain {
name: String,
client: Arc<ChainClient<Self>>,
chain_store: Arc<dyn ChainStore>,
metrics_registry: Arc<dyn MetricsRegistryTrait>,
metrics_registry: Arc<MetricsRegistry>,
block_stream_builder: Arc<dyn BlockStreamBuilder<Self>>,
}

Expand Down
7 changes: 3 additions & 4 deletions chain/substreams/src/chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@ use crate::{data_source::*, EntityChanges, TriggerData, TriggerFilter, TriggersA
use anyhow::Error;
use graph::blockchain::client::ChainClient;
use graph::blockchain::{BlockIngestor, EmptyNodeCapabilities, NoopRuntimeAdapter};
use graph::components::metrics::MetricsRegistryTrait;
use graph::components::store::DeploymentCursorTracker;
use graph::firehose::FirehoseEndpoints;
use graph::prelude::{BlockHash, LoggerFactory};
use graph::prelude::{BlockHash, LoggerFactory, MetricsRegistry};
use graph::{
blockchain::{
self,
Expand Down Expand Up @@ -45,14 +44,14 @@ pub struct Chain {

pub(crate) logger_factory: LoggerFactory,
pub(crate) client: Arc<ChainClient<Self>>,
pub(crate) metrics_registry: Arc<dyn MetricsRegistryTrait>,
pub(crate) metrics_registry: Arc<MetricsRegistry>,
}

impl Chain {
pub fn new(
logger_factory: LoggerFactory,
firehose_endpoints: FirehoseEndpoints,
metrics_registry: Arc<dyn MetricsRegistryTrait>,
metrics_registry: Arc<MetricsRegistry>,
chain_store: Arc<dyn ChainStore>,
block_stream_builder: Arc<dyn BlockStreamBuilder<Self>>,
) -> Self {
Expand Down
5 changes: 2 additions & 3 deletions core/src/polling_monitor/metrics.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
use std::sync::Arc;

use graph::{
components::metrics::MetricsRegistryTrait,
prelude::DeploymentHash,
prelude::{DeploymentHash, MetricsRegistry},
prometheus::{Counter, Gauge},
};

Expand All @@ -14,7 +13,7 @@ pub struct PollingMonitorMetrics {
}

impl PollingMonitorMetrics {
pub fn new(registry: Arc<dyn MetricsRegistryTrait>, subgraph_hash: &DeploymentHash) -> Self {
pub fn new(registry: Arc<MetricsRegistry>, subgraph_hash: &DeploymentHash) -> Self {
let requests = registry
.new_deployment_counter(
"polling_monitor_requests",
Expand Down
7 changes: 3 additions & 4 deletions core/src/subgraph/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,14 @@ use bytes::Bytes;
use graph::{
blockchain::Blockchain,
components::{
metrics::MetricsRegistryTrait,
store::{DeploymentId, SubgraphFork},
subgraph::{MappingError, SharedProofOfIndexing},
},
data_source::{offchain, CausalityRegion, DataSource, TriggerData},
ipfs_client::CidFile,
prelude::{
BlockNumber, BlockState, CancelGuard, CheapClone, DeploymentHash, RuntimeHostBuilder,
SubgraphCountMetric, SubgraphInstanceMetrics, TriggerProcessor,
BlockNumber, BlockState, CancelGuard, CheapClone, DeploymentHash, MetricsRegistry,
RuntimeHostBuilder, SubgraphCountMetric, SubgraphInstanceMetrics, TriggerProcessor,
},
slog::Logger,
tokio::sync::mpsc,
Expand Down Expand Up @@ -192,7 +191,7 @@ pub struct OffchainMonitor {
impl OffchainMonitor {
pub fn new(
logger: Logger,
registry: Arc<dyn MetricsRegistryTrait>,
registry: Arc<MetricsRegistry>,
subgraph_hash: &DeploymentHash,
ipfs_service: IpfsService,
) -> Self {
Expand Down
5 changes: 2 additions & 3 deletions core/src/subgraph/instance_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ use graph::blockchain::block_stream::BlockStreamMetrics;
use graph::blockchain::Blockchain;
use graph::blockchain::NodeCapabilities;
use graph::blockchain::{BlockchainKind, TriggerFilter};
use graph::components::metrics::MetricsRegistryTrait;
use graph::components::subgraph::ProofOfIndexingVersion;
use graph::data::subgraph::{UnresolvedSubgraphManifest, SPEC_VERSION_0_0_6};
use graph::data_source::causality_region::CausalityRegionSeq;
Expand All @@ -27,7 +26,7 @@ pub struct SubgraphInstanceManager<S: SubgraphStore> {
logger_factory: LoggerFactory,
subgraph_store: Arc<S>,
chains: Arc<BlockchainMap>,
metrics_registry: Arc<dyn MetricsRegistryTrait>,
metrics_registry: Arc<MetricsRegistry>,
instances: SubgraphKeepAlive,
link_resolver: Arc<dyn LinkResolver>,
ipfs_service: IpfsService,
Expand Down Expand Up @@ -163,7 +162,7 @@ impl<S: SubgraphStore> SubgraphInstanceManager<S> {
subgraph_store: Arc<S>,
chains: Arc<BlockchainMap>,
sg_metrics: Arc<SubgraphCountMetric>,
metrics_registry: Arc<dyn MetricsRegistryTrait>,
metrics_registry: Arc<MetricsRegistry>,
link_resolver: Arc<dyn LinkResolver>,
ipfs_service: IpfsService,
static_filters: bool,
Expand Down
3 changes: 1 addition & 2 deletions graph/src/blockchain/block_stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ use tokio::sync::mpsc::{self, Receiver, Sender};

use super::{Block, BlockPtr, Blockchain};
use crate::anyhow::Result;
use crate::components::metrics::MetricsRegistryTrait;
use crate::components::store::{BlockNumber, DeploymentLocator};
use crate::data::subgraph::UnifiedMappingApiVersion;
use crate::firehose::{self, FirehoseEndpoint};
Expand Down Expand Up @@ -387,7 +386,7 @@ pub struct BlockStreamMetrics {

impl BlockStreamMetrics {
pub fn new(
registry: Arc<dyn MetricsRegistryTrait>,
registry: Arc<MetricsRegistry>,
deployment_id: &DeploymentHash,
network: String,
shard: String,
Expand Down
7 changes: 3 additions & 4 deletions graph/src/blockchain/builder.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
use super::Blockchain;
use crate::{
components::{metrics::MetricsRegistryTrait, store::ChainStore},
firehose::FirehoseEndpoints,
prelude::LoggerFactory,
components::store::ChainStore, firehose::FirehoseEndpoints, prelude::LoggerFactory,
prelude::MetricsRegistry,
};
use std::sync::Arc;

Expand All @@ -13,7 +12,7 @@ pub struct BasicBlockchainBuilder {
pub name: String,
pub chain_store: Arc<dyn ChainStore>,
pub firehose_endpoints: FirehoseEndpoints,
pub metrics_registry: Arc<dyn MetricsRegistryTrait>,
pub metrics_registry: Arc<MetricsRegistry>,
}

/// Something that can build a [`Blockchain`].
Expand Down
5 changes: 2 additions & 3 deletions graph/src/blockchain/firehose_block_stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ use super::client::ChainClient;
use super::{Blockchain, TriggersAdapter};
use crate::blockchain::block_stream::FirehoseCursor;
use crate::blockchain::TriggerFilter;
use crate::components::metrics::MetricsRegistryTrait;
use crate::prelude::*;
use crate::util::backoff::ExponentialBackoff;
use crate::{firehose, firehose::FirehoseEndpoint};
Expand All @@ -23,7 +22,7 @@ struct FirehoseBlockStreamMetrics {
}

impl FirehoseBlockStreamMetrics {
pub fn new(registry: Arc<dyn MetricsRegistryTrait>, deployment: DeploymentHash) -> Self {
pub fn new(registry: Arc<MetricsRegistry>, deployment: DeploymentHash) -> Self {
Self {
deployment,

Expand Down Expand Up @@ -116,7 +115,7 @@ where
filter: Arc<C::TriggerFilter>,
start_blocks: Vec<BlockNumber>,
logger: Logger,
registry: Arc<dyn MetricsRegistryTrait>,
registry: Arc<MetricsRegistry>,
) -> Self
where
F: FirehoseMapper<C> + 'static,
Expand Down
5 changes: 2 additions & 3 deletions graph/src/blockchain/substreams_block_stream.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use super::block_stream::SubstreamsMapper;
use crate::blockchain::block_stream::{BlockStream, BlockStreamEvent};
use crate::blockchain::Blockchain;
use crate::components::metrics::MetricsRegistryTrait;
use crate::firehose::FirehoseEndpoint;
use crate::prelude::*;
use crate::substreams::response::Message;
Expand All @@ -26,7 +25,7 @@ struct SubstreamsBlockStreamMetrics {

impl SubstreamsBlockStreamMetrics {
pub fn new(
registry: Arc<dyn MetricsRegistryTrait>,
registry: Arc<MetricsRegistry>,
deployment: DeploymentHash,
provider: String,
) -> Self {
Expand Down Expand Up @@ -126,7 +125,7 @@ where
start_blocks: Vec<BlockNumber>,
end_blocks: Vec<BlockNumber>,
logger: Logger,
registry: Arc<dyn MetricsRegistryTrait>,
registry: Arc<MetricsRegistry>,
) -> Self
where
F: SubstreamsMapper<C> + 'static,
Expand Down
Loading