Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[authorization] Extend metric gitpod_guard_access_checks_total by "function-access" #18928

Merged
merged 1 commit into from
Oct 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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