mirror of
https://github.com/aljazceru/ditto.git
synced 2025-12-18 14:04:23 +01:00
metrics: remove path from fetch and request metrics
This commit is contained in:
@@ -3,13 +3,13 @@ import { Counter } from 'prom-client';
|
|||||||
export const httpRequestCounter = new Counter({
|
export const httpRequestCounter = new Counter({
|
||||||
name: 'http_requests_total',
|
name: 'http_requests_total',
|
||||||
help: 'Total number of HTTP requests',
|
help: 'Total number of HTTP requests',
|
||||||
labelNames: ['method', 'path'],
|
labelNames: ['method'],
|
||||||
});
|
});
|
||||||
|
|
||||||
export const fetchCounter = new Counter({
|
export const fetchCounter = new Counter({
|
||||||
name: 'fetch_total',
|
name: 'fetch_total',
|
||||||
help: 'Total number of fetch requests',
|
help: 'Total number of fetch requests',
|
||||||
labelNames: ['method', 'path'],
|
labelNames: ['method'],
|
||||||
});
|
});
|
||||||
|
|
||||||
export const firehoseEventCounter = new Counter({
|
export const firehoseEventCounter = new Counter({
|
||||||
|
|||||||
@@ -3,8 +3,8 @@ import { MiddlewareHandler } from '@hono/hono';
|
|||||||
import { httpRequestCounter } from '@/metrics.ts';
|
import { httpRequestCounter } from '@/metrics.ts';
|
||||||
|
|
||||||
export const metricsMiddleware: MiddlewareHandler = async (c, next) => {
|
export const metricsMiddleware: MiddlewareHandler = async (c, next) => {
|
||||||
const { method, path } = c.req;
|
const { method } = c.req;
|
||||||
httpRequestCounter.inc({ method, path });
|
httpRequestCounter.inc({ method });
|
||||||
|
|
||||||
await next();
|
await next();
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ const fetchWorker: typeof fetch = async (...args) => {
|
|||||||
await ready;
|
await ready;
|
||||||
const [url, init] = serializeFetchArgs(args);
|
const [url, init] = serializeFetchArgs(args);
|
||||||
const { body, signal, ...rest } = init;
|
const { body, signal, ...rest } = init;
|
||||||
fetchCounter.inc({ method: init.method, path: new URL(url).pathname });
|
fetchCounter.inc({ method: init.method });
|
||||||
const result = await client.fetch(url, { ...rest, body: await prepareBodyForWorker(body) }, signal);
|
const result = await client.fetch(url, { ...rest, body: await prepareBodyForWorker(body) }, signal);
|
||||||
return new Response(...result);
|
return new Response(...result);
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user