Skip to content

Commit

Permalink
[authorization] Extend metric gitpod_guard_access_checks_total by "fu…
Browse files Browse the repository at this point in the history
…nction-access" (#18928)
  • Loading branch information
geropl authored Oct 16, 2023
1 parent fe087f6 commit 3160a20
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 2 additions & 0 deletions components/server/src/auth/function-access.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
*/

import { injectable } from "inversify";
import { reportGuardAccessCheck } from "../prometheus-metrics";

export interface FunctionAccessGuard {
canAccess(name: string): boolean;
Expand All @@ -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);
}
}
2 changes: 1 addition & 1 deletion components/server/src/prometheus-metrics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down

0 comments on commit 3160a20

Please sign in to comment.