-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
feat(core): Deprecate Span.transaction
in favor of getRootSpan
#10134
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
61be37b
wip
Lms24 a0efb9b
replace usages/add eslint ignores in core
Lms24 31126f3
move to dedicated file
Lms24 9298b76
replace span.transaction usages in other packages
Lms24 9b721b1
migration
Lms24 c2c20b1
add core as a dep of @sentry/svelte
Lms24 5131d02
fix rebase ??
Lms24 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 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 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 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 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 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 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 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 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 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 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,15 @@ | ||
import type { Span } from '@sentry/types'; | ||
|
||
/** | ||
* Returns the root span of a given span. | ||
* | ||
* As long as we use `Transaction`s internally, the returned root span | ||
* will be a `Transaction` but be aware that this might change in the future. | ||
* | ||
* If the given span has no root span or transaction, `undefined` is returned. | ||
*/ | ||
export function getRootSpan(span: Span): Span | undefined { | ||
// TODO (v8): Remove this check and just return span | ||
// eslint-disable-next-line deprecation/deprecation | ||
return span.transaction; | ||
} |
This file contains 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 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 { Span, Transaction, getRootSpan } from '../../../src'; | ||
|
||
describe('getRootSpan', () => { | ||
it('returns the root span of a span (Span)', () => { | ||
const root = new Span({ name: 'test' }); | ||
// @ts-expect-error this is highly illegal and shouldn't happen IRL | ||
// eslint-disable-next-line deprecation/deprecation | ||
root.transaction = root; | ||
|
||
// eslint-disable-next-line deprecation/deprecation | ||
const childSpan = root.startChild({ name: 'child' }); | ||
expect(getRootSpan(childSpan)).toBe(root); | ||
}); | ||
|
||
it('returns the root span of a span (Transaction)', () => { | ||
// eslint-disable-next-line deprecation/deprecation | ||
const root = new Transaction({ name: 'test' }); | ||
|
||
// eslint-disable-next-line deprecation/deprecation | ||
const childSpan = root.startChild({ name: 'child' }); | ||
expect(getRootSpan(childSpan)).toBe(root); | ||
}); | ||
|
||
it('returns the span itself if it is a root span', () => { | ||
// eslint-disable-next-line deprecation/deprecation | ||
const span = new Transaction({ name: 'test' }); | ||
|
||
expect(getRootSpan(span)).toBe(span); | ||
}); | ||
|
||
it('returns undefined if span has no root span', () => { | ||
const span = new Span({ name: 'test' }); | ||
|
||
expect(getRootSpan(span)).toBe(undefined); | ||
}); | ||
}); |
This file contains 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 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 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 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 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 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 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.
Is there even a todo for v8 here? Won't we get rid of the transaction class?
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.
Hmm I mean we somehow still need to construct a transaction for the event payload so I guess it's not gonna vanish completely. We'll just need some way to set and find the root span/txn of a span in v8.