Skip to content

Commit

Permalink
🔥 (RUMM-997): Remove Resource duplication as Error
Browse files Browse the repository at this point in the history
  • Loading branch information
xgouchet committed Feb 25, 2021
1 parent 9b8e081 commit b18a181
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 331 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -176,18 +176,10 @@ internal class RumResourceScope(
userExtraAttributes = user.extraInfo
)
writer.write(rumEvent)
if (isFailedHttpRequest(statusCode)) {
val errorMessage = ERROR_MSG_FORMAT.format(method, url)
sendError(errorMessage, RumErrorSource.NETWORK, statusCode, null, writer)
}
parentScope.handleEvent(RumRawEvent.SentResource(), writer)
sent = true
}

private fun isFailedHttpRequest(statusCode: Long?): Boolean {
return (statusCode ?: 0) >= HTTP_ERROR_CODE_THRESHOLD
}

private fun resolveResourceProvider(): ResourceEvent.Provider? {
return if (firstPartyHostDetector.isFirstPartyUrl(url)) {
ResourceEvent.Provider(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,16 @@ internal class ResourceEventAssert(actual: ResourceEvent) :
return this
}

fun hasStatusCode(expected: Long?): ResourceEventAssert {
assertThat(actual.resource.statusCode)
.overridingErrorMessage(
"Expected event data to have resource.status_code $expected " +
"but was ${actual.resource.statusCode}"
)
.isEqualTo(expected)
return this
}

fun hasDurationGreaterThan(upperBound: Long): ResourceEventAssert {
assertThat(actual.resource.duration)
.overridingErrorMessage(
Expand Down
Loading

0 comments on commit b18a181

Please sign in to comment.