Skip to content

Commit

Permalink
graph, runtime: Track gas used for host exports in dips metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
incrypto32 committed Mar 18, 2024
1 parent 80d41b3 commit da35c2d
Show file tree
Hide file tree
Showing 4 changed files with 346 additions and 146 deletions.
5 changes: 3 additions & 2 deletions graph/src/components/subgraph/instance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ use crate::{
data::{store::Id, subgraph::schema::SubgraphError},
data_source::{DataSourceTemplate, DataSourceTemplateInfo},
prelude::*,
runtime::gas::Gas,
schema::EntityType,
spawn,
};
Expand Down Expand Up @@ -185,11 +186,11 @@ impl BlockStateMetrics {
Ok(())
}

pub fn track_gas_and_ops(&mut self, method: &str, gas_used: u64) {
pub fn track_gas_and_ops(&mut self, gas_used: Gas, method: &str) {
if ENV_VARS.enable_dips_metrics {
let key = CounterKey::from(method);
let counter = self.gas_counter.entry(key.clone()).or_insert(0);
*counter += gas_used;
*counter += gas_used.0;

let counter = self.op_counter.entry(key).or_insert(0);
*counter += 1;
Expand Down
2 changes: 1 addition & 1 deletion graph/src/runtime/gas/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ pub trait GasSizeOf {

/// This wrapper ensures saturating arithmetic is used
#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug, PartialOrd, Ord)]
pub struct Gas(u64);
pub struct Gas(pub u64);

impl Gas {
pub const ZERO: Gas = Gas(0);
Expand Down
Loading

0 comments on commit da35c2d

Please sign in to comment.