Skip to content

Commit

Permalink
🔉[RUMF-1423] Add debug log for retry issue (#1790)
Browse files Browse the repository at this point in the history
* Add debug log when no payload to retry

* Remove 'resume after transport down' debug log
  • Loading branch information
bcaudan authored Oct 25, 2022
1 parent 34223e3 commit b8d8a74
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions packages/core/src/transport/sendWithRetryStrategy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ const enum RetryReason {

export interface RetryState {
transportStatus: TransportStatus
lastFailureStatus: number
currentBackoffTime: number
bandwidthMonitor: ReturnType<typeof newBandwidthMonitor>
queuedPayloads: ReturnType<typeof newPayloadQueue>
Expand Down Expand Up @@ -71,14 +70,21 @@ function scheduleRetry(
setTimeout(
monitor(() => {
const payload = state.queuedPayloads.first()
if (!payload) {
addTelemetryDebug('no payload to retry', {
debug: {
queue: {
size: state.queuedPayloads.size(),
is_full: state.queuedPayloads.isFull(),
bytes_count: state.queuedPayloads.bytesCount,
},
transport_status: state.transportStatus,
},
})
}
send(payload, state, sendStrategy, {
onSuccess: () => {
state.queuedPayloads.dequeue()
if (state.lastFailureStatus !== 0) {
addTelemetryDebug('resuming after transport down', {
failureStatus: state.lastFailureStatus,
})
}
state.currentBackoffTime = INITIAL_BACKOFF_TIME
retryQueuedPayloads(RetryReason.AFTER_RESUME, state, sendStrategy, endpointType, reportError)
},
Expand Down Expand Up @@ -108,7 +114,6 @@ function send(
// do not consider transport down if another ongoing request could succeed
state.transportStatus =
state.bandwidthMonitor.ongoingRequestCount > 0 ? TransportStatus.FAILURE_DETECTED : TransportStatus.DOWN
state.lastFailureStatus = response.status
onFailure()
}
})
Expand Down Expand Up @@ -143,7 +148,6 @@ function shouldRetryRequest(response: HttpResponse) {
export function newRetryState(): RetryState {
return {
transportStatus: TransportStatus.UP,
lastFailureStatus: 0,
currentBackoffTime: INITIAL_BACKOFF_TIME,
bandwidthMonitor: newBandwidthMonitor(),
queuedPayloads: newPayloadQueue(),
Expand Down

0 comments on commit b8d8a74

Please sign in to comment.