mirror of
https://gitlab.com/soapbox-pub/ditto.git
synced 2025-12-06 11:29:46 +00:00
metrics: track response method
This commit is contained in:
parent
1e8aeee5a6
commit
f730771d72
2 changed files with 2 additions and 2 deletions
|
|
@ -9,7 +9,7 @@ export const httpRequestCounter = new Counter({
|
||||||
export const httpResponseCounter = new Counter({
|
export const httpResponseCounter = new Counter({
|
||||||
name: 'http_responses_total',
|
name: 'http_responses_total',
|
||||||
help: 'Total number of HTTP responses',
|
help: 'Total number of HTTP responses',
|
||||||
labelNames: ['status', 'path'],
|
labelNames: ['method', 'path', 'status'],
|
||||||
});
|
});
|
||||||
|
|
||||||
export const streamingConnectionsGauge = new Gauge({
|
export const streamingConnectionsGauge = new Gauge({
|
||||||
|
|
|
||||||
|
|
@ -16,5 +16,5 @@ export const metricsMiddleware: MiddlewareHandler = async (c, next) => {
|
||||||
// Get a parameterized path name like `/posts/:id` instead of `/posts/1234`.
|
// Get a parameterized path name like `/posts/:id` instead of `/posts/1234`.
|
||||||
// Tries to find actual route names first before falling back on potential middleware handlers like `app.use('*')`.
|
// Tries to find actual route names first before falling back on potential middleware handlers like `app.use('*')`.
|
||||||
const path = c.req.matchedRoutes.find((r) => r.method !== 'ALL')?.path ?? c.req.routePath;
|
const path = c.req.matchedRoutes.find((r) => r.method !== 'ALL')?.path ?? c.req.routePath;
|
||||||
httpResponseCounter.inc({ status, path });
|
httpResponseCounter.inc({ method, status, path });
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue