-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
feat(tracing): Add long task collection #5529
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
Merged
Changes from 10 commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
a7995eb
rfc(perf): Add long task collection
k-fish 1df4bf1
Cleanup and add a playwright test
k-fish a0dd40d
Check for active transactions as long tasks occur, not ahead
k-fish ce4ad87
Prettier fix
k-fish 5a73d4d
Fix test
k-fish 5bebba4
Fix timestamp names in test
k-fish f662902
Fix names... again
k-fish 6206e04
Remove consoles from test suite mock script
k-fish 7a7ae98
Merge remote-tracking branch 'origin/master' into ref/add-long-task-c…
k-fish 53dc48d
Add span for long task in the transaction
k-fish fe9144a
Merge remote-tracking branch 'origin/master' into ref/add-long-task-c…
k-fish 54664a2
Remove extra span since it's likely just flaky, not a long task
k-fish 0b2c253
Temporarily improve error message to understand reason for test failure
k-fish e9a9d9e
Rearrange transaction count check
k-fish 7eef4a5
Fix newer syntax
k-fish 923dd66
See if removing the long task detection causes next tests to pass
k-fish ec58516
Also remove import
k-fish abf11dc
Wrap in try catch incase there is an internal error
k-fish be21d5d
Try again without try and extra logging since local is working
k-fish 8ae755c
Add origin to start time to stop flaking long tasks from appearing at…
k-fish b821c0f
Fix array contains needing exact matches for spans in transaction mat…
k-fish 5aa7b75
Add experiment flag as a way of disabling this feature, which can be …
k-fish 63a171c
Fix tests
k-fish d747811
Don't want to wait for eslint fix
k-fish 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
12 changes: 12 additions & 0 deletions
12
packages/integration-tests/suites/tracing/metrics/long-tasks/assets/script.js
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,12 @@ | ||
(() => { | ||
const startTime = Date.now(); | ||
|
||
function getElasped() { | ||
const time = Date.now(); | ||
return time - startTime; | ||
} | ||
|
||
while (getElasped() < 101) { | ||
// | ||
} | ||
})(); |
9 changes: 9 additions & 0 deletions
9
packages/integration-tests/suites/tracing/metrics/long-tasks/template.html
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,9 @@ | ||
<html> | ||
<head> | ||
<meta charset="utf-8" /> | ||
</head> | ||
<body> | ||
<div>Rendered Before Long Task</div> | ||
<script src="https://example.com/path/to/script.js"></script> | ||
</body> | ||
</html> |
36 changes: 36 additions & 0 deletions
36
packages/integration-tests/suites/tracing/metrics/long-tasks/test.ts
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,36 @@ | ||
import { expect, Route } from '@playwright/test'; | ||
import { Event } from '@sentry/types'; | ||
|
||
import { sentryTest } from '../../../../utils/fixtures'; | ||
import { getFirstSentryEnvelopeRequest } from '../../../../utils/helpers'; | ||
|
||
sentryTest('should capture long task.', async ({ browserName, getLocalTestPath, page }) => { | ||
// Long tasks only work on chrome | ||
if (browserName !== 'chromium') { | ||
sentryTest.skip(); | ||
} | ||
|
||
await page.route('**/path/to/script.js', (route: Route) => route.fulfill({ path: `${__dirname}/assets/script.js` })); | ||
|
||
const url = await getLocalTestPath({ testDir: __dirname }); | ||
|
||
const eventData = await getFirstSentryEnvelopeRequest<Event>(page, url); | ||
const uiSpans = eventData.spans?.filter(({ op }) => op?.startsWith('ui')); | ||
|
||
expect(uiSpans?.length).toBe(1); | ||
|
||
const [firstUISpan] = uiSpans || []; | ||
expect(firstUISpan).toEqual( | ||
expect.objectContaining({ | ||
op: 'ui.long-task', | ||
description: 'Long Task', | ||
parent_span_id: eventData.contexts?.trace.span_id, | ||
}), | ||
); | ||
const start = firstUISpan['start_timestamp'] ?? 0; | ||
const end = firstUISpan['timestamp'] ?? 0; | ||
const duration = end - start; | ||
|
||
expect(duration).toBeGreaterThanOrEqual(0.1); | ||
expect(duration).toBeLessThanOrEqual(0.15); | ||
}); |
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
woah :o