-
Notifications
You must be signed in to change notification settings - Fork 5
/
metrics.ts
55 lines (52 loc) · 1.86 KB
/
metrics.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import { dev } from "$app/environment";
import {
Counter,
Gauge,
collectDefaultMetrics,
Registry,
register,
} from "prom-client";
// The global registry persists across HMR reloads of this module, throwing on
// every reload due to duplicate names. So, in dev, use a registry scoped to
// this module. In prod, we can't do that as the entrypoint to the application,
// which mounts the prom /metrics server there, can't import from sveltekit
// application chunks. Thankfully, there is no HMR in prod, so we can just use
// the global registry in that case.
export const registry = dev ? new Registry() : register;
collectDefaultMetrics({ register: registry });
export const zoektRequestCount = new Counter({
name: "zoekt_http_requests_total",
help: "Count of http requests made to zoekt",
labelNames: ["path", "status"],
registers: [registry],
});
export const zoektRequestDuration = new Counter({
name: "zoekt_http_request_seconds_total",
help: "Duration of http requests made to zoekt",
labelNames: ["path", "status"],
registers: [registry],
});
export const zoektRequestConcurrency = new Gauge({
name: "zoekt_http_requests",
help: "Gauge of concurrent requests being made to zoekt",
labelNames: ["path"],
registers: [registry],
});
export const neogrokRequestCount = new Counter({
name: "neogrok_http_requests_total",
help: "Count of http requests handled by neogrok",
labelNames: ["route", "status"],
registers: [registry],
});
export const neogrokRequestDuration = new Counter({
name: "neogrok_http_request_seconds_total",
help: "Duration of http requests handled by neogrok",
labelNames: ["route", "status"],
registers: [registry],
});
export const neogrokRequestConcurrency = new Gauge({
name: "neogrok_http_requests",
help: "Gauge of concurrent requests being handled by neogrok",
labelNames: ["route"],
registers: [registry],
});