Skip to content

Commit

Permalink
narrowed allowed labels
Browse files Browse the repository at this point in the history
  • Loading branch information
JulienR1 committed Nov 22, 2023
1 parent 9dd1326 commit 75e65a7
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/prometheus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ export async function metrics() {
return new Response(await registry.metrics(), { status: 200, headers });
}

export function registerCounter(name: string, help: string, labels?: string[]) {
export function registerCounter<T extends string = string>(name: string, help: string, labels?: T[]) {
try {
registry.registerMetric(new client.Counter({ name, help, labelNames: labels ?? []}));
return registry.getSingleMetric(name) as Counter;
registry.registerMetric(new client.Counter({ name, help, labelNames: labels ?? [] }));
return registry.getSingleMetric(name) as Counter<T>;
} catch (error) {}
}

Expand Down

0 comments on commit 75e65a7

Please sign in to comment.