Skip to content

Commit e1bb911

Browse files
committed
feat: attempts
1 parent 86c59b0 commit e1bb911

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/perms/middleware.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ use tower::{Layer, Service};
2424
use tracing::info;
2525
use tracing_opentelemetry::OpenTelemetrySpanExt;
2626

27+
const ATTEMPTS: &str = "init4.perms.attempts";
28+
const ATTEMPTS_DESCR: &str = "Counts the number of builder permissioning attempts";
29+
2730
const MISSING_HEADER: &str = "init4.perms.missing_header";
2831
const MISSING_HEADER_DESCR: &str =
2932
"Counts the number of requests missing the authentication header";
@@ -36,6 +39,7 @@ const SUCCESS: &str = "init4.perms.success";
3639
const SUCCESS_DESCR: &str = "Counts the number of auths allowed due to builder permissioning";
3740

3841
static DESCRIBE: LazyLock<()> = LazyLock::new(|| {
42+
describe_counter!(ATTEMPTS, ATTEMPTS_DESCR);
3943
describe_counter!(MISSING_HEADER, MISSING_HEADER_DESCR);
4044
describe_counter!(PERMISSION_DENIED, PERMISSION_DENIED_DESCR);
4145
describe_counter!(SUCCESS, SUCCESS_DESCR);
@@ -199,6 +203,8 @@ where
199203

200204
let guard = span.enter();
201205

206+
counter!(ATTEMPTS).increment(1);
207+
202208
// Check if the sub is in the header.
203209
let sub = match validate_header_sub(req.headers().get("x-jwt-claim-sub")) {
204210
Ok(sub) => sub,

0 commit comments

Comments
 (0)