From f1f61553bb544a202183677d4728d7c6e57ae7cf Mon Sep 17 00:00:00 2001 From: Gero Posmyk-Leinemann Date: Mon, 16 Oct 2023 07:16:31 +0000 Subject: [PATCH] [authorization] Extend metric gitpod_guard_access_checks_total by "function-access" --- components/server/src/auth/function-access.ts | 2 ++ components/server/src/prometheus-metrics.ts | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/components/server/src/auth/function-access.ts b/components/server/src/auth/function-access.ts index 75ca43e8fb7e6e..114e2db9a4301d 100644 --- a/components/server/src/auth/function-access.ts +++ b/components/server/src/auth/function-access.ts @@ -5,6 +5,7 @@ */ import { injectable } from "inversify"; +import { reportGuardAccessCheck } from "../prometheus-metrics"; export interface FunctionAccessGuard { canAccess(name: string): boolean; @@ -28,6 +29,7 @@ export class ExplicitFunctionAccessGuard { constructor(protected readonly allowedCalls: string[]) {} canAccess(name: string): boolean { + reportGuardAccessCheck("function-access"); return this.allowedCalls.some((c) => c === name); } } diff --git a/components/server/src/prometheus-metrics.ts b/components/server/src/prometheus-metrics.ts index 0d356dc0ae37fb..53e765aae7820a 100644 --- a/components/server/src/prometheus-metrics.ts +++ b/components/server/src/prometheus-metrics.ts @@ -348,7 +348,7 @@ export const guardAccessChecksTotal = new prometheusClient.Counter({ labelNames: ["type"], }); -export type GuardAccessCheckType = "fga" | "resource-access"; +export type GuardAccessCheckType = "fga" | "resource-access" | "function-access"; export function reportGuardAccessCheck(type: GuardAccessCheckType) { guardAccessChecksTotal.labels(type).inc(); }