Skip to content

Commit

Permalink
Record caller metrics in Atlas (#625)
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
gtrettenero and Giorgio Trettenero authored Jan 14, 2025
1 parent 62985d9 commit 60e81db
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -198,6 +198,7 @@ public static class MetacatRequestContextBuilder {
MetacatRequestContextBuilder() {
this.bApiUri = UNKNOWN;
this.bScheme = UNKNOWN;
this.bClientAppName = UNKNOWN;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,14 @@ public <R> 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 {
Expand Down Expand Up @@ -243,6 +249,7 @@ public <R> R processRequest(
final long start = registry.clock().wallTime();
final Map<String, String> tags = Maps.newHashMap();
tags.put("request", resourceRequestName);
tags.put("caller", MetacatContextManager.getContext().getClientAppName());
registry.counter(requestCounterId.withTags(tags)).increment();
try {
MetacatContextManager.getContext().setRequestName(resourceRequestName);
Expand Down

0 comments on commit 60e81db

Please sign in to comment.