Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

👷‍♀ Enable reduced Session Replay data batch time limit #3088

Merged
merged 1 commit into from
Oct 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion packages/core/src/tools/experimentalFeatures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ export enum ExperimentalFeature {
REMOTE_CONFIGURATION = 'remote_configuration',
UPDATE_VIEW_NAME = 'update_view_name',
LONG_ANIMATION_FRAME = 'long_animation_frame',
REDUCE_SEGMENT_LIMIT_BATCH_TIME = 'reduce_segment_limit_batch_time',
}

const enabledExperimentalFeatures: Set<ExperimentalFeature> = new Set()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
computeSegmentContext,
doStartSegmentCollection,
SEGMENT_BYTES_LIMIT,
getSegmentDurationLimit,
SEGMENT_DURATION_LIMIT,
} from './segmentCollection'

const CONTEXT: SegmentContext = { application: { id: 'a' }, view: { id: 'b' }, session: { id: 'c' } }
Expand All @@ -26,7 +26,7 @@ const VERY_BIG_RECORD: BrowserRecord = {
data: Array(SEGMENT_BYTES_LIMIT).join('a') as any,
}

const BEFORE_SEGMENT_DURATION_LIMIT = getSegmentDurationLimit() * 0.9
const BEFORE_SEGMENT_DURATION_LIMIT = SEGMENT_DURATION_LIMIT * 0.9

describe('startSegmentCollection', () => {
let stopSegmentCollection: () => void
Expand Down Expand Up @@ -240,15 +240,15 @@ describe('startSegmentCollection', () => {
it('uses `httpRequest.send` when sending the segment', () => {
clock = mockClock()
addRecordAndFlushSegment(() => {
clock!.tick(getSegmentDurationLimit())
clock!.tick(SEGMENT_DURATION_LIMIT)
})
expect(httpRequestSpy.send).toHaveBeenCalled()
})

it('next segment is created because of the segment duration limit has been reached', async () => {
clock = mockClock()
addRecordAndFlushSegment(() => {
clock!.tick(getSegmentDurationLimit())
clock!.tick(SEGMENT_DURATION_LIMIT)
})
addRecordAndFlushSegment()
expect((await readMostRecentMetadata(httpRequestSpy.sendOnExit)).creation_reason).toBe('segment_duration_limit')
Expand Down
17 changes: 3 additions & 14 deletions packages/rum/src/domain/segmentCollection/segmentCollection.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,13 @@
import type { DeflateEncoder, HttpRequest, TimeoutId } from '@datadog/browser-core'
import {
isPageExitReason,
ONE_SECOND,
clearTimeout,
setTimeout,
isExperimentalFeatureEnabled,
ExperimentalFeature,
} from '@datadog/browser-core'
import { isPageExitReason, ONE_SECOND, clearTimeout, setTimeout } from '@datadog/browser-core'
import type { LifeCycle, ViewHistory, RumSessionManager, RumConfiguration } from '@datadog/browser-rum-core'
import { LifeCycleEventType } from '@datadog/browser-rum-core'
import type { BrowserRecord, CreationReason, SegmentContext } from '../../types'
import { buildReplayPayload } from './buildReplayPayload'
import type { FlushReason, Segment } from './segment'
import { createSegment } from './segment'

export function getSegmentDurationLimit() {
return isExperimentalFeatureEnabled(ExperimentalFeature.REDUCE_SEGMENT_LIMIT_BATCH_TIME)
? 5 * ONE_SECOND
: 30 * ONE_SECOND
}
export const SEGMENT_DURATION_LIMIT = 5 * ONE_SECOND
/**
* beacon payload max queue size implementation is 64kb
* ensure that we leave room for logs, rum and potential other users
Expand Down Expand Up @@ -150,7 +139,7 @@ export function doStartSegmentCollection(
segment: createSegment({ encoder, context, creationReason: state.nextSegmentCreationReason }),
expirationTimeoutId: setTimeout(() => {
flushSegment('segment_duration_limit')
}, getSegmentDurationLimit()),
}, SEGMENT_DURATION_LIMIT),
}
}

Expand Down