From 5e07f98fcc6d9efe362fe24d076f1ba8f06d3da1 Mon Sep 17 00:00:00 2001 From: Bastien Caudan Date: Fri, 4 Jun 2021 18:16:39 +0200 Subject: [PATCH 1/2] enable monitoring for sandbox --- sandbox/index.html | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sandbox/index.html b/sandbox/index.html index cdcc25f199..cb76820951 100644 --- a/sandbox/index.html +++ b/sandbox/index.html @@ -9,9 +9,11 @@ DD_RUM.init({ clientToken: 'xxx', applicationId: 'xxx', + internalMonitoringApiKey: 'xxx', }) DD_LOGS.init({ clientToken: 'xxx', + internalMonitoringApiKey: 'xxx', }) From 6667ae79de447e7aa1afa368622fd7c669b72136 Mon Sep 17 00:00:00 2001 From: Bastien Caudan Date: Fri, 4 Jun 2021 18:17:17 +0200 Subject: [PATCH 2/2] monitor high lcp, fcp, resource.duration values --- packages/core/src/tools/utils.ts | 1 + .../resource/resourceUtils.ts | 17 ++++++++++ .../view/trackInitialViewTimings.ts | 31 ++++++++++++++++++- 3 files changed, 48 insertions(+), 1 deletion(-) diff --git a/packages/core/src/tools/utils.ts b/packages/core/src/tools/utils.ts index 8a0f78c8e4..6f5d72cc73 100644 --- a/packages/core/src/tools/utils.ts +++ b/packages/core/src/tools/utils.ts @@ -3,6 +3,7 @@ import { monitor } from '../domain/internalMonitoring' export const ONE_SECOND = 1000 export const ONE_MINUTE = 60 * ONE_SECOND export const ONE_HOUR = 60 * ONE_MINUTE +export const ONE_DAY = 24 * ONE_HOUR export const ONE_KILO_BYTE = 1024 export const enum DOM_EVENT { diff --git a/packages/rum-core/src/domain/rumEventsCollection/resource/resourceUtils.ts b/packages/rum-core/src/domain/rumEventsCollection/resource/resourceUtils.ts index 10ae559604..de66f67aad 100644 --- a/packages/rum-core/src/domain/rumEventsCollection/resource/resourceUtils.ts +++ b/packages/rum-core/src/domain/rumEventsCollection/resource/resourceUtils.ts @@ -9,6 +9,9 @@ import { ResourceType, ServerDuration, toServerDuration, + ONE_DAY, + relativeNow, + timeStampNow, } from '@datadog/browser-core' import { RumPerformanceResourceTiming } from '../../../browser/performanceCollection' @@ -82,6 +85,20 @@ export function computePerformanceResourceDuration(entry: RumPerformanceResource return toServerDuration(elapsed(startTime, responseEnd)) } + if (duration > ONE_DAY) { + addMonitoringMessage('resource duration > 1 day', { + debug: { + type: entry.initiatorType, + name: entry.name, + startTime: Math.round(startTime), + responseEnd: Math.round(responseEnd), + duration: Math.round(duration), + relativeNow: Math.round(relativeNow()), + timeStampNow: timeStampNow(), + }, + }) + } + return toServerDuration(duration) } diff --git a/packages/rum-core/src/domain/rumEventsCollection/view/trackInitialViewTimings.ts b/packages/rum-core/src/domain/rumEventsCollection/view/trackInitialViewTimings.ts index 1a640ab807..16e37da771 100644 --- a/packages/rum-core/src/domain/rumEventsCollection/view/trackInitialViewTimings.ts +++ b/packages/rum-core/src/domain/rumEventsCollection/view/trackInitialViewTimings.ts @@ -1,4 +1,15 @@ -import { addEventListeners, DOM_EVENT, Duration, elapsed, EventEmitter, RelativeTime } from '@datadog/browser-core' +import { + addEventListeners, + DOM_EVENT, + Duration, + elapsed, + EventEmitter, + RelativeTime, + ONE_DAY, + addMonitoringMessage, + relativeNow, + timeStampNow, +} from '@datadog/browser-core' import { LifeCycle, LifeCycleEventType } from '../../lifeCycle' import { trackFirstHidden } from './trackFirstHidden' @@ -69,6 +80,15 @@ export function trackFirstContentfulPaint(lifeCycle: LifeCycle, callback: (fcp: entry.name === 'first-contentful-paint' && entry.startTime < firstHidden.timeStamp ) { + if (entry.startTime > ONE_DAY) { + addMonitoringMessage('FCP > 1 day', { + debug: { + fcp: Math.round(entry.startTime), + relativeNow: Math.round(relativeNow()), + timeStampNow: timeStampNow(), + }, + }) + } callback(entry.startTime) } }) @@ -109,6 +129,15 @@ export function trackLargestContentfulPaint( entry.startTime < firstInteractionTimestamp && entry.startTime < firstHidden.timeStamp ) { + if (entry.startTime > ONE_DAY) { + addMonitoringMessage('LCP > 1 day', { + debug: { + lcp: Math.round(entry.startTime), + relativeNow: Math.round(relativeNow()), + timeStampNow: timeStampNow(), + }, + }) + } callback(entry.startTime) } }