datasource/ethereum: Create block streams with subgraph names
This improves logging significantly, since we can easily tell which
log message belongs to which subgraph stream.
@@ -92,6 +92,7 @@ struct BlockStreamContext<S, C, E> {
subgraph_store: Arc<S>,
chain_store: Arc<C>,
eth_adapter: Arc<E>,
+ subgraph_name: String,
subgraph_id: String,
logger: Logger,
}
@@ -102,6 +103,7 @@ impl<S, C, E> Clone for BlockStreamContext<S, C, E> {
subgraph_store: self.subgraph_store.clone(),
chain_store: self.chain_store.clone(),
eth_adapter: self.eth_adapter.clone(),
+ subgraph_name: self.subgraph_name.clone(),
subgraph_id: self.subgraph_id.clone(),
logger: self.logger.clone(),
}
@@ -126,11 +128,16 @@ where
subgraph_store: Arc<S>,
chain_store: Arc<C>,
eth_adapter: Arc<E>,
+ subgraph_name: String,
subgraph_id: String,
log_filter: EthereumLogFilter,
logger: Logger,
) -> Self {
- let logger = logger.new(o!("component" => "BlockStream"));
+ let logger = logger.new(o!(
+ "component" => "BlockStream",
+ "subgraph_name" => format!("{}", subgraph_name),
+ "subgraph_id" => format!("{}", subgraph_id),
+ ));
let (chain_head_update_sink, chain_head_update_stream) = channel(100);
@@ -143,6 +150,7 @@ where
subgraph_store,
chain_store,
eth_adapter,
+ subgraph_name,
subgraph_id,
logger,
},
@@ -747,7 +755,12 @@ where
{
type Stream = BlockStream<S, C, E>;
- fn from_subgraph(&self, manifest: &SubgraphManifest, logger: Logger) -> Self::Stream {
+ fn from_subgraph(
+ &self,
+ name: String,
+ manifest: &SubgraphManifest,
+ logger: Logger,
+ ) -> Self::Stream {
// Add entry to subgraphs table in Store
let genesis_block_ptr = self.chain_store.genesis_block_ptr().unwrap();
self.subgraph_store
@@ -763,6 +776,7 @@ where
self.subgraph_store.clone(),
self.chain_store.clone(),
self.eth_adapter.clone(),
+ name,
manifest.id.clone(),
log_filter,
logger,
