-
Notifications
You must be signed in to change notification settings - Fork 21
feat: add metrics for intent execution time #607
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
70980e4
b4a5e17
f1c0b82
93d9814
446627a
193711e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -5,7 +5,8 @@ use prometheus::{ | |||||||||||
| Histogram, HistogramOpts, HistogramVec, IntCounter, IntCounterVec, | ||||||||||||
| IntGauge, IntGaugeVec, Opts, Registry, | ||||||||||||
| }; | ||||||||||||
| pub use types::{AccountClone, AccountCommit, Outcome}; | ||||||||||||
| pub use types::{AccountClone, AccountCommit, LabelValue, Outcome}; | ||||||||||||
|
|
||||||||||||
| mod types; | ||||||||||||
|
|
||||||||||||
| // ----------------- | ||||||||||||
|
|
@@ -181,13 +182,32 @@ lazy_static::lazy_static! { | |||||||||||
| "committor_intent_backlog_count", "Number of intents in backlog", | ||||||||||||
| ).unwrap(); | ||||||||||||
|
|
||||||||||||
| static ref COMMITTOR_FAILED_INTENTS_COUNT: IntCounter = IntCounter::new( | ||||||||||||
| "committor_failed_intents_count", "Number of failed to be executed intents", | ||||||||||||
| static ref COMMITTOR_FAILED_INTENTS_COUNT: IntCounterVec = IntCounterVec::new( | ||||||||||||
| Opts::new("committor_failed_intents_count", "Number of failed to be executed intents"), | ||||||||||||
| &["intent_kind", "error_kind"] | ||||||||||||
| ).unwrap(); | ||||||||||||
|
|
||||||||||||
| static ref COMMITTOR_EXECUTORS_BUSY_COUNT: IntGauge = IntGauge::new( | ||||||||||||
| "committor_executors_busy_count", "Number of busy intent executors" | ||||||||||||
| ).unwrap(); | ||||||||||||
|
|
||||||||||||
| static ref COMMITTOR_INTENT_EXECUTION_TIME_HISTOGRAM: HistogramVec = HistogramVec::new( | ||||||||||||
| HistogramOpts::new( | ||||||||||||
| "committor_intent_execution_time_histogram", | ||||||||||||
| "Time in seconds spent on intent execution" | ||||||||||||
| ) | ||||||||||||
| .buckets( | ||||||||||||
| MILLIS_1_9.iter() | ||||||||||||
| .chain(MILLIS_10_90.iter()) | ||||||||||||
| .chain(MILLIS_100_900.iter()) | ||||||||||||
| .chain(SECONDS_1_9.iter()).cloned().collect(), | ||||||||||||
| ), | ||||||||||||
| &["intent_kind", "outcome_kind"], | ||||||||||||
| ).unwrap(); | ||||||||||||
|
Comment on lines
+194
to
+206
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧹 Nitpick | 🔵 Trivial Consider adding microsecond buckets for sub-millisecond executions. The histogram starts at 1ms buckets, which may not capture fast-executing intents that complete in microseconds. If intent execution can be faster than 1ms, consider adding If you're unsure whether intents can execute in sub-millisecond time, you could:
🤖 Prompt for AI Agents |
||||||||||||
|
|
||||||||||||
| static ref COMMITTOR_INTENT_CU_USAGE: IntGauge = IntGauge::new( | ||||||||||||
| "committor_intent_cu_usage", "Compute units used for Intent" | ||||||||||||
| ).unwrap(); | ||||||||||||
| } | ||||||||||||
|
|
||||||||||||
| pub(crate) fn register() { | ||||||||||||
|
|
@@ -223,6 +243,7 @@ pub(crate) fn register() { | |||||||||||
| register!(COMMITTOR_INTENTS_BACKLOG_COUNT); | ||||||||||||
| register!(COMMITTOR_FAILED_INTENTS_COUNT); | ||||||||||||
| register!(COMMITTOR_EXECUTORS_BUSY_COUNT); | ||||||||||||
| register!(COMMITTOR_INTENT_EXECUTION_TIME_HISTOGRAM); | ||||||||||||
| register!(ENSURE_ACCOUNTS_TIME); | ||||||||||||
|
Comment on lines
244
to
247
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Register the CU usage gauge.
register!(COMMITTOR_FAILED_INTENTS_COUNT);
register!(COMMITTOR_EXECUTORS_BUSY_COUNT);
+ register!(COMMITTOR_INTENT_CU_USAGE);
register!(COMMITTOR_INTENT_EXECUTION_TIME_HISTOGRAM);🤖 Prompt for AI Agents |
||||||||||||
| register!(RPC_REQUEST_HANDLING_TIME); | ||||||||||||
| register!(TRANSACTION_PROCESSING_TIME); | ||||||||||||
|
|
@@ -318,10 +339,29 @@ pub fn set_committor_intents_backlog_count(value: i64) { | |||||||||||
| COMMITTOR_INTENTS_BACKLOG_COUNT.set(value) | ||||||||||||
| } | ||||||||||||
|
|
||||||||||||
| pub fn inc_committor_failed_intents_count() { | ||||||||||||
| COMMITTOR_FAILED_INTENTS_COUNT.inc() | ||||||||||||
| pub fn inc_committor_failed_intents_count( | ||||||||||||
| intent_kind: &impl LabelValue, | ||||||||||||
| error_kind: &impl LabelValue, | ||||||||||||
| ) { | ||||||||||||
| COMMITTOR_FAILED_INTENTS_COUNT | ||||||||||||
| .with_label_values(&[intent_kind.value(), error_kind.value()]) | ||||||||||||
| .inc() | ||||||||||||
| } | ||||||||||||
|
|
||||||||||||
| pub fn set_committor_executors_busy_count(value: i64) { | ||||||||||||
| COMMITTOR_EXECUTORS_BUSY_COUNT.set(value) | ||||||||||||
| } | ||||||||||||
|
|
||||||||||||
| pub fn observe_committor_intent_execution_time_histogram( | ||||||||||||
| seconds: f64, | ||||||||||||
| kind: &impl LabelValue, | ||||||||||||
| outcome: &impl LabelValue, | ||||||||||||
| ) { | ||||||||||||
| COMMITTOR_INTENT_EXECUTION_TIME_HISTOGRAM | ||||||||||||
| .with_label_values(&[kind.value(), outcome.value()]) | ||||||||||||
| .observe(seconds); | ||||||||||||
| } | ||||||||||||
|
|
||||||||||||
| pub fn set_commmittor_intent_cu_usage(value: i64) { | ||||||||||||
| COMMITTOR_INTENT_CU_USAGE.set(value) | ||||||||||||
|
Comment on lines
+365
to
+366
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion | 🟠 Major Fix the typo in the public setter. The new API is exposed as -pub fn set_commmittor_intent_cu_usage(value: i64) {
+pub fn set_committor_intent_cu_usage(value: i64) {
COMMITTOR_INTENT_CU_USAGE.set(value)
}📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||
| } | ||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧹 Nitpick | 🔵 Trivial
LGTM: Timing instrumentation properly integrated.
The execution timing is correctly captured with
Instant::now()before the async operation and metrics collection occurs after execution completes. The metrics are collected before result mapping, which correctly preserves the original error types for labeling.Minor observation: Line 254 changed error logging from
{:?}(Debug) to{}(Display). This simplifies the log output but may reduce detail if the error's Display implementation is less verbose than Debug.🤖 Prompt for AI Agents