From 43fefa8b8d11885e2ce798ad886ffcd2ffd07958 Mon Sep 17 00:00:00 2001 From: Jordan Porter Date: Sun, 25 Aug 2024 14:53:06 -0600 Subject: [PATCH] adjust tags to match --- docs/supportability-metrics.md | 17 +++++++++++++---- src/common/wrap/wrap-websocket.js | 2 +- .../metrics/aggregate/websocket-detection.js | 4 +++- 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/docs/supportability-metrics.md b/docs/supportability-metrics.md index a86a4c8f2..ab6a99842 100644 --- a/docs/supportability-metrics.md +++ b/docs/supportability-metrics.md @@ -30,13 +30,22 @@ A timeslice metric is harvested to the JSE/XHR consumer. An aggregation service * WebSocket/Send/PostLoad/Bytes -* WebSocket/Close/PreLoad/Ms +* WebSocket/Close-Method/PreLoad/Ms -* WebSocket/Close/Preload/MsSinceClassInit +* WebSocket/Close-Method/Preload/MsSinceClassInit -* WebSocket/Close/PostLoad/Ms +* WebSocket/Close-Method/PostLoad/Ms -* WebSocket/Close/PostLoad/MsSinceClassInit +* WebSocket/Close-Method/PostLoad/MsSinceClassInit + + +* WebSocket/Close-Event/PreLoad/Ms + +* WebSocket/Close-Event/Preload/MsSinceClassInit + +* WebSocket/Close-Event/PostLoad/Ms + +* WebSocket/Close-Event/PostLoad/MsSinceClassInit * WebSocket/Message/PreLoad/Ms diff --git a/src/common/wrap/wrap-websocket.js b/src/common/wrap/wrap-websocket.js index 2420204ff..fac4da242 100644 --- a/src/common/wrap/wrap-websocket.js +++ b/src/common/wrap/wrap-websocket.js @@ -30,7 +30,7 @@ export function wrapWebSocket (sharedEE) { const report = reporter() report('new') - const events = ['message', 'error', 'open'] // could also watch the "close" AEL if we wanted to, but we are already watching the static method + const events = ['message', 'error', 'open', 'close'] // could also watch the "close" AEL if we wanted to, but we are already watching the static method /** add event listeners */ events.forEach(evt => { ws.addEventListener(evt, function (e) { diff --git a/src/features/metrics/aggregate/websocket-detection.js b/src/features/metrics/aggregate/websocket-detection.js index 395d05f9d..0b566f8b2 100644 --- a/src/features/metrics/aggregate/websocket-detection.js +++ b/src/features/metrics/aggregate/websocket-detection.js @@ -3,7 +3,9 @@ import { toTitleCase } from '../../../common/util/text' import { ADD_EVENT_LISTENER_TAG } from '../../../common/wrap/wrap-websocket' export function handleWebsocketEvents (reporter, tag, timestamp, timeSinceInit, isLoaded, data) { - const metricTag = toTitleCase(tag === ADD_EVENT_LISTENER_TAG ? data.eventType : tag) + const useDataType = tag === ADD_EVENT_LISTENER_TAG + let metricTag = toTitleCase(useDataType ? data.eventType : tag) + if (metricTag === 'Close') metricTag += (useDataType ? '-Event' : '-Method') const bytes = (metricTag === 'Message' && dataSize(data?.event?.data)) || (metricTag === 'Send' && dataSize(data)) reporter(buildSMTag(metricTag, 'Ms', isLoaded), timestamp) reporter(buildSMTag(metricTag, 'MsSinceClassInit', isLoaded), timeSinceInit)