Skip to content
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

refactor metrics summary #120

Closed
ChuckHend opened this issue Sep 21, 2023 · 0 comments · Fixed by #159
Closed

refactor metrics summary #120

ChuckHend opened this issue Sep 21, 2023 · 0 comments · Fixed by #159
Labels
enhancement New feature or request

Comments

@ChuckHend
Copy link
Member

Metrics summary currently executes a query for every queue in pgmq.meta. Look into optimizing that - likely able to make 1-2 queries in total.

pgmq/src/metrics.rs

Lines 38 to 60 in 0fad4dc

#[pg_extern(name = "metrics_all")]
fn pgmq_metrics_all() -> Result<
TableIterator<
'static,
(
name!(queue_name, String),
name!(queue_length, i64),
name!(newest_msg_age_sec, Option<i32>),
name!(oldest_msg_age_sec, Option<i32>),
name!(total_messages, i64),
name!(scrape_time, TimestampWithTimeZone),
),
>,
crate::PgmqExtError,
> {
let all_queueus = listit()?;
let mut results: MetricResult = Vec::new();
for q in all_queueus {
let q_results = query_summary(&q.0)?;
results.extend(q_results);
}
Ok(TableIterator::new(results))
}

@ChuckHend ChuckHend added the enhancement New feature or request label Sep 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant