Skip to content

Commit

Permalink
Merge branch 'benoit/re-enable-retry-replay' (cbc83ff) into staging-51
Browse files Browse the repository at this point in the history
 pm_trace_id: 11831456
 feature_branch_pipeline_id: 11831456
 source: to-staging

* commit 'cbc83fff4aa26f23b27b36d8e0123db90d32ecec':
  Revert "Revert "✨ [RUMF-1425] enable request retry/throttle for replay intake (#1819)" (#1820)"
  v4.28.0 (#1876)
  • Loading branch information
BenoitZugmeyer committed Dec 14, 2022
2 parents 37de1b8 + cbc83ff commit 40919f8
Show file tree
Hide file tree
Showing 12 changed files with 43 additions and 115 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@
---

## v4.28.0

- 🐛 [RUMF-1337] Fix incorrect fetch duration ([#1875](https://github.com/DataDog/browser-sdk/pull/1875))

## v4.27.1

- 🐛 [RUMF-1449] fix Zone support when **symbol** is missing ([#1872](https://github.com/DataDog/browser-sdk/pull/1872))
Expand Down
2 changes: 1 addition & 1 deletion developer-extension/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@datadog/browser-sdk-developer-extension",
"version": "4.27.1",
"version": "4.28.0",
"private": true,
"scripts": {
"build": "rm -rf dist && webpack --mode production",
Expand Down
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"npmClient": "yarn",
"useWorkspaces": true,
"version": "4.27.1",
"version": "4.28.0",
"publishConfig": {
"access": "public"
}
Expand Down
2 changes: 1 addition & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@datadog/browser-core",
"version": "4.27.1",
"version": "4.28.0",
"license": "Apache-2.0",
"main": "cjs/index.js",
"module": "esm/index.js",
Expand Down
4 changes: 2 additions & 2 deletions packages/logs/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@datadog/browser-logs",
"version": "4.27.1",
"version": "4.28.0",
"license": "Apache-2.0",
"main": "cjs/entries/main.js",
"module": "esm/entries/main.js",
Expand All @@ -13,7 +13,7 @@
"replace-build-env": "node ../../scripts/replace-build-env.js"
},
"dependencies": {
"@datadog/browser-core": "4.27.1"
"@datadog/browser-core": "4.28.0"
},
"peerDependencies": {
"@datadog/browser-rum": "4.27.1"
Expand Down
4 changes: 2 additions & 2 deletions packages/rum-core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@datadog/browser-rum-core",
"version": "4.27.1",
"version": "4.28.0",
"license": "Apache-2.0",
"main": "cjs/index.js",
"module": "esm/index.js",
Expand All @@ -12,7 +12,7 @@
"replace-build-env": "node ../../scripts/replace-build-env.js"
},
"dependencies": {
"@datadog/browser-core": "4.27.1"
"@datadog/browser-core": "4.28.0"
},
"devDependencies": {
"ajv": "6.12.6"
Expand Down
6 changes: 3 additions & 3 deletions packages/rum-slim/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@datadog/browser-rum-slim",
"version": "4.27.1",
"version": "4.28.0",
"license": "Apache-2.0",
"main": "cjs/entries/main.js",
"module": "esm/entries/main.js",
Expand All @@ -12,8 +12,8 @@
"build:esm": "rm -rf esm && tsc -p tsconfig.esm.json"
},
"dependencies": {
"@datadog/browser-core": "4.27.1",
"@datadog/browser-rum-core": "4.27.1"
"@datadog/browser-core": "4.28.0",
"@datadog/browser-rum-core": "4.28.0"
},
"peerDependencies": {
"@datadog/browser-logs": "4.27.1"
Expand Down
6 changes: 3 additions & 3 deletions packages/rum/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@datadog/browser-rum",
"version": "4.27.1",
"version": "4.28.0",
"license": "Apache-2.0",
"main": "cjs/entries/main.js",
"module": "esm/entries/main.js",
Expand All @@ -12,8 +12,8 @@
"build:esm": "rm -rf esm && tsc -p tsconfig.esm.json"
},
"dependencies": {
"@datadog/browser-core": "4.27.1",
"@datadog/browser-rum-core": "4.27.1"
"@datadog/browser-core": "4.28.0",
"@datadog/browser-rum-core": "4.28.0"
},
"peerDependencies": {
"@datadog/browser-logs": "4.27.1"
Expand Down
98 changes: 13 additions & 85 deletions packages/rum/src/domain/segmentCollection/segmentCollection.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { HttpRequest, TimeStamp } from '@datadog/browser-core'
import { PageExitReason, updateExperimentalFeatures, resetExperimentalFeatures, isIE } from '@datadog/browser-core'
import { PageExitReason, isIE } from '@datadog/browser-core'
import type { ViewContexts, ViewContext } from '@datadog/browser-rum-core'
import { LifeCycle, LifeCycleEventType } from '@datadog/browser-rum-core'
import type { Clock } from '@datadog/browser-core/test/specHelper'
Expand Down Expand Up @@ -83,7 +83,6 @@ describe('startSegmentCollection', () => {
afterEach(() => {
clock?.cleanup()
stopSegmentCollection()
resetExperimentalFeatures()
})

describe('initial segment', () => {
Expand Down Expand Up @@ -135,17 +134,6 @@ describe('startSegmentCollection', () => {
expect(httpRequestSpy.sendOnExit).toHaveBeenCalled()
})

describe('with the retry_replay experimental flag', () => {
beforeEach(() => {
updateExperimentalFeatures(['retry_replay'])
})

it('uses `httpRequest.sendOnExit` when sending the segment', () => {
addRecordAndFlushSegment(emulatePageUnload)
expect(httpRequestSpy.sendOnExit).toHaveBeenCalled()
})
})

it('next segment is created because of beforeunload event', () => {
addRecordAndFlushSegment(emulatePageUnload)
addRecordAndFlushSegment()
Expand All @@ -163,17 +151,6 @@ describe('startSegmentCollection', () => {
expect(httpRequestSpy.sendOnExit).toHaveBeenCalled()
})

describe('with the retry_replay experimental flag', () => {
beforeEach(() => {
updateExperimentalFeatures(['retry_replay'])
})

it('uses `httpRequest.sendOnExit` when sending the segment', () => {
addRecordAndFlushSegment(emulatePageHidden)
expect(httpRequestSpy.sendOnExit).toHaveBeenCalled()
})
})

it('next segment is created because of visibility hidden event', () => {
addRecordAndFlushSegment(emulatePageHidden)
addRecordAndFlushSegment()
Expand All @@ -186,20 +163,9 @@ describe('startSegmentCollection', () => {
lifeCycle.notify(LifeCycleEventType.VIEW_CREATED, {} as any)
}

it('uses `httpRequest.sendOnExit` when sending the segment', () => {
it('uses `httpRequest.send` when sending the segment', () => {
addRecordAndFlushSegment(emulateViewChange)
expect(httpRequestSpy.sendOnExit).toHaveBeenCalled()
})

describe('with the retry_replay experimental flag', () => {
beforeEach(() => {
updateExperimentalFeatures(['retry_replay'])
})

it('uses `httpRequest.send` when sending the segment', () => {
addRecordAndFlushSegment(emulateViewChange)
expect(httpRequestSpy.send).toHaveBeenCalled()
})
expect(httpRequestSpy.send).toHaveBeenCalled()
})

it('next segment is created because of view change', () => {
Expand All @@ -210,24 +176,11 @@ describe('startSegmentCollection', () => {
})

describe('flush when reaching a bytes limit', () => {
it('uses `httpRequest.sendOnExit` when sending the segment', () => {
it('uses `httpRequest.send` when sending the segment', () => {
addRecordAndFlushSegment(() => {
addRecord(VERY_BIG_RECORD)
})
expect(httpRequestSpy.sendOnExit).toHaveBeenCalled()
})

describe('with the retry_replay experimental flag', () => {
beforeEach(() => {
updateExperimentalFeatures(['retry_replay'])
})

it('uses `httpRequest.send` when sending the segment', () => {
addRecordAndFlushSegment(() => {
addRecord(VERY_BIG_RECORD)
})
expect(httpRequestSpy.send).toHaveBeenCalled()
})
expect(httpRequestSpy.send).toHaveBeenCalled()
})

it('next segment is created because the bytes limit has been reached', () => {
Expand All @@ -246,8 +199,8 @@ describe('startSegmentCollection', () => {
addRecord(RECORD)
worker.processAllMessages()

expect(httpRequestSpy.sendOnExit).toHaveBeenCalledTimes(1)
expect(getSentFormData(httpRequestSpy.sendOnExit).get('records_count')).toBe('4')
expect(httpRequestSpy.send).toHaveBeenCalledTimes(1)
expect(getSentFormData(httpRequestSpy.send).get('records_count')).toBe('4')
})

it('does not flush segment prematurely when records from the previous segment are still being processed', () => {
Expand All @@ -264,32 +217,18 @@ describe('startSegmentCollection', () => {

worker.processAllMessages()

expect(httpRequestSpy.sendOnExit).toHaveBeenCalledTimes(1)
expect(getSentFormData(httpRequestSpy.sendOnExit).get('records_count')).toBe('2')
expect(httpRequestSpy.send).toHaveBeenCalledTimes(1)
expect(getSentFormData(httpRequestSpy.send).get('records_count')).toBe('2')
})
})

describe('flush when a duration has been reached', () => {
it('uses `httpRequest.sendOnExit` when sending the segment', () => {
it('uses `httpRequest.send` when sending the segment', () => {
clock = mockClock()
addRecordAndFlushSegment(() => {
clock!.tick(SEGMENT_DURATION_LIMIT)
})
expect(httpRequestSpy.sendOnExit).toHaveBeenCalled()
})

describe('with the retry_replay experimental flag', () => {
beforeEach(() => {
updateExperimentalFeatures(['retry_replay'])
})

it('uses `httpRequest.send` when sending the segment', () => {
clock = mockClock()
addRecordAndFlushSegment(() => {
clock!.tick(SEGMENT_DURATION_LIMIT)
})
expect(httpRequestSpy.send).toHaveBeenCalled()
})
expect(httpRequestSpy.send).toHaveBeenCalled()
})

it('next segment is created because of the segment duration limit has been reached', () => {
Expand Down Expand Up @@ -317,20 +256,9 @@ describe('startSegmentCollection', () => {
})

describe('flush when stopping segment collection', () => {
it('uses `httpRequest.sendOnExit` when sending the segment', () => {
it('uses `httpRequest.send` when sending the segment', () => {
addRecordAndFlushSegment(stopSegmentCollection)
expect(httpRequestSpy.sendOnExit).toHaveBeenCalled()
})

describe('with the retry_replay experimental flag', () => {
beforeEach(() => {
updateExperimentalFeatures(['retry_replay'])
})

it('uses `httpRequest.send` when sending the segment', () => {
addRecordAndFlushSegment(stopSegmentCollection)
expect(httpRequestSpy.send).toHaveBeenCalled()
})
expect(httpRequestSpy.send).toHaveBeenCalled()
})
})
})
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { HttpRequest, TimeoutId } from '@datadog/browser-core'
import { isExperimentalFeatureEnabled, ONE_SECOND, monitor } from '@datadog/browser-core'
import { ONE_SECOND, monitor } from '@datadog/browser-core'
import type { LifeCycle, ViewContexts, RumSessionManager } from '@datadog/browser-rum-core'
import { LifeCycleEventType } from '@datadog/browser-rum-core'
import type { BrowserRecord, CreationReason, SegmentContext } from '../../types'
Expand Down Expand Up @@ -133,11 +133,7 @@ export function doStartSegmentCollection(
},
(data, rawSegmentBytesCount) => {
const payload = buildReplayPayload(data, segment.metadata, rawSegmentBytesCount)
if (
!isExperimentalFeatureEnabled('retry_replay') ||
segment.flushReason === 'visibility_hidden' ||
segment.flushReason === 'before_unload'
) {
if (segment.flushReason === 'visibility_hidden' || segment.flushReason === 'before_unload') {
httpRequest.sendOnExit(payload)
} else {
httpRequest.send(payload)
Expand Down
2 changes: 1 addition & 1 deletion performances/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"private": true,
"name": "performances",
"version": "4.27.1",
"version": "4.28.0",
"scripts": {
"start": "ts-node ./src/main.ts"
},
Expand Down
20 changes: 10 additions & 10 deletions test/app/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,24 @@
# yarn lockfile v1


"@datadog/browser-core@4.27.1", "@datadog/browser-core@file:../../packages/core":
version "4.27.1"
"@datadog/browser-core@4.28.0", "@datadog/browser-core@file:../../packages/core":
version "4.28.0"

"@datadog/browser-logs@file:../../packages/logs":
version "4.27.1"
version "4.28.0"
dependencies:
"@datadog/browser-core" "4.27.1"
"@datadog/browser-core" "4.28.0"

"@datadog/browser-rum-core@4.27.1", "@datadog/browser-rum-core@file:../../packages/rum-core":
version "4.27.1"
"@datadog/browser-rum-core@4.28.0", "@datadog/browser-rum-core@file:../../packages/rum-core":
version "4.28.0"
dependencies:
"@datadog/browser-core" "4.27.1"
"@datadog/browser-core" "4.28.0"

"@datadog/browser-rum@file:../../packages/rum":
version "4.27.1"
version "4.28.0"
dependencies:
"@datadog/browser-core" "4.27.1"
"@datadog/browser-rum-core" "4.27.1"
"@datadog/browser-core" "4.28.0"
"@datadog/browser-rum-core" "4.28.0"

"@jridgewell/gen-mapping@^0.3.0":
version "0.3.2"
Expand Down

0 comments on commit 40919f8

Please sign in to comment.