Skip to content

Commit

Permalink
Revert "ref: add threadId to continuous profile link (#74730)"
Browse files Browse the repository at this point in the history
This reverts commit 6e76430.

Co-authored-by: JonasBa <9317857+JonasBa@users.noreply.github.com>
  • Loading branch information
getsentry-bot and JonasBa committed Jul 24, 2024
1 parent 6065a6d commit a9de22b
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 50 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ import type {
} from 'sentry/views/performance/newTraceDetails/traceModels/traceTree';

interface UseTransactionProps {
node: TraceTreeNode<TraceTree.Transaction> | null;
node: TraceTreeNode<TraceTree.Transaction>;
organization: Organization;
}

export function useTransaction(props: UseTransactionProps) {
return useApiQuery<EventTransaction>(
[
`/organizations/${props.organization.slug}/events/${props.node?.value?.project_slug}:${props?.node?.value.event_id}/`,
`/organizations/${props.organization.slug}/events/${props.node.value.project_slug}:${props.node.value.event_id}/`,
{
query: {
referrer: 'trace-details-summary',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,12 @@ export function SpanNodeDetails({
}: TraceTreeNodeDetailsProps<TraceTreeNode<TraceTree.Span>>) {
const location = useLocation();
const {projects} = useProjects();
const {event} = node.value;
const issues = useMemo(() => {
return [...node.errors, ...node.performance_issues];
}, [node.errors, node.performance_issues]);

const project = projects.find(proj => proj.slug === node.value.event?.projectSlug);
const profileId = node.value.event?.contexts?.profile?.profile_id ?? null;
const project = projects.find(proj => proj.slug === event?.projectSlug);
const profileId = event?.contexts?.profile?.profile_id ?? null;

return (
<TraceDrawerComponents.DetailContainer>
Expand All @@ -91,10 +91,10 @@ export function SpanNodeDetails({
project={project}
onTabScrollToNode={onTabScrollToNode}
/>
{node.value.event.projectSlug ? (
{event.projectSlug ? (
<ProfilesProvider
orgSlug={organization.slug}
projectSlug={node.value.event.projectSlug}
projectSlug={event.projectSlug}
profileId={profileId || ''}
>
<ProfileContext.Consumer>
Expand Down Expand Up @@ -129,9 +129,9 @@ export function SpanNodeDetails({
startTimestamp={node.value.start_timestamp}
/>
</TraceDrawerComponents.SectionCardGroup>
<EventContexts event={node.value.event} />
<EventContexts event={event} />
{organization.features.includes('profiling') ? (
<SpanProfileDetails span={node.value} event={node.value.event} />
<SpanProfileDetails span={node.value} event={event} />
) : null}
</ProfileGroupProvider>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ import {
isTransactionNode,
} from 'sentry/views/performance/newTraceDetails/guards';
import {traceAnalytics} from 'sentry/views/performance/newTraceDetails/traceAnalytics';
import {useTransaction} from 'sentry/views/performance/newTraceDetails/traceApi/useTransaction';
import {makeTraceContinuousProfilingLink} from 'sentry/views/performance/newTraceDetails/traceDrawer/traceProfilingLink';
import type {
MissingInstrumentationNode,
Expand Down Expand Up @@ -330,21 +329,6 @@ const ValueTd = styled('td')`
position: relative;
`;

function getThreadIdFromNode(
node: TraceTreeNode<TraceTree.NodeValue>,
transaction: EventTransaction | undefined
): string | undefined {
if (isSpanNode(node) && node.value.data['thread.id']) {
return node.value.data['thread.id'];
}

if (transaction) {
return transaction.context?.trace?.data?.['thread.id'];
}

return undefined;
}

function NodeActions(props: {
node: TraceTreeNode<any>;
onTabScrollToNode: (
Expand Down Expand Up @@ -425,17 +409,12 @@ function NodeActions(props: {
return '';
}, [props]);

const {data: transaction} = useTransaction({
node: isTransactionNode(props.node) ? props.node : null,
organization,
});

const params = useParams<{traceSlug?: string}>();

const profileLink = makeTraceContinuousProfilingLink(props.node, profilerId, {
orgSlug: props.organization.slug,
projectSlug: props.node.metadata.project_slug ?? '',
traceId: params.traceSlug ?? '',
threadId: getThreadIdFromNode(props.node, transaction),
});

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ describe('traceProfilingLink', () => {
projectSlug: 'project',
orgSlug: '',
traceId: '',
threadId: '0',
})
).toBeNull();
});
Expand All @@ -48,7 +47,6 @@ describe('traceProfilingLink', () => {
projectSlug: '',
orgSlug: 'sentry',
traceId: '',
threadId: '0',
})
).toBeNull();
});
Expand Down Expand Up @@ -86,7 +84,6 @@ describe('traceProfilingLink', () => {
projectSlug: 'project',
orgSlug: 'sentry',
traceId: 'trace',
threadId: '0',
}
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ export function makeTraceContinuousProfilingLink(
options: {
orgSlug: string;
projectSlug: string;
threadId: string | undefined;
traceId: string;
},
query: Location['query'] = {}
Expand Down Expand Up @@ -95,19 +94,15 @@ export function makeTraceContinuousProfilingLink(
return null;
}

const queryWithEventData: Record<string, string> = {
const queryWithSpanIdAndTraceId: Record<string, string> = {
...query,
eventId,
traceId: options.traceId,
};

if (typeof options.threadId === 'string') {
queryWithEventData.tid = options.threadId;
}

const spanId = getNodeId(node);
if (spanId) {
queryWithEventData.spanId = spanId;
queryWithSpanIdAndTraceId.spanId = spanId;
}

return generateContinuousProfileFlamechartRouteWithQuery(
Expand All @@ -116,6 +111,6 @@ export function makeTraceContinuousProfilingLink(
profilerId,
start.toISOString(),
end.toISOString(),
queryWithEventData
queryWithSpanIdAndTraceId
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -119,12 +119,11 @@ import {TraceType} from '../traceType';
type ArgumentTypes<F> = F extends (...args: infer A) => any ? A : never;

export declare namespace TraceTree {
interface RawSpan extends RawSpanType {}
interface Transaction extends TraceFullDetailed {
profiler_id: string;
sdk_name: string;
}
interface Span extends RawSpan {
interface Span extends RawSpanType {
childTransactions: TraceTreeNode<TraceTree.Transaction>[];
event: EventTransaction;
measurements?: Record<string, Measurement>;
Expand All @@ -139,14 +138,14 @@ export declare namespace TraceTree {
timestamp: number;
type: 'missing_instrumentation';
}
interface SiblingAutogroup extends RawSpan {
interface SiblingAutogroup extends RawSpanType {
autogrouped_by: {
description: string;
op: string;
};
}

interface ChildrenAutogroup extends RawSpan {
interface ChildrenAutogroup extends RawSpanType {
autogrouped_by: {
op: string;
};
Expand Down Expand Up @@ -867,7 +866,7 @@ export class TraceTree {
static FromSpans(
parent: TraceTreeNode<TraceTree.NodeValue>,
data: Event,
spans: TraceTree.RawSpan[],
spans: RawSpanType[],
options: {sdk: string | undefined} | undefined
): [TraceTreeNode<TraceTree.NodeValue>, [number, number] | null] {
parent.invalidate(parent);
Expand All @@ -878,7 +877,7 @@ export class TraceTree {

const parentIsSpan = isSpanNode(parent);
const lookuptable: Record<
TraceTree.RawSpan['span_id'],
RawSpanType['span_id'],
TraceTreeNode<TraceTree.Span | TraceTree.Transaction>
> = {};

Expand Down Expand Up @@ -2491,7 +2490,7 @@ export function computeAutogroupedBarSegments(

// Returns a list of errors related to the txn with ids matching the span id
function getRelatedSpanErrorsFromTransaction(
span: TraceTree.RawSpan,
span: RawSpanType,
node?: TraceTreeNode<TraceTree.NodeValue>
): TraceErrorType[] {
if (!node || !node.value || !isTransactionNode(node)) {
Expand All @@ -2513,7 +2512,7 @@ function getRelatedSpanErrorsFromTransaction(

// Returns a list of performance errors related to the txn with ids matching the span id
function getRelatedPerformanceIssuesFromTransaction(
span: TraceTree.RawSpan,
span: RawSpanType,
node?: TraceTreeNode<TraceTree.NodeValue>
): TraceTree.TracePerformanceIssue[] {
if (!node || !node.value || !isTransactionNode(node)) {
Expand Down

0 comments on commit a9de22b

Please sign in to comment.