Skip to content

Commit

Permalink
Tag URI for HTTP redirect responses from Jersey if route is matched (#…
Browse files Browse the repository at this point in the history
…3332)

Change default tag provider for Jersey to report redirect responses with the uri if a matched resource is found.

Resolves gh-3327
  • Loading branch information
tinolazreg committed Aug 10, 2022
1 parent 197071c commit f5f3e01
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
Expand Up @@ -87,7 +87,7 @@ public static Tag uri(RequestEvent event) {
ContainerResponse response = event.getContainerResponse();
if (response != null) {
int status = response.getStatus();
if (isRedirection(status)) {
if (isRedirection(status) && event.getUriInfo().getMatchedResourceMethod() == null) {
return URI_REDIRECTION;
}
if (status == 404 && event.getUriInfo().getMatchedResourceMethod() == null) {
Expand Down
Expand Up @@ -112,15 +112,15 @@ void notFoundIsReportedWithUriOfMatchedResource() {
}

@Test
void redirectsAreAccumulatedUnderSameUri() {
void redirectsAreReportedWithUriOfMatchedResource() {
target("redirect/302").request().get();
target("redirect/307").request().get();

assertThat(registry.get(METRIC_NAME).tags(tagsFrom("REDIRECTION", "302", "REDIRECTION", null)).timer().count())
.isEqualTo(1);
assertThat(registry.get(METRIC_NAME).tags(tagsFrom("/redirect/{status}", "302", "REDIRECTION", null)).timer()
.count()).isEqualTo(1);

assertThat(registry.get(METRIC_NAME).tags(tagsFrom("REDIRECTION", "307", "REDIRECTION", null)).timer().count())
.isEqualTo(1);
assertThat(registry.get(METRIC_NAME).tags(tagsFrom("/redirect/{status}", "307", "REDIRECTION", null)).timer()
.count()).isEqualTo(1);
}

@Test
Expand Down

0 comments on commit f5f3e01

Please sign in to comment.