mirror of
https://gitlab.com/soapbox-pub/ditto.git
synced 2025-12-06 11:29:46 +00:00
metrics: remove path from fetch and request metrics
This commit is contained in:
parent
ea15f291b0
commit
e50ba819b9
3 changed files with 5 additions and 5 deletions
|
|
@ -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);
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue