Skip to content

Commit 6812bc0

Browse files
authored
feat(explorer): custom copy and navigation for get_profile_flamegraph tool (#103314)
Adds copy and urls for profile-viewing tool
1 parent e4534e7 commit 6812bc0

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed

static/app/views/seerExplorer/utils.tsx

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,14 @@ const TOOL_FORMATTERS: Record<string, ToolFormatter> = {
161161
? `Watching replay ${shortReplayId}...`
162162
: `Watched replay ${shortReplayId}`;
163163
},
164+
165+
get_profile_flamegraph: (args, isLoading) => {
166+
const profileId = args.profile_id || '';
167+
const shortProfileId = profileId.slice(0, 8);
168+
return isLoading
169+
? `Sampling profile ${shortProfileId}...`
170+
: `Sampled profile ${shortProfileId}`;
171+
},
164172
};
165173

166174
/**
@@ -403,6 +411,43 @@ export function buildToolLinkUrl(
403411
pathname: `/organizations/${orgSlug}/replays/${replay_id}/`,
404412
};
405413
}
414+
case 'get_profile_flamegraph': {
415+
const {profile_id, project_id, is_continuous, start_ts, end_ts} = toolLink.params;
416+
if (!profile_id || !project_id) {
417+
return null;
418+
}
419+
420+
// Look up project slug from project_id
421+
const project = projects?.find(p => p.id === String(project_id));
422+
if (!project) {
423+
return null;
424+
}
425+
426+
if (is_continuous) {
427+
// Continuous profiles need start/end timestamps as query params
428+
if (!start_ts || !end_ts) {
429+
return null;
430+
}
431+
432+
// Convert Unix timestamps to ISO date strings
433+
const startDate = new Date(start_ts * 1000).toISOString();
434+
const endDate = new Date(end_ts * 1000).toISOString();
435+
436+
return {
437+
pathname: `/organizations/${orgSlug}/explore/profiling/profile/${project.slug}/flamegraph/`,
438+
query: {
439+
start: startDate,
440+
end: endDate,
441+
profilerId: profile_id,
442+
},
443+
};
444+
}
445+
446+
// Transaction profiles use profile_id in the path
447+
return {
448+
pathname: `/organizations/${orgSlug}/explore/profiling/profile/${project.slug}/${profile_id}/flamegraph/`,
449+
};
450+
}
406451
default:
407452
return null;
408453
}

0 commit comments

Comments
 (0)