Skip to content

Commit

Permalink
Add null-safety in prometheus
Browse files Browse the repository at this point in the history
  • Loading branch information
dmgaldi committed Dec 22, 2022
1 parent 6c52849 commit 0c46bac
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,11 @@ public void filter(ContainerRequestContext req, ContainerResponseContext res) {
req.setProperty(METHOD_KEY, req.getMethod());
req.setProperty(IS_ERROR_KEY, isError);
}
reqCount.labels((String) req.getProperty(MATCHED_URL_KEY), req.getMethod(), String.valueOf(res.getStatus()))
.inc();
req.removeProperty(MATCHED_URL_KEY);
final String matchedUrlKey = (String) req.getProperty(MATCHED_URL_KEY);
if (matchedUrlKey != null) {
reqCount.labels(matchedUrlKey, req.getMethod(), String.valueOf(res.getStatus())).inc();
req.removeProperty(MATCHED_URL_KEY);
}
}

@Override
Expand Down

0 comments on commit 0c46bac

Please sign in to comment.