feat(metrics): count request:end, and only request:end

A failed request emits three lifecycle events. request:end is the terminal and
universal one, so it is the request counter; request:failed is additional and
gets its own series. Counting both as requests is the double count issue #64
was filed for.

Labels come from route, which the route table bounds, never from name, which
carries the arriving path and is bounded by nothing — issue #65.

Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
This commit is contained in:
chrnx committed 2026-09-18 13:26:32 -05:00
1 parent 22e77ee452
commit 5a74cad793
3 files changed
+101

No files matched your search

Binary file not shown.
+19
View File
@@ -0,0 +1,19 @@
/** One labelled series and its accumulated value. */
export interface Series {
route: string;
method: string;
status?: number;
value: number;
}
/** What the collector holds, for a consumer that wants numbers rather than text. */
export interface MetricsSnapshot {
requests: Series[];
errors: Series[];
duration: Array<{ route: string; method: string; sum: number; count: number }>;
}
export interface MetricsOptions {
/** Graph name the collector is published under, and the plugin's name. Defaults to `metrics`. */
provides?: string;
}