Skip to content

Commit

Permalink
šŸ› [RUMF-1499] Don't send duration for resources crossing a page frozeā€¦
Browse files Browse the repository at this point in the history
ā€¦n state (#2271)
  • Loading branch information
amortemousque authored May 30, 2023
1 parent 9a053b7 commit 638b655
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 22 deletions.
1 change: 0 additions & 1 deletion packages/core/src/tools/experimentalFeatures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ export enum ExperimentalFeature {
RESOURCE_PAGE_STATES = 'resource_page_states',
PAGE_STATES = 'page_states',
COLLECT_FLUSH_REASON = 'collect_flush_reason',
NO_RESOURCE_DURATION_FROZEN_STATE = 'no_resource_duration_frozen_state',
}

const enabledExperimentalFeatures: Set<ExperimentalFeature> = new Set()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,7 @@ describe('resourceCollection', () => {
expect(rawRumResourceEventEntry._dd.page_states).toEqual(jasmine.objectContaining(mockPageStates))
})

it('should not have a duration if a frozen state happens during the request and no performance entry matches when NO_RESOURCE_DURATION_FROZEN_STATE enabled', () => {
addExperimentalFeatures([ExperimentalFeature.NO_RESOURCE_DURATION_FROZEN_STATE])
it('should not have a duration if a frozen state happens during the request and no performance entry matches', () => {
const { lifeCycle, rawRumEvents } = setupBuilder.build()
const mockPageStates = [{ state: PageState.FROZEN, startTime: 0 as RelativeTime }]
const mockXHR = createCompletedRequest()
Expand All @@ -146,19 +145,6 @@ describe('resourceCollection', () => {
expect(rawRumResourceEventFetch.resource.duration).toBeUndefined()
})

it('should have a duration if a frozen state happens during the request and no performance entry matches when NO_RESOURCE_DURATION_FROZEN_STATE disabled', () => {
const { lifeCycle, rawRumEvents } = setupBuilder.build()
const mockPageStates = [{ state: PageState.FROZEN, startTime: 0 as RelativeTime }]
const mockXHR = createCompletedRequest()

pageStateHistorySpy.and.returnValue(mockPageStates)

lifeCycle.notify(LifeCycleEventType.REQUEST_COMPLETED, mockXHR)

const rawRumResourceEventFetch = rawRumEvents[0].rawRumEvent as RawRumResourceEvent
expect(rawRumResourceEventFetch.resource.duration).toBeDefined()
})

it('should not collect page states on resources when ff resource_page_states disabled', () => {
const { lifeCycle, rawRumEvents } = setupBuilder.build()
const mockPageStates = [{ state: PageState.ACTIVE, startTime: 0 as RelativeTime }]
Expand All @@ -173,7 +159,6 @@ describe('resourceCollection', () => {
const rawRumResourceEventFetch = rawRumEvents[0].rawRumEvent as RawRumResourceEvent
const rawRumResourceEventEntry = rawRumEvents[1].rawRumEvent as RawRumResourceEvent

expect(pageStateHistorySpy).not.toHaveBeenCalled()
expect(rawRumResourceEventFetch._dd.page_states).not.toBeDefined()
expect(rawRumResourceEventEntry._dd.page_states).not.toBeDefined()
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,11 +231,6 @@ function computePageStateInfo(pageStateHistory: PageStateHistory, startClocks: C
}

function computeRequestDuration(pageStateHistory: PageStateHistory, startClocks: ClocksState, duration: Duration) {
// TODO remove FF in next major
if (!isExperimentalFeatureEnabled(ExperimentalFeature.NO_RESOURCE_DURATION_FROZEN_STATE)) {
return toServerDuration(duration)
}

const requestCrossedFrozenState = pageStateHistory
.findAll(startClocks.relative, duration)
?.some((pageState) => pageState.state === PageState.FROZEN)
Expand Down

0 comments on commit 638b655

Please sign in to comment.