Skip to content

Commit

Permalink
Integrate fix-merge-2091830aea-into-staging-38 (#2997) into staging-38
Browse files Browse the repository at this point in the history
Integrated commit sha: 50eaf45

Co-authored-by: Benoît <benoit.zugmeyer@datadoghq.com>
  • Loading branch information
dd-mergequeue[bot] and BenoitZugmeyer authored Sep 16, 2024
2 parents c3a9fca + 50eaf45 commit 307c91f
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 44 deletions.
2 changes: 0 additions & 2 deletions packages/core/src/tools/experimentalFeatures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,8 @@ import { objectHasValue } from './utils/objectUtils'
// eslint-disable-next-line no-restricted-syntax
export enum ExperimentalFeature {
WRITABLE_RESOURCE_GRAPHQL = 'writable_resource_graphql',
TOLERANT_RESOURCE_TIMINGS = 'tolerant_resource_timings',
REMOTE_CONFIGURATION = 'remote_configuration',
UPDATE_VIEW_NAME = 'update_view_name',
NULL_INP_TELEMETRY = 'null_inp_telemetry',
LONG_ANIMATION_FRAME = 'long_animation_frame',
VIEW_SPECIFIC_CONTEXT = 'view_specific_context',
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import type { Duration, RelativeTime } from '@datadog/browser-core'
import { ExperimentalFeature, isIE, relativeToClocks } from '@datadog/browser-core'
import { mockExperimentalFeatures } from '@datadog/browser-core/test'
import { isIE, relativeToClocks } from '@datadog/browser-core'
import type { GlobalPerformanceBufferMock } from '../../../test'
import { createPerformanceEntry, mockGlobalPerformanceBuffer } from '../../../test'
import type { RumPerformanceResourceTiming } from '../../browser/performanceObservable'
Expand Down Expand Up @@ -144,7 +143,7 @@ describe('matchRequestResourceEntry', () => {
expect(matchingEntry).toEqual(undefined)
})

it('[without tolerant_resource_timings] should not match invalid entry nested in the request ', () => {
it('should not match invalid entry nested in the request ', () => {
const entry = createPerformanceEntry(RumPerformanceEntryType.RESOURCE, {
name: FAKE_URL,
// fetchStart < startTime is invalid
Expand All @@ -157,20 +156,4 @@ describe('matchRequestResourceEntry', () => {

expect(matchingEntry).toEqual(undefined)
})

it('[with tolerant_resource_timings] should match invalid entry nested in the request ', () => {
mockExperimentalFeatures([ExperimentalFeature.TOLERANT_RESOURCE_TIMINGS])
const entry = createPerformanceEntry(RumPerformanceEntryType.RESOURCE, {
name: FAKE_URL,
// fetchStart < startTime is invalid
fetchStart: 0 as RelativeTime,
startTime: 200 as RelativeTime,
})

globalPerformanceObjectMock.addPerformanceEntry(entry)

const matchingEntry = matchRequestResourceEntry(FAKE_REQUEST as RequestCompleteEvent)

expect(matchingEntry).toBeDefined()
})
})
20 changes: 3 additions & 17 deletions packages/rum-core/src/domain/resource/resourceUtils.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { ExperimentalFeature, type Duration, type RelativeTime, type ServerDuration } from '@datadog/browser-core'
import { mockExperimentalFeatures } from '@datadog/browser-core/test'
import { type Duration, type RelativeTime, type ServerDuration } from '@datadog/browser-core'
import { RumPerformanceEntryType, type RumPerformanceResourceTiming } from '../../browser/performanceObservable'
import type { RumConfiguration } from '../configuration'
import { mockRumConfiguration } from '../../../test'
Expand Down Expand Up @@ -199,37 +198,31 @@ describe('computeResourceEntryDetails', () => {
})
;[
{
timing: 'connect' as const,
reason: 'connectStart > connectEnd',
connectEnd: 10 as RelativeTime,
connectStart: 20 as RelativeTime,
},
{
timing: 'dns' as const,
reason: 'domainLookupStart > domainLookupEnd',
domainLookupEnd: 10 as RelativeTime,
domainLookupStart: 20 as RelativeTime,
},
{
timing: 'download' as const,
reason: 'responseStart > responseEnd',
responseEnd: 10 as RelativeTime,
responseStart: 20 as RelativeTime,
},
{
timing: 'first_byte' as const,
reason: 'requestStart > responseStart',
requestStart: 20 as RelativeTime,
responseStart: 10 as RelativeTime,
},
{
timing: 'redirect' as const,
reason: 'redirectStart > redirectEnd',
redirectEnd: 15 as RelativeTime,
redirectStart: 20 as RelativeTime,
},
{
timing: 'ssl' as const,
connectEnd: 10 as RelativeTime,
reason: 'secureConnectionStart > connectEnd',
secureConnectionStart: 20 as RelativeTime,
Expand All @@ -240,17 +233,10 @@ describe('computeResourceEntryDetails', () => {
fetchStart: 10 as RelativeTime,
reason: 'negative timing start',
},
].forEach(({ reason, timing, ...overrides }) => {
it(`[without tolerant-resource-timings] should not compute entry when ${reason}`, () => {
].forEach(({ reason, ...overrides }) => {
it(`should not compute entry when ${reason}`, () => {
expect(computeResourceEntryDetails(generateResourceWith(overrides))).toBeUndefined()
})

if (timing) {
it(`[with tolerant-resource-timings] should not include the '${timing}' timing when ${reason}`, () => {
mockExperimentalFeatures([ExperimentalFeature.TOLERANT_RESOURCE_TIMINGS])
expect(computeResourceEntryDetails(generateResourceWith(overrides))![timing]).toBeUndefined()
})
}
})

it('should allow really fast document resource', () => {
Expand Down
6 changes: 0 additions & 6 deletions packages/rum-core/src/domain/resource/resourceUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@ import type { RelativeTime, ServerDuration } from '@datadog/browser-core'
import {
addTelemetryDebug,
elapsed,
ExperimentalFeature,
getPathName,
includes,
isExperimentalFeatureEnabled,
isValidUrl,
ResourceType,
toServerDuration,
Expand Down Expand Up @@ -144,10 +142,6 @@ export function hasValidResourceEntryDuration(entry: RumPerformanceResourceTimin
}

export function hasValidResourceEntryTimings(entry: RumPerformanceResourceTiming) {
if (isExperimentalFeatureEnabled(ExperimentalFeature.TOLERANT_RESOURCE_TIMINGS)) {
return true
}

// Ensure timings are in the right order. On top of filtering out potential invalid
// RumPerformanceResourceTiming, it will ignore entries from requests where timings cannot be
// collected, for example cross origin requests without a "Timing-Allow-Origin" header allowing
Expand Down

0 comments on commit 307c91f

Please sign in to comment.