Skip to content

Commit

Permalink
✨ added shouldGroupStatusCode, close #2
Browse files Browse the repository at this point in the history
  • Loading branch information
Julien-R44 committed Dec 19, 2021
1 parent dad0dee commit ff7c224
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
7 changes: 6 additions & 1 deletion src/CollectPerformanceMetrics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,12 @@ export class CollectPerformanceMetrics {
* End HTTP request timer.
*/
if (httpMetricOptions.enabled && stopHttpRequestTimer) {
stopHttpRequestTimer({ statusCode })
let statusCodeStr = statusCode.toString()
if (httpMetricOptions.shouldGroupStatusCode) {
statusCodeStr = statusCodeStr[0] + 'xx'
}

stopHttpRequestTimer({ statusCode: statusCodeStr })
}
}
}
5 changes: 4 additions & 1 deletion templates/prometheus.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export default {
const prometheusConfig {
/*
|--------------------------------------------------------------------------
| Expose prometheus metrics via HTTP endpoint.
Expand Down Expand Up @@ -37,6 +37,7 @@ export default {
name: 'adonis_http_request_durations',
includeQueryParams: false,
includeRouteParams: false,
shouldGroupStatusCode: true,
help: 'Total time each HTTP request takes.',
labelNames: ['method', 'url', 'statusCode'],
buckets: [0.003, 0.03, 0.1, 0.3, 1.5, 10],
Expand Down Expand Up @@ -72,3 +73,5 @@ export default {
prefix: '',
},
}

export default prometheusConfig

0 comments on commit ff7c224

Please sign in to comment.