Skip to content

Commit

Permalink
Record caller metrics in Atlas
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
  • Loading branch information
Giorgio Trettenero committed Jan 13, 2025
1 parent 52066ec commit 51d8eb3
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 51d8eb3

Please sign in to comment.