You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by wu...@apache.org on 2022/04/06 08:32:41 UTC

[skywalking-client-js] branch master updated: fix: update fmp metric (#79)

This is an automated email from the ASF dual-hosted git repository.

wusheng pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/skywalking-client-js.git


The following commit(s) were added to refs/heads/master by this push:
     new 51a2b78  fix: update fmp metric (#79)
51a2b78 is described below

commit 51a2b78de968db0654c516028372c9f9328134ba
Author: Fine0830 <fi...@outlook.com>
AuthorDate: Wed Apr 6 16:32:34 2022 +0800

    fix: update fmp metric (#79)
---
 CHANGES.md               |  7 +++++++
 README.md                |  1 +
 src/performance/fmp.ts   | 17 +++--------------
 src/services/constant.ts | 20 ++------------------
 src/trace/type.d.ts      |  4 ++--
 5 files changed, 15 insertions(+), 34 deletions(-)

diff --git a/CHANGES.md b/CHANGES.md
index 44bcc33..54bb712 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -1,5 +1,12 @@
 # Changes
 
+## 0.8.0
+
+1. Fix fmp metric.
+2. Add e2e tese based on skywaling-infra-e2e.
+3. Update metric and events.
+4. Remove ServiceTag by following SkyWalking v9 new layer model.
+
 ## 0.7.0
 
 1. Support setting time interval to report segments.
diff --git a/README.md b/README.md
index b0ecfb3..9e01b64 100644
--- a/README.md
+++ b/README.md
@@ -8,6 +8,7 @@ Apache SkyWalking Client JS
 - Lightweight
 - Make browser as a start of whole distributed tracing
 
+NOTICE,  SkyWalking Client JS 0.8.0 and later versions require SkyWalking v9.
 # Usage
 
 ## Install  
diff --git a/src/performance/fmp.ts b/src/performance/fmp.ts
index 3bd2e00..df0132f 100644
--- a/src/performance/fmp.ts
+++ b/src/performance/fmp.ts
@@ -83,18 +83,7 @@ class FMPTiming {
       childList: true,
       subtree: true,
     });
-    // calculate score when page loaded
-    if (document.readyState === 'complete') {
-      this.calculateFinalScore();
-    } else {
-      window.addEventListener(
-        'load',
-        () => {
-          this.calculateFinalScore();
-        },
-        false,
-      );
-    }
+    this.calculateFinalScore();
   }
   private calculateFinalScore() {
     if (MutationEvent && this.flag) {
@@ -136,13 +125,13 @@ class FMPTiming {
       let time: number = 0;
       if (item.weight === 1) {
         const index: number = parseInt(item.ele.getAttribute('fmp_c'), 10);
-        time = this.statusCollector[index].time;
+        time = this.statusCollector[index] && this.statusCollector[index].time;
       } else if (item.weight === 2) {
         if (item.ele.tagName === 'IMG') {
           time = this.entries[(item.ele as HTMLImageElement).src];
         } else if (item.ele.tagName === 'SVG') {
           const index: number = parseInt(item.ele.getAttribute('fmp_c'), 10);
-          time = this.statusCollector[index].time;
+          time = this.statusCollector[index] && this.statusCollector[index].time;
         } else {
           const match = getStyle(item.ele, 'background-image').match(/url\(\"(.*?)\"\)/);
           let url: string = '';
diff --git a/src/services/constant.ts b/src/services/constant.ts
index 04135d9..7fb5922 100644
--- a/src/services/constant.ts
+++ b/src/services/constant.ts
@@ -37,27 +37,11 @@ export enum ReportTypes {
   SEGMENTS = '/v3/segments',
 }
 
-export enum SpanLayerType {
-  UNKNOWN = 0,
-  DATABASE = 1,
-  RPC_FRAMEWORK = 2,
-  HTTP = 3,
-  MQ = 4,
-  CACHE = 4,
-}
-
-export const SpanLayer = SpanLayerType.HTTP;
-
-export enum SpanTypeEnum {
-  ENTRY = 0,
-  EXIT = 1,
-  LOCAL = 2,
-}
+export const SpanLayer = 'Http';
+export const SpanType = 'Exit';
 
-export const SpanType = SpanTypeEnum.EXIT;
 export enum ReadyStatus {
   OPENED = 1,
   DONE = 4,
 }
 export const ComponentId = 10001; // ajax
-export const ServiceTag = '<browser>';
diff --git a/src/trace/type.d.ts b/src/trace/type.d.ts
index d253190..2e49bd6 100644
--- a/src/trace/type.d.ts
+++ b/src/trace/type.d.ts
@@ -28,8 +28,8 @@ export interface SpanFields {
   startTime: number;
   endTime: number;
   spanId: number;
-  spanLayer: number;
-  spanType: number;
+  spanLayer: string;
+  spanType: string;
   isError: boolean;
   parentSpanId: number;
   componentId: number;