From 37d1eeeaafe13421086498490698dc0172070f99 Mon Sep 17 00:00:00 2001 From: Suman Das <59254445+sumandas0@users.noreply.github.com> Date: Tue, 5 Mar 2024 16:25:25 +0530 Subject: [PATCH] feat: log all the integration metrics --- .../apache/atlas/auth/client/auth/AbstractAuthClient.java | 6 +++--- .../java/org/apache/atlas/service/metrics/MetricUtils.java | 4 ++++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/client-auth/src/main/java/org/apache/atlas/auth/client/auth/AbstractAuthClient.java b/client-auth/src/main/java/org/apache/atlas/auth/client/auth/AbstractAuthClient.java index cb13431384..988a120bfd 100644 --- a/client-auth/src/main/java/org/apache/atlas/auth/client/auth/AbstractAuthClient.java +++ b/client-auth/src/main/java/org/apache/atlas/auth/client/auth/AbstractAuthClient.java @@ -38,7 +38,7 @@ public class AbstractAuthClient { private static final String BEARER = "Bearer "; private static final int TIMEOUT_IN_SEC = 60; private static final String INTEGRATION = "integration"; - private static final String KEYCLOAK = "keycloak"; + private static final String AUTH = "auth"; protected final AuthConfig authConfig; protected final RetrofitKeycloakClient retrofitKeycloakClient; @@ -84,10 +84,10 @@ public AbstractAuthClient(AuthConfig authConfig) { Interceptor responseLoggingInterceptor = chain -> { Request request = chain.request(); String rawPath = request.url().uri().getRawPath(); - Timer.Sample timerSample = this.metricUtils.start(rawPath); + Timer.Sample timerSample = this.metricUtils.start(rawPath, false); okhttp3.Response response = chain.proceed(request); this.metricUtils.recordHttpTimer(timerSample, request.method(), rawPath, response.code(), - INTEGRATION, KEYCLOAK); + INTEGRATION, AUTH); return response; }; diff --git a/common/src/main/java/org/apache/atlas/service/metrics/MetricUtils.java b/common/src/main/java/org/apache/atlas/service/metrics/MetricUtils.java index c309190391..523225ce7f 100644 --- a/common/src/main/java/org/apache/atlas/service/metrics/MetricUtils.java +++ b/common/src/main/java/org/apache/atlas/service/metrics/MetricUtils.java @@ -52,6 +52,10 @@ public Timer.Sample start(String uri) { return matchCanonicalPattern(uri).isPresent() ? Timer.start(getMeterRegistry()) : null; } + public Timer.Sample start(String uri, boolean checkCanonicalPattern) { + return checkCanonicalPattern ? start(uri) : Timer.start(getMeterRegistry()); + } + public void recordHttpTimer(Timer.Sample sample, String method, String rawPath, int code, String... additionalTags) { if (Objects.isNull(sample)) { return;