-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
fix(ourlogs): Search and display fixes for embedded views #90940
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
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ import {useCallback} from 'react'; | |
import styled from '@emotion/styled'; | ||
|
||
import {Button} from 'sentry/components/core/button'; | ||
import {OurlogsDrawer} from 'sentry/components/events/ourlogs/ourlogsDrawer'; | ||
import useDrawer from 'sentry/components/globalDrawer'; | ||
import {IconChevron} from 'sentry/icons'; | ||
import {t} from 'sentry/locale'; | ||
|
@@ -14,37 +15,53 @@ import {LogsAnalyticsPageSource} from 'sentry/utils/analytics/logsAnalyticsEvent | |
import useOrganization from 'sentry/utils/useOrganization'; | ||
import { | ||
LogsPageParamsProvider, | ||
type LogsPageParamsProviderProps, | ||
useLogsSearch, | ||
} from 'sentry/views/explore/contexts/logs/logsPageParams'; | ||
import {TraceItemAttributeProvider} from 'sentry/views/explore/contexts/traceItemAttributeContext'; | ||
import {LogsIssueDrawer} from 'sentry/views/explore/logs/logsIssueDrawer'; | ||
import {LogsTable} from 'sentry/views/explore/logs/logsTable'; | ||
import { | ||
useExploreLogsTable, | ||
type UseExploreLogsTableResult, | ||
} from 'sentry/views/explore/logs/useLogsQuery'; | ||
import {useExploreLogsTable} from 'sentry/views/explore/logs/useLogsQuery'; | ||
import {TraceItemDataset} from 'sentry/views/explore/types'; | ||
import {SectionKey} from 'sentry/views/issueDetails/streamline/context'; | ||
import {InterimSection} from 'sentry/views/issueDetails/streamline/interimSection'; | ||
|
||
export function LogsIssuesSection({ | ||
initialCollapse, | ||
isOnEmbeddedView, | ||
limitToTraceId, | ||
export function OurlogsSection({ | ||
event, | ||
project, | ||
group, | ||
}: { | ||
event: Event; | ||
group: Group; | ||
initialCollapse: boolean; | ||
project: Project; | ||
} & Omit<LogsPageParamsProviderProps, 'children' | 'analyticsPageSource'>) { | ||
}) { | ||
return ( | ||
<LogsPageParamsProvider | ||
analyticsPageSource={LogsAnalyticsPageSource.ISSUE_DETAILS} | ||
isTableFrozen | ||
blockRowExpanding | ||
limitToTraceId={event.contexts?.trace?.trace_id} | ||
> | ||
<OurlogsSectionContent event={event} group={group} project={project} /> | ||
</LogsPageParamsProvider> | ||
); | ||
} | ||
|
||
function OurlogsSectionContent({ | ||
event, | ||
project, | ||
group, | ||
}: { | ||
event: Event; | ||
group: Group; | ||
project: Project; | ||
}) { | ||
const organization = useOrganization(); | ||
const feature = organization.features.includes('ourlogs-enabled'); | ||
const tableData = useExploreLogsTable({enabled: feature, limit: 10}); | ||
const logsSearch = useLogsSearch(); | ||
const abbreviatedTableData = {...tableData, data: (tableData.data ?? []).slice(0, 5)}; | ||
const {openDrawer} = useDrawer(); | ||
|
||
const limitToTraceId = event.contexts?.trace?.trace_id; | ||
const onOpenLogsDrawer = useCallback(() => { | ||
trackAnalytics('logs.issue_details.drawer_opened', { | ||
organization, | ||
|
@@ -53,11 +70,11 @@ export function LogsIssuesSection({ | |
() => ( | ||
<LogsPageParamsProvider | ||
analyticsPageSource={LogsAnalyticsPageSource.ISSUE_DETAILS} | ||
isOnEmbeddedView | ||
isTableFrozen | ||
limitToTraceId={limitToTraceId} | ||
> | ||
<TraceItemAttributeProvider traceItemType={TraceItemDataset.LOGS} enabled> | ||
<LogsIssueDrawer group={group} event={event} project={project} /> | ||
<OurlogsDrawer group={group} event={event} project={project} /> | ||
</TraceItemAttributeProvider> | ||
</LogsPageParamsProvider> | ||
), | ||
|
@@ -75,7 +92,7 @@ export function LogsIssuesSection({ | |
// We may change this in the future if we have a trace-group or we generate trace sids for these issue types. | ||
return null; | ||
} | ||
if (tableData?.data?.length === 0) { | ||
if (!tableData || (tableData.data?.length === 0 && logsSearch.isEmpty())) { | ||
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. Oh is the the bug that hides it if you are filtering down and it's an empty table? Can we make a quick test and just assert the empty state renders (mock the requests returning empty) to cover these? 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. I'll do the tests for the issues page in a separate PR, there is no harness yet |
||
// Like breadcrumbs, we don't show the logs section if there are no logs. | ||
return null; | ||
} | ||
|
@@ -85,52 +102,40 @@ export function LogsIssuesSection({ | |
type={SectionKey.LOGS} | ||
title={t('Logs')} | ||
data-test-id="logs-data-section" | ||
initialCollapse={initialCollapse} | ||
> | ||
<LogsPageParamsProvider | ||
analyticsPageSource={LogsAnalyticsPageSource.ISSUE_DETAILS} | ||
isOnEmbeddedView={isOnEmbeddedView} | ||
limitToTraceId={limitToTraceId} | ||
> | ||
<LogsSectionContent tableData={tableData} openDrawer={onOpenLogsDrawer} /> | ||
</LogsPageParamsProvider> | ||
<LogContentWrapper onClick={() => onOpenLogsDrawer()}> | ||
<LogsTable | ||
showHeader={false} | ||
allowPagination={false} | ||
tableData={abbreviatedTableData} | ||
/> | ||
{tableData.data?.length > 5 ? ( | ||
<div> | ||
<Button | ||
icon={<IconChevron direction="right" />} | ||
aria-label={t('View more')} | ||
size="md" | ||
onClick={() => onOpenLogsDrawer()} | ||
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. do we need both Also I hadn't realized it but we would have never been able to expand logs for log count < 5 on the table without the general onclick, so good that we added it 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. yea, you can still tab to focus it |
||
> | ||
{t('View more')} | ||
</Button> | ||
</div> | ||
) : null} | ||
</LogContentWrapper> | ||
</InterimSection> | ||
); | ||
} | ||
|
||
function LogsSectionContent({ | ||
tableData, | ||
openDrawer, | ||
}: { | ||
openDrawer: () => void; | ||
tableData: UseExploreLogsTableResult; | ||
}) { | ||
const abbreviatedTableData = {...tableData, data: (tableData.data ?? []).slice(0, 5)}; | ||
return ( | ||
<LogContentWrapper> | ||
<LogsTable | ||
showHeader={false} | ||
allowPagination={false} | ||
tableData={abbreviatedTableData} | ||
/> | ||
{tableData.data?.length > 5 ? ( | ||
<div> | ||
<Button | ||
icon={<IconChevron direction="right" />} | ||
aria-label={t('View more')} | ||
size="md" | ||
onClick={() => openDrawer()} | ||
> | ||
{t('View more')} | ||
</Button> | ||
</div> | ||
) : null} | ||
</LogContentWrapper> | ||
); | ||
} | ||
|
||
const LogContentWrapper = styled('div')` | ||
const LogContentWrapper = styled('button')` | ||
all: unset; | ||
display: flex; | ||
flex-direction: column; | ||
gap: ${space(1)}; | ||
pointer-events: auto; | ||
cursor: pointer; | ||
* { | ||
pointer-events: none !important; | ||
cursor: inherit !important; | ||
} | ||
`; |
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.
are these two conditionals ever exclusive? Does a frozen table imply we're using the drawer always? Or is it only in issues where we do
View More
and have the limited table?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.
exactly, yea