-
Notifications
You must be signed in to change notification settings - Fork 39
add session time components instrumentation #145
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
suryart
merged 7 commits into
browserstack:master
from
shashikdm:AUT-3792-instrumentation-changes
Jul 23, 2021
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
5af03fb
add session time components instrumentation
104fbc0
add specs for time components
bcd7fa3
* bug fixes
f6c9a18
revamp session time components and add auto local usage
8abd3cf
add total time and whitespace fixes
4e1d2e8
fix timeComponents logic and add zip breakup
3d779cb
add missing instrumentation
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,3 +8,4 @@ package-lock.json | |
.env.* | ||
log/*.log | ||
results/* | ||
coverage |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
'use strict' | ||
|
||
const { isUndefined } = require('./utils'); | ||
|
||
let sessionTimes = { | ||
referenceTimes: { | ||
absoluteStartTime: Date.now() | ||
}, // Absolute times which needs to be used later to calculate logTimes | ||
logTimes: {}, // Time Difference in ms which we need to push to EDS | ||
}; | ||
|
||
const initTimeComponents = () => { | ||
sessionTimes = {referenceTimes: {absoluteStartTime: Date.now()}, logTimes: {}}; | ||
karanshah-browserstack marked this conversation as resolved.
Show resolved
Hide resolved
|
||
}; | ||
|
||
const markBlockStart = (blockName) => { | ||
sessionTimes.referenceTimes[blockName] = Date.now(); | ||
}; | ||
|
||
const markBlockEnd = (blockName) => { | ||
const startTime = sessionTimes.referenceTimes[blockName] || sessionTimes.referenceTimes.absoluteStartTime; | ||
markBlockDiff(blockName, startTime, Date.now()); | ||
}; | ||
|
||
const markBlockDiff = (blockName, startTime, stopTime) => { | ||
sessionTimes.logTimes[blockName] = stopTime - startTime; | ||
} | ||
|
||
const getTimeComponents = () => { | ||
const data = convertDotToNestedObject(sessionTimes.logTimes); | ||
|
||
return data; | ||
}; | ||
|
||
const convertDotToNestedObject = (dotNotationObject) => { | ||
let nestedObject = {}; | ||
|
||
Object.keys(dotNotationObject).forEach((key) => { | ||
let dotKeys = key.split('.'); | ||
let currentKey = nestedObject; | ||
for(let i = 0; i < dotKeys.length - 1; i++) { | ||
if (isUndefined(currentKey[dotKeys[i]])) { | ||
currentKey[dotKeys[i]] = {}; | ||
} else if (Number.isInteger(currentKey[dotKeys[i]])) { | ||
currentKey[dotKeys[i]] = {total: currentKey[dotKeys[i]]}; | ||
} | ||
currentKey = currentKey[dotKeys[i]]; | ||
} | ||
if (isUndefined(currentKey[dotKeys[dotKeys.length - 1]]) || Number.isInteger(currentKey[dotKeys[dotKeys.length - 1]])) { | ||
currentKey[dotKeys[dotKeys.length - 1]] = dotNotationObject[key]; | ||
} else { | ||
currentKey[dotKeys[dotKeys.length - 1]].total = dotNotationObject[key]; | ||
} | ||
}); | ||
|
||
return nestedObject; | ||
}; | ||
|
||
module.exports = { | ||
initTimeComponents, | ||
markBlockStart, | ||
markBlockEnd, | ||
markBlockDiff, | ||
getTimeComponents, | ||
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.