Skip to content

Commit

Permalink
Set unknown span status.
Browse files Browse the repository at this point in the history
  • Loading branch information
maciejwalkowiak committed Apr 15, 2021
1 parent f97cdb9 commit 42fe6b0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
Expand Up @@ -82,7 +82,8 @@ protected void doFilterInternal(
// if exception has been thrown, transaction status is already set to INTERNAL_ERROR, and
// httpResponse.getStatus() returns 200.
if (transaction.getStatus() == null) {
transaction.setStatus(SpanStatus.fromHttpStatusCode(httpResponse.getStatus()));
transaction.setStatus(
SpanStatus.fromHttpStatusCode(httpResponse.getStatus(), SpanStatus.UNKNOWN));
}
transaction.finish();
}
Expand Down
Expand Up @@ -86,6 +86,17 @@ class SentryTracingFilterTest {
})
}

@Test
fun `sets UNKNOWN span status for response status that dont match predefined span statuses`() {
val filter = fixture.getSut(status = 302)

filter.doFilter(fixture.request, fixture.response, fixture.chain)

verify(fixture.hub).captureTransaction(check {
assertThat(it.contexts.trace!!.status).isEqualTo(SpanStatus.UNKNOWN)
})
}

@Test
fun `when sentry trace is not present, transaction does not have parentSpanId set`() {
val filter = fixture.getSut()
Expand Down

0 comments on commit 42fe6b0

Please sign in to comment.