Skip to content

RUMM-2796 RequestFactory can throw exceptions#1214

Merged
mariusc83 merged 1 commit into
feature/sdkv2from
mconstantin/rumm-2796/request-factory-can-throw-exceptions
Jan 5, 2023
Merged

RUMM-2796 RequestFactory can throw exceptions#1214
mariusc83 merged 1 commit into
feature/sdkv2from
mconstantin/rumm-2796/request-factory-can-throw-exceptions

Conversation

@mariusc83

Copy link
Copy Markdown
Member

What does this PR do?

A brief description of the change being made with this pull request.

Motivation

What inspired you to submit this pull request?

Additional Notes

Anything else we should know when reviewing?

Review checklist (to be filled by reviewers)

  • Feature or bugfix MUST have appropriate tests (unit, integration, e2e)
  • Make sure you discussed the feature or bugfix with the maintaining team in an Issue
  • Make sure each commit and the PR mention the Issue number (cf the CONTRIBUTING doc)

@mariusc83
mariusc83 requested a review from a team as a code owner January 4, 2023 09:28
@mariusc83 mariusc83 self-assigned this Jan 4, 2023
@mariusc83
mariusc83 force-pushed the mconstantin/rumm-2796/request-factory-can-throw-exceptions branch 2 times, most recently from 3659546 to 3da65f5 Compare January 4, 2023 09:51

@0xnm 0xnm left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've left few suggestion, but overall lgtm.

internal enum class UploadStatus(val shouldRetry: Boolean) {
SUCCESS(shouldRetry = false),
NETWORK_ERROR(shouldRetry = true),
INVALID_REQUEST_ERROR(shouldRetry = false),

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would suggest something like REQUEST_CREATION_ERROR, because INVALID_REQUEST_ERROR may have a meaning that request was sent, but was rejected by the server (code 400, which is currently backed by HTTP_CLIENT_ERROR).


@Test
fun `M return InvalidRequestError W upload() { request factory throws }`(
@Forgery fakeException: java.lang.Exception,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
@Forgery fakeException: java.lang.Exception,
@Forgery fakeException: Exception,


@Test
fun `M log the exception to telemetry W upload() { request factory throws }`(
@Forgery fakeException: java.lang.Exception,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
@Forgery fakeException: java.lang.Exception,
@Forgery fakeException: Exception,

@mariusc83
mariusc83 force-pushed the mconstantin/rumm-2796/request-factory-can-throw-exceptions branch from 3da65f5 to 82208f3 Compare January 4, 2023 11:55
@mariusc83
mariusc83 force-pushed the mconstantin/rumm-2796/request-factory-can-throw-exceptions branch from 82208f3 to b31891b Compare January 4, 2023 12:17
@codecov-commenter

codecov-commenter commented Jan 4, 2023

Copy link
Copy Markdown

Codecov Report

Merging #1214 (b31891b) into feature/sdkv2 (555764f) will increase coverage by 0.04%.
The diff coverage is 100.00%.

@@                Coverage Diff                @@
##           feature/sdkv2    #1214      +/-   ##
=================================================
+ Coverage          82.65%   82.69%   +0.04%     
=================================================
  Files                353      353              
  Lines              12537    12545       +8     
  Branches            2075     2073       -2     
=================================================
+ Hits               10362    10374      +12     
+ Misses              1537     1535       -2     
+ Partials             638      636       -2     
Impacted Files Coverage Δ
...otlin/com/datadog/android/v2/api/RequestFactory.kt 0.00% <ø> (ø)
.../datadog/android/core/internal/net/UploadStatus.kt 98.18% <100.00%> (+0.18%) ⬆️
...android/v2/core/internal/net/DataOkHttpUploader.kt 94.94% <100.00%> (+0.57%) ⬆️
...droid/rum/tracking/ActivityViewTrackingStrategy.kt 86.54% <0.00%> (-1.92%) ⬇️
...in/com/datadog/android/log/internal/LogsFeature.kt 85.15% <0.00%> (-0.99%) ⬇️
...ndroid/telemetry/internal/TelemetryEventHandler.kt 73.60% <0.00%> (-0.80%) ⬇️
.../android/rum/internal/monitor/DatadogRumMonitor.kt 90.81% <0.00%> (-0.54%) ⬇️
.../android/rum/internal/domain/scope/RumViewScope.kt 95.36% <0.00%> (-0.18%) ⬇️
...android/log/internal/logger/TelemetryLogHandler.kt 85.71% <0.00%> (ø)
... and 6 more

val request = requestFactory.create(context, batch, batchMeta)
val request = try {
requestFactory.create(context, batch, batchMeta)
} catch (e: Exception) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DO we have more information on what type of exception can happen? Or is this just hypothetical?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unfortunately we don't. For example in case of SR it can be because of a bad payload format but in other cases it may be something else. I followed what iOS is doing also and I saw they also have it generic.

@mariusc83
mariusc83 merged commit 0b06acb into feature/sdkv2 Jan 5, 2023
@mariusc83
mariusc83 deleted the mconstantin/rumm-2796/request-factory-can-throw-exceptions branch January 5, 2023 09:03
@xgouchet xgouchet added this to the 1.17.0 milestone Dec 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants