-
Notifications
You must be signed in to change notification settings - Fork 76
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
change placeholder type from identifier to string (#175)
* change placeholder type to string * change from identifier to string type * dont redefine metrics record * skip trunk publish when not a release
- Loading branch information
Showing
5 changed files
with
44 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
-- get metrics for a single queue | ||
CREATE OR REPLACE FUNCTION pgmq.metrics(queue_name TEXT) | ||
RETURNS pgmq.metrics_result AS $$ | ||
DECLARE | ||
result_row pgmq.metrics_result; | ||
query TEXT; | ||
BEGIN | ||
query := FORMAT( | ||
$QUERY$ | ||
WITH q_summary AS ( | ||
SELECT | ||
count(*) as queue_length, | ||
EXTRACT(epoch FROM (NOW() - max(enqueued_at)))::int as newest_msg_age_sec, | ||
EXTRACT(epoch FROM (NOW() - min(enqueued_at)))::int as oldest_msg_age_sec, | ||
NOW() as scrape_time | ||
FROM pgmq.q_%s | ||
), | ||
all_metrics AS ( | ||
SELECT CASE | ||
WHEN is_called THEN last_value ELSE 0 | ||
END as total_messages | ||
FROM pgmq.q_%s_msg_id_seq | ||
) | ||
SELECT | ||
'%s' as queue_name, | ||
q_summary.queue_length, | ||
q_summary.newest_msg_age_sec, | ||
q_summary.oldest_msg_age_sec, | ||
all_metrics.total_messages, | ||
q_summary.scrape_time | ||
FROM q_summary, all_metrics | ||
$QUERY$, | ||
queue_name, queue_name, queue_name | ||
); | ||
EXECUTE query INTO result_row; | ||
RETURN result_row; | ||
END; | ||
$$ LANGUAGE plpgsql; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters