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

🔊🐛 [RUMF-201] add internal logs for abnormal timeOrigin #219

Merged
merged 3 commits into from
Dec 20, 2019
Merged
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
18 changes: 17 additions & 1 deletion packages/rum/src/performanceCollection.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { getRelativeTime, monitor } from '@datadog/browser-core'
import { addMonitoringMessage, getRelativeTime, monitor } from '@datadog/browser-core'

import { LifeCycle, LifeCycleEventType } from './lifeCycle'
import { RumSession } from './rumSession'
import { viewContext } from './viewTracker'

interface BrowserWindow extends Window {
PerformanceObserver?: PerformanceObserver
Expand Down Expand Up @@ -51,8 +52,23 @@ interface FakePerformanceNavigationTiming {
loadEventEnd: number
}

function reportAbnormalTimeOrigin() {
if (getRelativeTime(performance.timing.loadEventEnd) > 86400e3 /* 1 day in ms */) {
addMonitoringMessage(
`Got an abnormal loadEventEnd timing
Session Id: ${viewContext.sessionId}
View Id: ${viewContext.id}
timeOrigin: ${performance.timeOrigin}
navigationStart: ${performance.timing.navigationStart}
loadEventEnd: ${performance.timing.loadEventEnd}
timing: ${getRelativeTime(performance.timing.loadEventEnd)}`
)
}
}

function retrieveNavigationTimingWhenLoaded(callback: (timing: PerformanceNavigationTiming) => void) {
function sendFakeTiming() {
reportAbnormalTimeOrigin()
const timing: FakePerformanceNavigationTiming = {
domComplete: getRelativeTime(performance.timing.domComplete),
domContentLoadedEventEnd: getRelativeTime(performance.timing.domContentLoadedEventEnd),
Expand Down