Skip to content

Commit 56db982

Browse files
mangasneysofu
authored andcommitted
add stopwatch (#3970)
1 parent a538b9e commit 56db982

File tree

3 files changed

+22
-9
lines changed

3 files changed

+22
-9
lines changed

core/src/subgraph/instance_manager.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,7 @@ impl<S: SubgraphStore> SubgraphInstanceManager<S> {
285285
let subgraph_metrics = Arc::new(SubgraphInstanceMetrics::new(
286286
registry.cheap_clone(),
287287
deployment.hash.as_str(),
288+
stopwatch_metrics.clone(),
288289
));
289290
let subgraph_metrics_unregister = subgraph_metrics.clone();
290291
let host_metrics = Arc::new(HostMetrics::new(

core/src/subgraph/trigger_processor.rs

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,16 +35,20 @@ where
3535

3636
let mut host_mapping: Vec<(&T::Host, TriggerWithHandler<MappingTrigger<C>>)> = vec![];
3737

38-
for host in hosts {
39-
let mapping_trigger = match host.match_and_decode(trigger, block, logger)? {
40-
// Trigger matches and was decoded as a mapping trigger.
41-
Some(mapping_trigger) => mapping_trigger,
38+
{
39+
let _section = subgraph_metrics.stopwatch.start_section("match_and_decode");
4240

43-
// Trigger does not match, do not process it.
44-
None => continue,
45-
};
41+
for host in hosts {
42+
let mapping_trigger = match host.match_and_decode(trigger, block, logger)? {
43+
// Trigger matches and was decoded as a mapping trigger.
44+
Some(mapping_trigger) => mapping_trigger,
4645

47-
host_mapping.push((&host, mapping_trigger));
46+
// Trigger does not match, do not process it.
47+
None => continue,
48+
};
49+
50+
host_mapping.push((&host, mapping_trigger));
51+
}
4852
}
4953

5054
if host_mapping.is_empty() {

graph/src/components/metrics/subgraph.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,23 @@ use crate::prelude::{Gauge, Histogram, HostMetrics, MetricsRegistry};
33
use std::collections::HashMap;
44
use std::sync::Arc;
55

6+
use super::stopwatch::StopwatchMetrics;
7+
68
pub struct SubgraphInstanceMetrics {
79
pub block_trigger_count: Box<Histogram>,
810
pub block_processing_duration: Box<Histogram>,
911
pub block_ops_transaction_duration: Box<Histogram>,
1012

13+
pub stopwatch: StopwatchMetrics,
1114
trigger_processing_duration: Box<Histogram>,
1215
}
1316

1417
impl SubgraphInstanceMetrics {
15-
pub fn new(registry: Arc<dyn MetricsRegistry>, subgraph_hash: &str) -> Self {
18+
pub fn new(
19+
registry: Arc<dyn MetricsRegistry>,
20+
subgraph_hash: &str,
21+
stopwatch: StopwatchMetrics,
22+
) -> Self {
1623
let block_trigger_count = registry
1724
.new_deployment_histogram(
1825
"deployment_block_trigger_count",
@@ -51,6 +58,7 @@ impl SubgraphInstanceMetrics {
5158
block_processing_duration,
5259
trigger_processing_duration,
5360
block_ops_transaction_duration,
61+
stopwatch,
5462
}
5563
}
5664

0 commit comments

Comments
 (0)