Skip to content

Commit

Permalink
adjust tags to match
Browse files Browse the repository at this point in the history
  • Loading branch information
metal-messiah committed Aug 25, 2024
1 parent b680375 commit 43fefa8
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
17 changes: 13 additions & 4 deletions docs/supportability-metrics.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,22 @@ A timeslice metric is harvested to the JSE/XHR consumer. An aggregation service
* WebSocket/Send/PostLoad/Bytes

<!--- WebSocket close method was called before the page loaded, ms from page origin --->
* WebSocket/Close/PreLoad/Ms
* WebSocket/Close-Method/PreLoad/Ms
<!--- WebSocket close method was called before the page loaded, ms from class init --->
* WebSocket/Close/Preload/MsSinceClassInit
* WebSocket/Close-Method/Preload/MsSinceClassInit
<!--- WebSocket close method was called after the page loaded, ms from page origin --->
* WebSocket/Close/PostLoad/Ms
* WebSocket/Close-Method/PostLoad/Ms
<!--- WebSocket close method was called after the page loaded, ms from class init --->
* WebSocket/Close/PostLoad/MsSinceClassInit
* WebSocket/Close-Method/PostLoad/MsSinceClassInit

<!--- WebSocket close event was received before the page loaded, ms from page origin --->
* WebSocket/Close-Event/PreLoad/Ms
<!--- WebSocket close event was received before the page loaded, ms from class init --->
* WebSocket/Close-Event/Preload/MsSinceClassInit
<!--- WebSocket close event was received after the page loaded, ms from page origin --->
* WebSocket/Close-Event/PostLoad/Ms
<!--- WebSocket close event was received after the page loaded, ms from class init --->
* WebSocket/Close-Event/PostLoad/MsSinceClassInit

<!--- WebSocket message event was received before the page loaded, ms from page origin --->
* WebSocket/Message/PreLoad/Ms
Expand Down
2 changes: 1 addition & 1 deletion src/common/wrap/wrap-websocket.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
4 changes: 3 additions & 1 deletion src/features/metrics/aggregate/websocket-detection.js
Original file line number Diff line number Diff line change
Expand Up @@ -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

Check warning on line 6 in src/features/metrics/aggregate/websocket-detection.js

View check run for this annotation

Codecov / codecov/patch

src/features/metrics/aggregate/websocket-detection.js#L5-L6

Added lines #L5 - L6 were not covered by tests
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)

Check warning on line 11 in src/features/metrics/aggregate/websocket-detection.js

View check run for this annotation

Codecov / codecov/patch

src/features/metrics/aggregate/websocket-detection.js#L10-L11

Added lines #L10 - L11 were not covered by tests
Expand Down

0 comments on commit 43fefa8

Please sign in to comment.