Skip to content

Commit f2dc006

Browse files
authored
Add WRITE_RATE_LIMIT_STEP_BYTES_WRITTEN for WriteRateLimitStep (#96)
1 parent a56b641 commit f2dc006

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

aptos-indexer-processors-sdk/sdk/src/common_steps/write_rate_limit_step.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@ use crate::{
33
types::transaction_context::TransactionContext,
44
utils::{
55
errors::ProcessorError,
6-
step_metrics::{StepMetricLabels, WRITE_RATE_LIMIT_STEP_REMAINING_BYTES},
6+
step_metrics::{
7+
StepMetricLabels, WRITE_RATE_LIMIT_STEP_BYTES_WRITTEN,
8+
WRITE_RATE_LIMIT_STEP_REMAINING_BYTES,
9+
},
710
},
811
};
912
use serde::{Deserialize, Serialize};
@@ -134,6 +137,13 @@ where
134137
})
135138
.set(self.current_bucket_size as i64);
136139

140+
// Bump the inverse metric, which is just the bytes written as a counter.
141+
WRITE_RATE_LIMIT_STEP_BYTES_WRITTEN
142+
.get_or_create(&StepMetricLabels {
143+
step_name: self.name(),
144+
})
145+
.inc_by(size_of_item as u64);
146+
137147
Ok(out)
138148
}
139149
}

aptos-indexer-processors-sdk/sdk/src/utils/step_metrics.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,12 @@ pub fn init_step_metrics_registry(registry: &mut Registry) {
108108
"WriteRateLimitStep remaining bytes (aka tokens) that can be written this instant",
109109
WRITE_RATE_LIMIT_STEP_REMAINING_BYTES.clone(),
110110
);
111+
112+
registry.register(
113+
format!("{}_{}", METRICS_PREFIX, "write_rate_limit_bytes_written"),
114+
"WriteRateLimitStep bytes written",
115+
WRITE_RATE_LIMIT_STEP_BYTES_WRITTEN.clone(),
116+
);
111117
}
112118

113119
#[derive(Clone, Debug, Hash, PartialEq, Eq, EncodeLabelSet)]
@@ -165,6 +171,9 @@ pub static POLLING_ERROR_COUNT: Lazy<Family<StepMetricLabels, Counter>> =
165171
pub static WRITE_RATE_LIMIT_STEP_REMAINING_BYTES: Lazy<Family<StepMetricLabels, Gauge>> =
166172
Lazy::new(Family::<StepMetricLabels, Gauge>::default);
167173

174+
pub static WRITE_RATE_LIMIT_STEP_BYTES_WRITTEN: Lazy<Family<StepMetricLabels, Counter>> =
175+
Lazy::new(Family::<StepMetricLabels, Counter>::default);
176+
168177
#[derive(Builder)]
169178
pub struct StepMetrics {
170179
pub labels: StepMetricLabels,

0 commit comments

Comments
 (0)