Skip to content

Commit 65fddca

Browse files
committed
graph: Add a boolean gauge to track failure status of deployments
1 parent 96a0cd9 commit 65fddca

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

core/src/subgraph/instance_manager.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -555,6 +555,7 @@ where
555555
}
556556

557557
let start = Instant::now();
558+
let deployment_failed = ctx.block_stream_metrics.deployment_failed.clone();
558559

559560
let res = process_block(
560561
&logger,
@@ -579,6 +580,7 @@ where
579580

580581
ctx.inputs.store.unfail()?;
581582
}
583+
deployment_failed.set(0.0);
582584

583585
if needs_restart {
584586
// Cancel the stream for real
@@ -613,6 +615,7 @@ where
613615
handler: None,
614616
deterministic: e.is_deterministic(),
615617
};
618+
deployment_failed.set(1.0);
616619

617620
store_for_err
618621
.fail_subgraph(error)

graph/src/blockchain/block_stream.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ pub enum BlockStreamEvent<C: Blockchain> {
8484
#[derive(Clone)]
8585
pub struct BlockStreamMetrics {
8686
pub deployment_head: Box<Gauge>,
87+
pub deployment_failed: Box<Gauge>,
8788
pub reverted_blocks: Box<Gauge>,
8889
pub stopwatch: StopwatchMetrics,
8990
}
@@ -107,11 +108,19 @@ impl BlockStreamMetrics {
107108
.new_gauge(
108109
"deployment_head",
109110
"Track the head block number for a deployment",
110-
labels,
111+
labels.clone(),
111112
)
112113
.expect("failed to create `deployment_head` gauge");
114+
let deployment_failed = registry
115+
.new_gauge(
116+
"deployment_failed",
117+
"Boolean gauge to indicate whether the deployment has failed (1 == failed)",
118+
labels,
119+
)
120+
.expect("failed to create `deployment_failed` gauge");
113121
Self {
114122
deployment_head,
123+
deployment_failed,
115124
reverted_blocks,
116125
stopwatch,
117126
}

0 commit comments

Comments
 (0)