Skip to content

Commit 55cebe4

Browse files
committed
core, graph, store: Label deployment_(head|failed) with the shard
1 parent 65fddca commit 55cebe4

File tree

4 files changed

+19
-1
lines changed

4 files changed

+19
-1
lines changed

core/src/subgraph/instance_manager.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,7 @@ where
362362
registry.clone(),
363363
&deployment.hash,
364364
manifest.network_name(),
365+
store.shard().to_string(),
365366
stopwatch_metrics,
366367
));
367368

graph/src/blockchain/block_stream.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ impl BlockStreamMetrics {
9494
registry: Arc<impl MetricsRegistry>,
9595
deployment_id: &DeploymentHash,
9696
network: String,
97+
shard: String,
9798
stopwatch: StopwatchMetrics,
9899
) -> Self {
99100
let reverted_blocks = registry
@@ -103,7 +104,11 @@ impl BlockStreamMetrics {
103104
deployment_id.as_str(),
104105
)
105106
.expect("Failed to create `deployment_reverted_blocks` gauge");
106-
let labels = labels! { String::from("deployment") => deployment_id.to_string(), String::from("network") => network };
107+
let labels = labels! {
108+
String::from("deployment") => deployment_id.to_string(),
109+
String::from("network") => network,
110+
String::from("shard") => shard
111+
};
107112
let deployment_head = registry
108113
.new_gauge(
109114
"deployment_head",

graph/src/components/store.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1039,6 +1039,10 @@ pub trait WritableStore: Send + Sync + 'static {
10391039

10401040
/// Load the dynamic data sources for the given deployment
10411041
async fn load_dynamic_data_sources(&self) -> Result<Vec<StoredDynamicDataSource>, StoreError>;
1042+
1043+
/// Report the name of the shard in which the subgraph is stored. This
1044+
/// should only be used for reporting and monitoring
1045+
fn shard(&self) -> &str;
10421046
}
10431047

10441048
#[async_trait]
@@ -1211,6 +1215,10 @@ impl WritableStore for MockStore {
12111215
fn deployment_synced(&self) -> Result<(), Error> {
12121216
unimplemented!()
12131217
}
1218+
1219+
fn shard(&self) -> &str {
1220+
unimplemented!()
1221+
}
12141222
}
12151223

12161224
pub trait BlockStore: Send + Sync + 'static {

store/postgres/src/subgraph_store.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1143,6 +1143,10 @@ impl WritableStoreTrait for WritableStore {
11431143

11441144
Ok(self.store.send_store_event(&event)?)
11451145
}
1146+
1147+
fn shard(&self) -> &str {
1148+
self.site.shard.as_str()
1149+
}
11461150
}
11471151

11481152
fn same_subgraph(mods: &Vec<EntityModification>, id: &DeploymentHash) -> bool {

0 commit comments

Comments
 (0)