[No QA][Sentry] Filter out skeleton transactions based on desired duration#79357
[No QA][Sentry] Filter out skeleton transactions based on desired duration#79357rlinoz merged 6 commits intoExpensify:mainfrom
Conversation
Codecov Report✅ Changes either increased or maintained existing code coverage, great job!
|
|
@ShridharGoel Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button] |
| const minDurationFilter: TelemetryBeforeSend = (event) => { | ||
| // Check if the transaction (event) itself has a min_duration requirement | ||
| const eventMinDuration = event.contexts?.trace?.data?.[CONST.TELEMETRY.ATTRIBUTE_MIN_DURATION] as number; | ||
| if (eventMinDuration && !Number.isNaN(eventMinDuration)) { |
There was a problem hiding this comment.
can you untangle these if statements so we're not nesting them within each other? You can invert the boolean value checks and early return.
There was a problem hiding this comment.
this is not inline function so there is no place for early return but I've reduced amount of deep ifs. This should be more readable now
| const eventMinDuration = event.contexts?.trace?.data?.[CONST.TELEMETRY.ATTRIBUTE_MIN_DURATION] as number; | ||
| if (eventMinDuration && !Number.isNaN(eventMinDuration)) { | ||
| if (event.timestamp && event.start_timestamp) { | ||
| const eventDuration = (event.timestamp - event.start_timestamp) * 1000; |
There was a problem hiding this comment.
1000 should be even a file-scoped constant
There was a problem hiding this comment.
instead of creating a constant I moved this calculation to separate function so there is no repetiton
| const eventMinDuration = event.contexts?.trace?.data?.[CONST.TELEMETRY.ATTRIBUTE_MIN_DURATION] as number | undefined; | ||
|
|
||
| if (isValidMinDuration(eventMinDuration)) { | ||
| const eventDuration = calculateDuration(event.start_timestamp ?? 0, event.timestamp ?? 0); |
There was a problem hiding this comment.
You can do something like this instead of ?? 0:
if (!event.start_timestamp || !event.timestamp) {
// Can't calculate duration, so don't filter
return event;
}
There was a problem hiding this comment.
I ran some tests and I think we're safe to do so
| return true; | ||
| } | ||
|
|
||
| if (!span.timestamp) { |
There was a problem hiding this comment.
Do you think this can be changed to !span.start_timestamp || !span.timestamp ?
There was a problem hiding this comment.
I can, but start_timestamp is typed strictly to number in contrary to timestamp which can be undefined. Should I update this?
| import type {TelemetryBeforeSend} from './index'; | ||
|
|
||
| function isValidMinDuration(value: unknown): value is number { | ||
| return typeof value === 'number' && !Number.isNaN(value); |
There was a problem hiding this comment.
I have been wondering whether it is possible that the type of what we are setting is being changed somewhere, so value would be of type string or something...
I haven't find any evidence of that, but do you think we should check if it is string and try to parse it to number too? Or at least log it so we can update later.
There was a problem hiding this comment.
I've added a logic of parsing string, so I've changed isValidMinDuration to getValidMinDuration which handles both checking and parsing
|
@adhorodyski @rlinoz @ShridharGoel I've responded to all your comments |
|
PR doesn’t need product input as a tooling PR. Unassigning and unsubscribing myself. |
Reviewer Checklist
Screenshots/VideosAndroid: HybridAppAndroid: mWeb ChromeiOS: HybridAppiOS: mWeb SafariMacOS: Chrome / Safari |
|
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
|
🚀 Deployed to staging by https://github.com/rlinoz in version: 9.3.1-0 🚀
|
|
🚀 Deployed to production by https://github.com/francoisl in version: 9.3.1-1 🚀
|
Explanation of Change
This PR filters out transactions of
skeletonobjects based on the minDuration. Previous implementation focused only on child spans but there are cases where we have to treat transaction as a span.Fixed Issues
$ #74138
PROPOSAL:
Tests
To test this out I've disabled debugTransport in setup/telemetry/index.ts so all events are sent to Sentry. This can be skipped when testing on adhoc.
src/telemetry/middlewares/minDurationFilterto confirm that there is anytransactionwith nameManualSkeleton. This is crucial to test this out as sometimes spans are attached to other transactionsManualSkeletonOffline tests
QA Steps
// TODO: These must be filled out, or the issue title must include "[No QA]."
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectioncanBeMissingparam foruseOnyxtoggleReportand notonIconClick)src/languages/*files and using the translation methodSTYLE.md) were followedAvatar, I verified the components usingAvatarare working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))npm run compress-svg)Avataris modified, I verified thatAvataris working as expected in all cases)Designlabel and/or tagged@Expensify/designso the design team can review the changes.ScrollViewcomponent to make it scrollable when more elements are added to the page.mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps.Screenshots/Videos
Android: Native
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
ios.mov
MacOS: Chrome / Safari
dev.mov