From 7bd957e4e16edbba0fd5f17b4e49c6c34653ba53 Mon Sep 17 00:00:00 2001 From: Diljit VJ Date: Fri, 20 Sep 2024 18:32:51 +0530 Subject: [PATCH 1/3] chore: fix a method binding bug in PageLoadInstrumentation --- app/client/src/UITelemetry/PageLoadInstrumentation.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/client/src/UITelemetry/PageLoadInstrumentation.ts b/app/client/src/UITelemetry/PageLoadInstrumentation.ts index ccb173d0b4a..4ffee58eac4 100644 --- a/app/client/src/UITelemetry/PageLoadInstrumentation.ts +++ b/app/client/src/UITelemetry/PageLoadInstrumentation.ts @@ -51,10 +51,10 @@ export class PageLoadInstrumentation extends InstrumentationBase { enable(): void { // Register connection change listener - this.addConnectionAttributes(); + this.addConnectionAttributes.call(this); // Add device attributes to the root span - this.addDeviceAttributes(); + this.addDeviceAttributes.call(this); // Listen for LCP and FCP events // reportAllChanges: true will report all LCP and FCP events From e1b888a34e843077407ba433a228192f1a1a496f Mon Sep 17 00:00:00 2001 From: Diljit VJ Date: Fri, 20 Sep 2024 19:02:33 +0530 Subject: [PATCH 2/3] Convert enable to an arrow fn --- app/client/src/UITelemetry/PageLoadInstrumentation.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/client/src/UITelemetry/PageLoadInstrumentation.ts b/app/client/src/UITelemetry/PageLoadInstrumentation.ts index 4ffee58eac4..e60ba8904a9 100644 --- a/app/client/src/UITelemetry/PageLoadInstrumentation.ts +++ b/app/client/src/UITelemetry/PageLoadInstrumentation.ts @@ -49,12 +49,12 @@ export class PageLoadInstrumentation extends InstrumentationBase { // Leaving it empty as it is done by other OpenTelemetry instrumentation classes } - enable(): void { + enable = () => { // Register connection change listener - this.addConnectionAttributes.call(this); + this.addConnectionAttributes(); // Add device attributes to the root span - this.addDeviceAttributes.call(this); + this.addDeviceAttributes(); // Listen for LCP and FCP events // reportAllChanges: true will report all LCP and FCP events @@ -69,7 +69,7 @@ export class PageLoadInstrumentation extends InstrumentationBase { // If PerformanceObserver is not available, fallback to polling this.pollResourceTimingEntries(); } - } + }; private addDeviceAttributes() { this.rootSpan.setAttributes({ From d40ebc114f47e6ee1748748f3ec18a3dcc7e685f Mon Sep 17 00:00:00 2001 From: Diljit VJ Date: Fri, 20 Sep 2024 19:44:54 +0530 Subject: [PATCH 3/3] move all methods to init --- .../src/UITelemetry/PageLoadInstrumentation.ts | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/app/client/src/UITelemetry/PageLoadInstrumentation.ts b/app/client/src/UITelemetry/PageLoadInstrumentation.ts index e60ba8904a9..801038068b1 100644 --- a/app/client/src/UITelemetry/PageLoadInstrumentation.ts +++ b/app/client/src/UITelemetry/PageLoadInstrumentation.ts @@ -41,15 +41,12 @@ export class PageLoadInstrumentation extends InstrumentationBase { this.ignoreResourceUrls = ignoreResourceUrls; // Start the root span for the page load this.rootSpan = startRootSpan("PAGE_LOAD", {}, 0); - } - init() { - // init method is present in the base class and needs to be implemented - // This is method is never called by the OpenTelemetry SDK - // Leaving it empty as it is done by other OpenTelemetry instrumentation classes + // Initialize the instrumentation after starting the root span + this.init(); } - enable = () => { + init() { // Register connection change listener this.addConnectionAttributes(); @@ -69,7 +66,12 @@ export class PageLoadInstrumentation extends InstrumentationBase { // If PerformanceObserver is not available, fallback to polling this.pollResourceTimingEntries(); } - }; + } + + enable() { + // enable method is present in the base class and needs to be implemented + // Leaving it empty as there is no need to do anything here + } private addDeviceAttributes() { this.rootSpan.setAttributes({