Spaces:
Sleeping
Sleeping
Download apps/api/src/lib/http-metrics.ts from s-eto-hub/firecrawl-api: direct link, hf CLI and curl.
- Browser
- Download file 602 Bytes
-
https://huggingface.co/spaces/s-eto-hub/firecrawl-api/resolve/main/apps/api/src/lib/http-metrics.ts
- Command line
-
hf download hf://spaces/s-eto-hub/firecrawl-api/apps/api/src/lib/http-metrics.ts
-
curl -L -o http-metrics.ts https://huggingface.co/spaces/s-eto-hub/firecrawl-api/resolve/main/apps/api/src/lib/http-metrics.ts
602 Bytes
| import { Histogram } from "prom-client"; | |
| import type { Request } from "express"; | |
| const UUID_REGEX = | |
| /[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/gi; | |
| export const httpRequestDurationSeconds = new Histogram({ | |
| name: "http_request_duration_seconds", | |
| help: "Duration of HTTP requests in seconds", | |
| labelNames: ["version", "method", "route", "status"], | |
| buckets: [0.01, 0.05, 0.1, 0.25, 0.5, 1, 2.5, 5, 10, 30, 60], | |
| }); | |
| export function getRoutePattern(req: Request): string { | |
| if (req.route?.path) { | |
| return req.route.path; | |
| } | |
| return req.path.replace(UUID_REGEX, ":id"); | |
| } | |