-
-
Notifications
You must be signed in to change notification settings - Fork 4.6k
feat(traces): add 'Open in Logs' link to Logs view #110311
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,13 +2,20 @@ import type React from 'react'; | |
| import {Fragment} from 'react'; | ||
| import styled from '@emotion/styled'; | ||
|
|
||
| import {LinkButton} from '@sentry/scraps/button'; | ||
| import {Flex} from '@sentry/scraps/layout'; | ||
|
|
||
| import usePageFilters from 'sentry/components/pageFilters/usePageFilters'; | ||
| import Panel from 'sentry/components/panels/panel'; | ||
| import {SearchQueryBuilder} from 'sentry/components/searchQueryBuilder'; | ||
| import {t} from 'sentry/locale'; | ||
| import {LogsAnalyticsPageSource} from 'sentry/utils/analytics/logsAnalyticsEvent'; | ||
| import useOrganization from 'sentry/utils/useOrganization'; | ||
| import {LogsPageDataProvider} from 'sentry/views/explore/contexts/logs/logsPageData'; | ||
| import {useLogsFrozenTraceIds} from 'sentry/views/explore/logs/logsFrozenContext'; | ||
| import {LogsQueryParamsProvider} from 'sentry/views/explore/logs/logsQueryParamsProvider'; | ||
| import {LogsInfiniteTable} from 'sentry/views/explore/logs/tables/logsInfiniteTable'; | ||
| import {adjustLogTraceID, getLogsUrl} from 'sentry/views/explore/logs/utils'; | ||
| import { | ||
| useQueryParamsSearch, | ||
| useSetQueryParamsQuery, | ||
|
|
@@ -51,19 +58,32 @@ function LogsSectionContent({ | |
| }: { | ||
| scrollContainer: React.RefObject<HTMLDivElement | null>; | ||
| }) { | ||
| const organization = useOrganization(); | ||
| const {selection} = usePageFilters(); | ||
| const traceIds = useLogsFrozenTraceIds(); | ||
| const setLogsQuery = useSetQueryParamsQuery(); | ||
| const logsSearch = useQueryParamsSearch(); | ||
|
|
||
| const traceId = traceIds?.[0] && adjustLogTraceID(traceIds[0]); | ||
| const logsUrl = getLogsUrl({ | ||
| organization, | ||
| selection, | ||
| query: traceId ? `trace:${traceId}` : undefined, | ||
| }); | ||
|
|
||
| return ( | ||
| <Fragment> | ||
| <SearchQueryBuilder | ||
| placeholder={t('Search logs for this event')} | ||
| filterKeys={{}} | ||
| getTagValues={() => new Promise<string[]>(() => [])} | ||
| initialQuery={logsSearch.formatString()} | ||
| searchSource="ourlogs" | ||
| onSearch={query => setLogsQuery(query)} | ||
| /> | ||
| <Flex gap="lg"> | ||
| <SearchQueryBuilder | ||
| placeholder={t('Search logs for this event')} | ||
| filterKeys={{}} | ||
| getTagValues={() => new Promise<string[]>(() => [])} | ||
| initialQuery={logsSearch.formatString()} | ||
| searchSource="ourlogs" | ||
| onSearch={query => setLogsQuery(query)} | ||
| /> | ||
| <LinkButton to={logsUrl}>{t('Open in Logs')}</LinkButton> | ||
| </Flex> | ||
|
Contributor
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. Search bar won't stretch to fill available widthMedium Severity The
Member
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. |
||
| <TableContainer> | ||
| <LogsInfiniteTable embedded scrollContainer={scrollContainer} /> | ||
| </TableContainer> | ||
|
|
||




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.
[Question] I got these added lines from asking Cursor "I need to open the current sentry.io trace in /explore/logs. How do i construct that link?". Is this the right way to do that?
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.
Yes, typically there are functions that we'll use to create links as theres some repetitiveness to it. Everything here looks fine.