Skip to content

Commit

Permalink
graph: Change env variable name for gas metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
incrypto32 committed Mar 14, 2024
1 parent ebbfe8e commit 4e35efd
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
17 changes: 12 additions & 5 deletions graph/src/env/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -188,9 +188,9 @@ pub struct EnvVars {
pub subgraph_settings: Option<String>,
/// Whether to prefer substreams blocks streams over firehose when available.
pub prefer_substreams_block_streams: bool,
/// Set by the flag `GRAPH_ENABLE_GAS_METRICS`. Whether to enable
/// Set by the flag `GRAPH_ENABLE_DIPS_METRICS`. Whether to enable
/// gas metrics. Off by default.
pub enable_gas_metrics: bool,
pub enable_dips_metrics: bool,
/// Set by the env var `GRAPH_HISTORY_BLOCKS_OVERRIDE`. Defaults to None
/// Sets an override for the amount history to keep regardless of the
/// historyBlocks set in the manifest
Expand All @@ -199,6 +199,10 @@ pub struct EnvVars {
/// The amount of history to keep when using 'min' historyBlocks
/// in the manifest
pub min_history_blocks: BlockNumber,

/// Set by the env var `dips_metrics_object_store_url`
/// The name of the object store bucket to store DIPS metrics
pub dips_metrics_object_store_url: Option<String>,
}

impl EnvVars {
Expand Down Expand Up @@ -263,11 +267,12 @@ impl EnvVars {
ingestor_polling_interval: Duration::from_millis(inner.ingestor_polling_interval),
subgraph_settings: inner.subgraph_settings,
prefer_substreams_block_streams: inner.prefer_substreams_block_streams,
enable_gas_metrics: inner.enable_gas_metrics.0,
enable_dips_metrics: inner.enable_dips_metrics.0,
history_blocks_override: inner.history_blocks_override,
min_history_blocks: inner
.min_history_blocks
.unwrap_or(2 * inner.reorg_threshold),
dips_metrics_object_store_url: inner.dips_metrics_object_store_url,
})
}

Expand Down Expand Up @@ -399,12 +404,14 @@ struct Inner {
default = "false"
)]
prefer_substreams_block_streams: bool,
#[envconfig(from = "GRAPH_ENABLE_GAS_METRICS", default = "false")]
enable_gas_metrics: EnvVarBoolean,
#[envconfig(from = "GRAPH_ENABLE_DIPS_METRICS", default = "false")]
enable_dips_metrics: EnvVarBoolean,
#[envconfig(from = "GRAPH_HISTORY_BLOCKS_OVERRIDE")]
history_blocks_override: Option<BlockNumber>,
#[envconfig(from = "GRAPH_MIN_HISTORY_BLOCKS")]
min_history_blocks: Option<BlockNumber>,
#[envconfig(from = "GRAPH_DIPS_METRICS_OBJECT_STORE_URL")]
dips_metrics_object_store_url: Option<String>,
}

#[derive(Clone, Debug)]
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 @@ -101,7 +101,7 @@ impl GasCounter {
amount += costs::HOST_EXPORT_GAS;

// If gas metrics are enabled, track the gas used
if ENV_VARS.enable_gas_metrics {
if ENV_VARS.enable_dips_metrics {
if let Some(method) = method {
self.metrics.track_gas(method, amount.0);
self.metrics.track_operations(method, 1);
Expand Down

0 comments on commit 4e35efd

Please sign in to comment.