From 60e81dbd5874b603ac398a1a3e8f292f2f46ff72 Mon Sep 17 00:00:00 2001 From: gtrettenero <98507672+gtrettenero@users.noreply.github.com> Date: Mon, 13 Jan 2025 19:50:48 -0500 Subject: [PATCH] Record caller metrics in Atlas (#625) comment out: Record caller metrics in Atlas original adding UNKNOWN value print print without call print without call and double print still print but uncomment first put still print and uncomment second put still print and uncomment both puts focus only on first call, which errors, and use log instead of print assign to variable logs around variable logs around variable don't directly print null remove logs Co-authored-by: Giorgio Trettenero --- .../com/netflix/metacat/common/MetacatRequestContext.java | 3 ++- .../java/com/netflix/metacat/main/api/RequestWrapper.java | 7 +++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/metacat-common/src/main/java/com/netflix/metacat/common/MetacatRequestContext.java b/metacat-common/src/main/java/com/netflix/metacat/common/MetacatRequestContext.java index 7f28875d2..1efb31d02 100644 --- a/metacat-common/src/main/java/com/netflix/metacat/common/MetacatRequestContext.java +++ b/metacat-common/src/main/java/com/netflix/metacat/common/MetacatRequestContext.java @@ -92,7 +92,7 @@ public class MetacatRequestContext implements Serializable { */ public MetacatRequestContext() { this.userName = null; - this.clientAppName = null; + this.clientAppName = UNKNOWN; this.clientId = null; this.jobId = null; this.dataTypeContext = null; @@ -198,6 +198,7 @@ public static class MetacatRequestContextBuilder { MetacatRequestContextBuilder() { this.bApiUri = UNKNOWN; this.bScheme = UNKNOWN; + this.bClientAppName = UNKNOWN; } /** diff --git a/metacat-main/src/main/java/com/netflix/metacat/main/api/RequestWrapper.java b/metacat-main/src/main/java/com/netflix/metacat/main/api/RequestWrapper.java index 23240b85d..64f28c003 100644 --- a/metacat-main/src/main/java/com/netflix/metacat/main/api/RequestWrapper.java +++ b/metacat-main/src/main/java/com/netflix/metacat/main/api/RequestWrapper.java @@ -154,8 +154,14 @@ public R processRequest( if (requestTags != null) { tags.putAll(requestTags); } + tags.put("request", resourceRequestName); tags.put("scheme", MetacatContextManager.getContext().getScheme()); + String clientAppName = MetacatContextManager.getContext().getClientAppName(); + if (clientAppName == null) { + clientAppName = "UNKNOWN"; + } + tags.put("caller", clientAppName); registry.counter(requestCounterId.withTags(tags)).increment(); try { @@ -243,6 +249,7 @@ public R processRequest( final long start = registry.clock().wallTime(); final Map tags = Maps.newHashMap(); tags.put("request", resourceRequestName); + tags.put("caller", MetacatContextManager.getContext().getClientAppName()); registry.counter(requestCounterId.withTags(tags)).increment(); try { MetacatContextManager.getContext().setRequestName(resourceRequestName);