metrics: remove path from fetch and request metrics

This commit is contained in:
Alex Gleason 2024-06-22 09:08:32 -05:00
parent ea15f291b0
commit e50ba819b9
No known key found for this signature in database
GPG key ID: 7211D1F99744FBB7
3 changed files with 5 additions and 5 deletions

View file

@ -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({

View file

@ -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();
}; };

View file

@ -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);
}; };