Skip to content

Commit

Permalink
userservice: fix cache age metric (#401)
Browse files Browse the repository at this point in the history
A reference to the AtomicLong for the PolledMeter was not
retained so it would get garbage collected and stop reporting.

Also removes an unnecessary print stack trace call and updates
the client to set the endpoint for metrics. Since the remote
service in this case does not have the headers set, it is not
picked up automatically.
  • Loading branch information
brharrington committed May 4, 2019
1 parent 1dcfcef commit 28fb5a5
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ abstract class AbstractUserService extends AbstractService implements UserServic
if (enabled) {
PolledMeter.using(registry)
.withId(cacheAge)
.monitorValue(new AtomicLong(clock.wallTime()), Functions.age(clock));
.monitorValue(lastUpdateTime, Functions.age(clock));
}
}

Expand Down Expand Up @@ -102,7 +102,6 @@ private boolean refresh() {
lastUpdateTime.set(context.registry().clock().wallTime());
return true;
} catch (Exception e) {
e.printStackTrace();
logger.warn("failed to refresh users list", e);
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ HttpResponse get(String name, String uri) throws IOException {
.withRetries(2)
.acceptJson()
.acceptGzip()
.customizeLogging(entry -> entry.withEndpoint(name))
.send()
.decompress();
}
Expand Down

0 comments on commit 28fb5a5

Please sign in to comment.