Skip to content
This repository has been archived by the owner on Mar 9, 2022. It is now read-only.

Add response time and endpoint counters as metrics for Mira #236

Merged
merged 4 commits into from
Feb 6, 2018

Conversation

wennmo
Copy link
Member

@wennmo wennmo commented Feb 5, 2018

This is related to #227.

I have added metrics for measuring response time in milliseconds for all requests to Mira. If a response takes more than MIRA_ALLOWED_RESPONSE_TIME (default 1 second), Mira will log a warning.

Also added counters for all endpoints in Mira.

# HELP mira_api_response_time_ms Time in milliseconds consumed from Mira receiving a request until a response is sent
# TYPE mira_api_response_time_ms summary
mira_api_response_time_ms{quantile="0.01"} 0
mira_api_response_time_ms{quantile="0.05"} 0
mira_api_response_time_ms{quantile="0.5"} 0.7142857142857143
mira_api_response_time_ms{quantile="0.9"} 5
mira_api_response_time_ms{quantile="0.95"} 5.75
mira_api_response_time_ms{quantile="0.99"} 6
mira_api_response_time_ms{quantile="0.999"} 6
mira_api_response_time_ms_sum 15
mira_api_response_time_ms_count 15

# HELP mira_api_engines_request_counter Number of requests to /engines endpoint
# TYPE mira_api_engines_request_counter counter
mira_api_engines_request_counter 8

# HELP mira_api_health_request_counter Number of requests to /health endpoint
# TYPE mira_api_health_request_counter counter
mira_api_health_request_counter 6

# HELP mira_api_metrics_request_counter Number of requests to /metrics endpoint
# TYPE mira_api_metrics_request_counter counter
mira_api_metrics_request_counter 2

Copy link
Contributor

@peol peol left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, good work.

Copy link
Contributor

@FredrikFolkesson FredrikFolkesson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, one minor change if possible

src/Metrics.js Outdated
function recordResponseTimes() {
return function responseTime(ctx, next) {
const requestTime = Date.now();
return next().then(() => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we do this with async await?

@wennmo wennmo merged commit 0159b99 into master Feb 6, 2018
@wennmo wennmo deleted the slo_sli_sla branch February 6, 2018 12:08
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants