Skip to content

Commit

Permalink
Merge pull request #2474 from atlanhq/PLT-245-beta-apikey-counter
Browse files Browse the repository at this point in the history
Add metric counter when authenticating a request from a service-account
  • Loading branch information
ektavarma10 authored Nov 14, 2023
2 parents 61cb2ba + ac5d5e1 commit 92a6749
Showing 1 changed file with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
*/
package org.apache.atlas.web.security;

import io.micrometer.core.instrument.Counter;
import org.apache.atlas.service.metrics.MetricUtils;
import org.apache.atlas.ApplicationProperties;
import org.apache.commons.configuration.Configuration;
import org.keycloak.adapters.springsecurity.authentication.KeycloakAuthenticationProvider;
Expand Down Expand Up @@ -66,6 +68,11 @@ public Authentication authenticate(Authentication authentication) {
}
}

if(authentication.getName().startsWith("service-account-apikey")) {
// Increment the counter when the authentication is for a service account.
Counter.builder("service_account_apikey_request_counter").register(MetricUtils.getMeterRegistry()).increment();
}

return authentication;
}

Expand Down

0 comments on commit 92a6749

Please sign in to comment.