-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
feat(trace-tree-node): Mitigating SpanNode type guard usage #104481
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
Abdkhan14
merged 4 commits into
abdk/trace-tree-node-missing-ins-guards
from
abdk/trace-tree-node-span-node-guards
Dec 12, 2025
Merged
Changes from 3 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
b6ce85d
feat(trace-tree-node): Mitigating SpanNode type guard usage
0e96967
Merge branch 'abdk/trace-tree-node-missing-ins-guards' into abdk/trac…
dfe2925
feat(trace-tree-node): Fixing knip errors
d37e10f
feat(trace-tree-node): Mitigating eap span node type guards usage (#1…
Abdkhan14 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 |
|---|---|---|
| @@ -1,124 +1,40 @@ | ||
| import {useMemo} from 'react'; | ||
|
|
||
| import {ExternalLink} from 'sentry/components/core/link'; | ||
| import LoadingError from 'sentry/components/loadingError'; | ||
| import LoadingIndicator from 'sentry/components/loadingIndicator'; | ||
| import {t, tct} from 'sentry/locale'; | ||
| import type {EventTransaction} from 'sentry/types/event'; | ||
| import type {Project} from 'sentry/types/project'; | ||
| import useProjects from 'sentry/utils/useProjects'; | ||
| import {useTransaction} from 'sentry/views/performance/newTraceDetails/traceApi/useTransaction'; | ||
| import {getCustomInstrumentationLink} from 'sentry/views/performance/newTraceDetails/traceConfigurations'; | ||
| import {ProfilePreview} from 'sentry/views/performance/newTraceDetails/traceDrawer/details/profiling/profilePreview'; | ||
| import type {TraceTreeNodeDetailsProps} from 'sentry/views/performance/newTraceDetails/traceDrawer/tabs/traceTreeNodeDetails'; | ||
| import { | ||
| isEAPSpanNode, | ||
| isSpanNode, | ||
| } from 'sentry/views/performance/newTraceDetails/traceGuards'; | ||
| import type {EapSpanNode} from 'sentry/views/performance/newTraceDetails/traceModels/traceTreeNode/eapSpanNode'; | ||
| import type {NoInstrumentationNode} from 'sentry/views/performance/newTraceDetails/traceModels/traceTreeNode/noInstrumentationNode'; | ||
| import {ProfileGroupProvider} from 'sentry/views/profiling/profileGroupProvider'; | ||
| import {ProfileContext, ProfilesProvider} from 'sentry/views/profiling/profilesProvider'; | ||
|
|
||
| import {TraceDrawerComponents} from './styles'; | ||
| import {getProfileMeta} from './utils'; | ||
|
|
||
| interface BaseProps extends TraceTreeNodeDetailsProps<NoInstrumentationNode> { | ||
| event: EventTransaction | null; | ||
| profileId: string | undefined; | ||
| profileMeta: ReturnType<typeof getProfileMeta>; | ||
| profilerId: string | undefined; | ||
| project: Project | undefined; | ||
| } | ||
|
|
||
| export function MissingInstrumentationNodeDetails({ | ||
| ...props | ||
| }: TraceTreeNodeDetailsProps<NoInstrumentationNode>) { | ||
| const {node} = props; | ||
| const {projects} = useProjects(); | ||
| const previous = node.previous; | ||
|
|
||
| if (isEAPSpanNode(node.previous)) { | ||
| return <EAPMissingInstrumentationNodeDetails {...props} projects={projects} />; | ||
| } | ||
|
|
||
| if (isSpanNode(node.previous)) { | ||
| const event = node.previous.event; | ||
| const project = projects.find(proj => proj.slug === event?.projectSlug); | ||
| const profileMeta = getProfileMeta(event) || ''; | ||
| const profileContext = event?.contexts?.profile ?? {}; | ||
|
|
||
| return ( | ||
| <BaseMissingInstrumentationNodeDetails | ||
| {...props} | ||
| profileMeta={profileMeta} | ||
| project={project} | ||
| event={event} | ||
| profileId={profileContext.profile_id} | ||
| profilerId={profileContext.profiler_id} | ||
| /> | ||
| ); | ||
| } | ||
|
|
||
| return null; | ||
| } | ||
|
|
||
| function EAPMissingInstrumentationNodeDetails({ | ||
| projects, | ||
| ...props | ||
| }: TraceTreeNodeDetailsProps<NoInstrumentationNode> & { | ||
| projects: Project[]; | ||
| }) { | ||
| const {node} = props; | ||
| const previous = node.previous as EapSpanNode; | ||
|
|
||
| const { | ||
| data: eventTransaction = null, | ||
| isLoading: isEventTransactionLoading, | ||
| isError: isEventTransactionError, | ||
| } = useTransaction({ | ||
| event_id: previous.value.transaction_id, | ||
| const {data: eventTransaction = null} = useTransaction({ | ||
| event_id: previous.transactionId ?? '', | ||
| organization: props.organization, | ||
| project_slug: previous.value.project_slug, | ||
| project_slug: previous.projectSlug ?? '', | ||
|
Comment on lines
23
to
+27
This comment was marked as outdated.
Sorry, something went wrong.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Invalid
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We assign the parent's projectSlug for spanNodes. |
||
| }); | ||
|
|
||
| const profileMeta = useMemo( | ||
| () => getProfileMeta(eventTransaction) || '', | ||
| [eventTransaction] | ||
| ); | ||
|
|
||
| if (isEventTransactionLoading) { | ||
| return <LoadingIndicator />; | ||
| } | ||
|
|
||
| if (isEventTransactionError) { | ||
| return <LoadingError message={t('Failed to fetch span details')} />; | ||
| } | ||
|
|
||
| const project = projects.find(proj => proj.slug === eventTransaction?.projectSlug); | ||
| const profileContext = eventTransaction?.contexts?.profile ?? {}; | ||
|
|
||
| return ( | ||
| <BaseMissingInstrumentationNodeDetails | ||
| {...props} | ||
| profileMeta={profileMeta} | ||
| project={project} | ||
| event={eventTransaction} | ||
| profileId={profileContext.profile_id} | ||
| profilerId={profileContext.profiler_id} | ||
| /> | ||
| ); | ||
| } | ||
|
|
||
| function BaseMissingInstrumentationNodeDetails({ | ||
| node, | ||
| organization, | ||
| onTabScrollToNode, | ||
| profileMeta, | ||
| project, | ||
| event, | ||
| profileId, | ||
| profilerId, | ||
| }: BaseProps) { | ||
| return ( | ||
| <TraceDrawerComponents.DetailContainer> | ||
| <TraceDrawerComponents.HeaderContainer> | ||
|
|
@@ -135,8 +51,8 @@ function BaseMissingInstrumentationNodeDetails({ | |
| </TraceDrawerComponents.Title> | ||
| <TraceDrawerComponents.NodeActions | ||
| node={node} | ||
| organization={organization} | ||
| onTabScrollToNode={onTabScrollToNode} | ||
| organization={props.organization} | ||
| onTabScrollToNode={props.onTabScrollToNode} | ||
| /> | ||
| </TraceDrawerComponents.HeaderContainer> | ||
| <TraceDrawerComponents.BodyContainer> | ||
|
|
@@ -150,29 +66,31 @@ function BaseMissingInstrumentationNodeDetails({ | |
| } | ||
| )} | ||
| </p> | ||
| <ProfilesProvider | ||
| orgSlug={organization.slug} | ||
| projectSlug={event?.projectSlug ?? ''} | ||
| profileMeta={profileMeta || ''} | ||
| > | ||
| <ProfileContext.Consumer> | ||
| {profiles => ( | ||
| <ProfileGroupProvider | ||
| type="flamechart" | ||
| input={profiles?.type === 'resolved' ? profiles.data : null} | ||
| traceID={profileId ?? ''} | ||
| > | ||
| <ProfilePreview | ||
| project={project} | ||
| profileID={profileId} | ||
| profilerID={profilerId} | ||
| event={event} | ||
| missingInstrumentationNode={node} | ||
| /> | ||
| </ProfileGroupProvider> | ||
| )} | ||
| </ProfileContext.Consumer> | ||
| </ProfilesProvider> | ||
| {eventTransaction ? ( | ||
| <ProfilesProvider | ||
| orgSlug={props.organization.slug} | ||
| projectSlug={eventTransaction?.projectSlug ?? ''} | ||
| profileMeta={profileMeta || ''} | ||
| > | ||
| <ProfileContext.Consumer> | ||
| {profiles => ( | ||
| <ProfileGroupProvider | ||
| type="flamechart" | ||
| input={profiles?.type === 'resolved' ? profiles.data : null} | ||
| traceID={profileContext.profile_id ?? ''} | ||
| > | ||
| <ProfilePreview | ||
| project={project} | ||
| profileID={profileContext.profile_id ?? ''} | ||
| profilerID={profileContext.profiler_id ?? ''} | ||
| event={eventTransaction} | ||
| missingInstrumentationNode={node} | ||
| /> | ||
| </ProfileGroupProvider> | ||
| )} | ||
| </ProfileContext.Consumer> | ||
| </ProfilesProvider> | ||
| ) : null} | ||
| <p> | ||
| {t("If you'd prefer, you can also turn the feature off in the settings above.")} | ||
| </p> | ||
|
|
||
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
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.
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.
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.
Combined the two MissingInstrumentationNodeDetails to one.