@lwrjs/o11y 0.10.0-alpha.8 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{getInstrumentation as t}from"o11y/client";import{MODULE_DEFINE as e,MODULE_DEFINE_COUNT as r,BOOTSTRAP_END as n,BOOTSTRAP_DURATION as
|
|
1
|
+
import{getInstrumentation as t}from"o11y/client";import{MODULE_DEFINE as e,MODULE_DEFINE_COUNT as r,BOOTSTRAP_END as n,BOOTSTRAP_DURATION as i,MODULE_FETCH as s,MODULE_FETCH_DURATION as a,MAPPINGS_FETCH as o,MAPPINGS_FETCH_DURATION as c,INIT as m,INIT_MODULE as l,ROUTER_NAV as h,ROUTER_VIEW as u,INIT_DURATION as f,INIT_MODULE_DURATION as k,ROUTER_NAV_DURATION as g,ROUTER_VIEW_DURATION as p,BOOTSTRAP_ERROR as b,BOOTSTRAP_ERROR_COUNT as y,INIT_MODULE_COUNT as T,MODULE_FETCH_COUNT as d,MODULE_ERROR as v,MODULE_ERROR_COUNT as E,MAPPINGS_FETCH_COUNT as M,MAPPINGS_ERROR as O,MAPPINGS_ERROR_COUNT as W,ROUTER_NAV_COUNT as w,ROUTER_ERROR as V,ROUTER_ERROR_COUNT as j}from"lwr/metrics";const x=[s,o,m,l,h,u],C={[m]:f,[l]:k,[h]:g,[u]:p},F=Object.keys(C),B={[b]:y,[l]:T,[e]:r,[s]:d,[v]:E,[o]:M,[O]:W,[h]:w,[V]:j},L=Object.keys(B);class P{constructor(t,e){this.config=e||{},this.instrumentation=t}track(){this.trackExistingMarks(),this.setupObserver()}trackExistingMarks(){const t=performance.getEntriesByType("mark").filter((t=>t.name.startsWith(e)));t.length>0&&this.instrumentation.incrementCounter(r,t.length)}setupObserver(){new PerformanceObserver((t=>{t.getEntries().forEach((t=>{const{name:e,duration:r,startTime:m,entryType:l}=t,h=e.split("-")[0];if(e===n&&this.instrumentation.trackValue(i,m),"mark"===l){const e=t.detail||{},r=L.find((t=>t===h));r&&this.instrumentation.incrementCounter(B[r],1,!1,e)}if("measure"===l){const n=t.detail||{};this.config.enableModuleFetchTracking&&e.startsWith(s)&&this.instrumentation.trackValue(a,r,!1,n),this.config.enableMappingFetchTracking&&e.startsWith(o)&&this.instrumentation.trackValue(c,r,!1,n);const i=F.find((t=>t===h));i&&this.instrumentation.trackValue(C[i],r,!1,n)}x.some((t=>e.startsWith(t)))||performance.clearMarks(e)}))})).observe({entryTypes:["mark","measure"]})}}const R=void 0!==globalThis.performance&&"function"==typeof globalThis.performance.mark,q=globalThis.LWR,z={track:()=>{}};function A(e){const r=t("lwrjs"),n=q.metricsConfig||{};(R?new P(r,n):z).track()}export{A as default};
|
|
2
2
|
//# sourceMappingURL=o11yService.js.map
|
|
@@ -1,8 +1,15 @@
|
|
|
1
|
-
import { BOOTSTRAP_DURATION, BOOTSTRAP_END, BOOTSTRAP_ERROR, BOOTSTRAP_ERROR_COUNT, MAPPINGS_ERROR, MAPPINGS_ERROR_COUNT, MAPPINGS_FETCH, MAPPINGS_FETCH_COUNT, MAPPINGS_FETCH_DURATION, MODULE_DEFINE, MODULE_DEFINE_COUNT, MODULE_ERROR, MODULE_ERROR_COUNT, MODULE_FETCH, MODULE_FETCH_COUNT, MODULE_FETCH_DURATION, ROUTER_ERROR, ROUTER_ERROR_COUNT, ROUTER_NAV, ROUTER_NAV_COUNT, ROUTER_NAV_DURATION, ROUTER_VIEW, ROUTER_VIEW_DURATION } from 'lwr/metrics';
|
|
2
|
-
const doNotClear = [MODULE_FETCH, MAPPINGS_FETCH, ROUTER_NAV, ROUTER_VIEW];
|
|
3
|
-
const
|
|
1
|
+
import { BOOTSTRAP_DURATION, BOOTSTRAP_END, BOOTSTRAP_ERROR, BOOTSTRAP_ERROR_COUNT, INIT, INIT_DURATION, INIT_MODULE, INIT_MODULE_DURATION, INIT_MODULE_COUNT, MAPPINGS_ERROR, MAPPINGS_ERROR_COUNT, MAPPINGS_FETCH, MAPPINGS_FETCH_COUNT, MAPPINGS_FETCH_DURATION, MODULE_DEFINE, MODULE_DEFINE_COUNT, MODULE_ERROR, MODULE_ERROR_COUNT, MODULE_FETCH, MODULE_FETCH_COUNT, MODULE_FETCH_DURATION, ROUTER_ERROR, ROUTER_ERROR_COUNT, ROUTER_NAV, ROUTER_NAV_COUNT, ROUTER_NAV_DURATION, ROUTER_VIEW, ROUTER_VIEW_DURATION } from 'lwr/metrics';
|
|
2
|
+
const doNotClear = [MODULE_FETCH, MAPPINGS_FETCH, INIT, INIT_MODULE, ROUTER_NAV, ROUTER_VIEW];
|
|
3
|
+
const durationMap = {
|
|
4
|
+
[INIT]: INIT_DURATION,
|
|
5
|
+
[INIT_MODULE]: INIT_MODULE_DURATION,
|
|
6
|
+
[ROUTER_NAV]: ROUTER_NAV_DURATION,
|
|
7
|
+
[ROUTER_VIEW]: ROUTER_VIEW_DURATION
|
|
8
|
+
};
|
|
9
|
+
const metricsToTrack = Object.keys(durationMap);
|
|
4
10
|
const countMap = {
|
|
5
11
|
[BOOTSTRAP_ERROR]: BOOTSTRAP_ERROR_COUNT,
|
|
12
|
+
[INIT_MODULE]: INIT_MODULE_COUNT,
|
|
6
13
|
[MODULE_DEFINE]: MODULE_DEFINE_COUNT,
|
|
7
14
|
[MODULE_FETCH]: MODULE_FETCH_COUNT,
|
|
8
15
|
[MODULE_ERROR]: MODULE_ERROR_COUNT,
|
|
@@ -44,8 +51,10 @@ export class PerformanceApiSink {
|
|
|
44
51
|
const {
|
|
45
52
|
name,
|
|
46
53
|
duration,
|
|
47
|
-
startTime
|
|
54
|
+
startTime,
|
|
55
|
+
entryType
|
|
48
56
|
} = entry;
|
|
57
|
+
const id = name.split('-')[0];
|
|
49
58
|
|
|
50
59
|
// Track the bootstrap duration from navigation.start to lwr.bootstrap.end
|
|
51
60
|
if (name === BOOTSTRAP_END) {
|
|
@@ -53,20 +62,27 @@ export class PerformanceApiSink {
|
|
|
53
62
|
}
|
|
54
63
|
|
|
55
64
|
// Increment count metrics
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
65
|
+
if (entryType === 'mark') {
|
|
66
|
+
const metadata = entry.detail || {};
|
|
67
|
+
const metricToCount = metricsToCount.find(c => c === id);
|
|
68
|
+
if (metricToCount) {
|
|
69
|
+
this.instrumentation.incrementCounter(countMap[metricToCount], 1, false, metadata);
|
|
70
|
+
}
|
|
59
71
|
}
|
|
60
72
|
|
|
61
73
|
// Record duration metrics
|
|
62
|
-
if (
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
74
|
+
if (entryType === 'measure') {
|
|
75
|
+
const tags = entry.detail || {};
|
|
76
|
+
if (this.config.enableModuleFetchTracking && name.startsWith(MODULE_FETCH)) {
|
|
77
|
+
this.instrumentation.trackValue(MODULE_FETCH_DURATION, duration, false, tags);
|
|
78
|
+
}
|
|
79
|
+
if (this.config.enableMappingFetchTracking && name.startsWith(MAPPINGS_FETCH)) {
|
|
80
|
+
this.instrumentation.trackValue(MAPPINGS_FETCH_DURATION, duration, false, tags);
|
|
81
|
+
}
|
|
82
|
+
const metricToTrack = metricsToTrack.find(d => d === id);
|
|
83
|
+
if (metricToTrack) {
|
|
84
|
+
this.instrumentation.trackValue(durationMap[metricToTrack], duration, false, tags);
|
|
85
|
+
}
|
|
70
86
|
}
|
|
71
87
|
|
|
72
88
|
// Remove clearable marks
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
7
|
-
"version": "0.10.0
|
|
7
|
+
"version": "0.10.0",
|
|
8
8
|
"homepage": "https://developer.salesforce.com/docs/platform/lwr/overview",
|
|
9
9
|
"repository": {
|
|
10
10
|
"type": "git",
|
|
@@ -24,15 +24,15 @@
|
|
|
24
24
|
"build:bundle": "rollup --config scripts/rollup.moduleBundle.config.cjs"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@lwrjs/shared-utils": "0.10.0
|
|
27
|
+
"@lwrjs/shared-utils": "0.10.0"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
30
|
"@rollup/plugin-sucrase": "^5.0.1",
|
|
31
|
-
"@rollup/plugin-terser": "^0.4.
|
|
31
|
+
"@rollup/plugin-terser": "^0.4.3",
|
|
32
32
|
"rollup": "^2.78.0"
|
|
33
33
|
},
|
|
34
34
|
"peerDependencies": {
|
|
35
|
-
"o11y": "
|
|
35
|
+
"o11y": "246.x"
|
|
36
36
|
},
|
|
37
37
|
"lwc": {
|
|
38
38
|
"modules": [
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
]
|
|
49
49
|
},
|
|
50
50
|
"engines": {
|
|
51
|
-
"node": ">=16.0.0
|
|
51
|
+
"node": ">=16.0.0"
|
|
52
52
|
},
|
|
53
|
-
"gitHead": "
|
|
53
|
+
"gitHead": "e6deaeef3db8aa079acefed508897eca19b3218a"
|
|
54
54
|
}
|