Skip to content

Commit 99f79d1

Browse files
authored
fix(ourlogs): Search and display fixes for embedded views (#90940)
- Do not show cell actions in embedded tables - Add a test to such effect - Rename things to be consistent everywhere (just isFrozen) - Refactor the issues section - Do not entirely hide the section if your search returns empty results (unreported bug) - Use useState for search on embedded pages (issues, trace view) Fixes LOGS-82
1 parent 4c4b80a commit 99f79d1

File tree

12 files changed

+388
-203
lines changed

12 files changed

+388
-203
lines changed

static/app/components/events/breadcrumbs/combinedBreadcrumbsAndLogsSection.tsx

Lines changed: 0 additions & 66 deletions
This file was deleted.

static/app/views/explore/logs/logsIssueDrawer.tsx renamed to static/app/components/events/ourlogs/ourlogsDrawer.tsx

Lines changed: 29 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,21 @@ import {
99
NavigationCrumbs,
1010
ShortId,
1111
} from 'sentry/components/events/eventDrawer';
12+
import {SearchQueryBuilderProvider} from 'sentry/components/searchQueryBuilder/context';
1213
import {t} from 'sentry/locale';
1314
import {space} from 'sentry/styles/space';
1415
import type {Event} from 'sentry/types/event';
1516
import type {Group} from 'sentry/types/group';
1617
import type {Project} from 'sentry/types/project';
1718
import {getShortEventId} from 'sentry/utils/events';
18-
import {TraceItemSearchQueryBuilder} from 'sentry/views/explore/components/traceItemSearchQueryBuilder';
19+
import {MutableSearch} from 'sentry/utils/tokenizeSearch';
20+
import {
21+
TraceItemSearchQueryBuilder,
22+
useSearchQueryBuilderProps,
23+
} from 'sentry/views/explore/components/traceItemSearchQueryBuilder';
1924
import {
2025
useLogsSearch,
21-
useSetLogsQuery,
26+
useSetLogsSearch,
2227
} from 'sentry/views/explore/contexts/logs/logsPageParams';
2328
import {useTraceItemAttributes} from 'sentry/views/explore/contexts/traceItemAttributeContext';
2429
import {LogsTable} from 'sentry/views/explore/logs/logsTable';
@@ -31,12 +36,24 @@ interface LogIssueDrawerProps {
3136
project: Project;
3237
}
3338

34-
export function LogsIssueDrawer({event, project, group}: LogIssueDrawerProps) {
35-
const setLogsQuery = useSetLogsQuery();
39+
export function OurlogsDrawer({event, project, group}: LogIssueDrawerProps) {
40+
const setLogsSearch = useSetLogsSearch();
3641
const logsSearch = useLogsSearch();
3742
const tableData = useExploreLogsTable({});
38-
const {attributes: stringTags} = useTraceItemAttributes('string');
39-
const {attributes: numberTags} = useTraceItemAttributes('number');
43+
const {attributes: stringAttributes} = useTraceItemAttributes('string');
44+
const {attributes: numberAttributes} = useTraceItemAttributes('number');
45+
46+
const tracesItemSearchQueryBuilderProps = {
47+
initialQuery: logsSearch.formatString(),
48+
searchSource: 'ourlogs',
49+
onSearch: (query: string) => setLogsSearch(new MutableSearch(query)),
50+
numberAttributes,
51+
stringAttributes,
52+
itemType: TraceItemDataset.LOGS,
53+
};
54+
const searchQueryBuilderProps = useSearchQueryBuilderProps(
55+
tracesItemSearchQueryBuilderProps
56+
);
4057

4158
return (
4259
<EventDrawerContainer>
@@ -57,17 +74,12 @@ export function LogsIssueDrawer({event, project, group}: LogIssueDrawerProps) {
5774
/>
5875
</EventDrawerHeader>
5976
<EventDrawerBody>
60-
<LogsTableContainer>
61-
<TraceItemSearchQueryBuilder
62-
initialQuery={logsSearch.formatString()}
63-
searchSource="ourlogs"
64-
onSearch={setLogsQuery}
65-
numberAttributes={numberTags}
66-
stringAttributes={stringTags}
67-
itemType={TraceItemDataset.LOGS}
68-
/>
69-
<LogsTable showHeader={false} allowPagination tableData={tableData} />
70-
</LogsTableContainer>
77+
<SearchQueryBuilderProvider {...searchQueryBuilderProps}>
78+
<LogsTableContainer>
79+
<TraceItemSearchQueryBuilder {...tracesItemSearchQueryBuilderProps} />
80+
<LogsTable showHeader={false} allowPagination tableData={tableData} />
81+
</LogsTableContainer>
82+
</SearchQueryBuilderProvider>
7183
</EventDrawerBody>
7284
</EventDrawerContainer>
7385
);

static/app/views/explore/logs/logsIssuesSection.tsx renamed to static/app/components/events/ourlogs/ourlogsSection.tsx

Lines changed: 60 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import {useCallback} from 'react';
22
import styled from '@emotion/styled';
33

44
import {Button} from 'sentry/components/core/button';
5+
import {OurlogsDrawer} from 'sentry/components/events/ourlogs/ourlogsDrawer';
56
import useDrawer from 'sentry/components/globalDrawer';
67
import {IconChevron} from 'sentry/icons';
78
import {t} from 'sentry/locale';
@@ -14,37 +15,53 @@ import {LogsAnalyticsPageSource} from 'sentry/utils/analytics/logsAnalyticsEvent
1415
import useOrganization from 'sentry/utils/useOrganization';
1516
import {
1617
LogsPageParamsProvider,
17-
type LogsPageParamsProviderProps,
18+
useLogsSearch,
1819
} from 'sentry/views/explore/contexts/logs/logsPageParams';
1920
import {TraceItemAttributeProvider} from 'sentry/views/explore/contexts/traceItemAttributeContext';
20-
import {LogsIssueDrawer} from 'sentry/views/explore/logs/logsIssueDrawer';
2121
import {LogsTable} from 'sentry/views/explore/logs/logsTable';
22-
import {
23-
useExploreLogsTable,
24-
type UseExploreLogsTableResult,
25-
} from 'sentry/views/explore/logs/useLogsQuery';
22+
import {useExploreLogsTable} from 'sentry/views/explore/logs/useLogsQuery';
2623
import {TraceItemDataset} from 'sentry/views/explore/types';
2724
import {SectionKey} from 'sentry/views/issueDetails/streamline/context';
2825
import {InterimSection} from 'sentry/views/issueDetails/streamline/interimSection';
2926

30-
export function LogsIssuesSection({
31-
initialCollapse,
32-
isOnEmbeddedView,
33-
limitToTraceId,
27+
export function OurlogsSection({
3428
event,
3529
project,
3630
group,
3731
}: {
3832
event: Event;
3933
group: Group;
40-
initialCollapse: boolean;
4134
project: Project;
42-
} & Omit<LogsPageParamsProviderProps, 'children' | 'analyticsPageSource'>) {
35+
}) {
36+
return (
37+
<LogsPageParamsProvider
38+
analyticsPageSource={LogsAnalyticsPageSource.ISSUE_DETAILS}
39+
isTableFrozen
40+
blockRowExpanding
41+
limitToTraceId={event.contexts?.trace?.trace_id}
42+
>
43+
<OurlogsSectionContent event={event} group={group} project={project} />
44+
</LogsPageParamsProvider>
45+
);
46+
}
47+
48+
function OurlogsSectionContent({
49+
event,
50+
project,
51+
group,
52+
}: {
53+
event: Event;
54+
group: Group;
55+
project: Project;
56+
}) {
4357
const organization = useOrganization();
4458
const feature = organization.features.includes('ourlogs-enabled');
4559
const tableData = useExploreLogsTable({enabled: feature, limit: 10});
60+
const logsSearch = useLogsSearch();
61+
const abbreviatedTableData = {...tableData, data: (tableData.data ?? []).slice(0, 5)};
4662
const {openDrawer} = useDrawer();
4763

64+
const limitToTraceId = event.contexts?.trace?.trace_id;
4865
const onOpenLogsDrawer = useCallback(() => {
4966
trackAnalytics('logs.issue_details.drawer_opened', {
5067
organization,
@@ -53,11 +70,11 @@ export function LogsIssuesSection({
5370
() => (
5471
<LogsPageParamsProvider
5572
analyticsPageSource={LogsAnalyticsPageSource.ISSUE_DETAILS}
56-
isOnEmbeddedView
73+
isTableFrozen
5774
limitToTraceId={limitToTraceId}
5875
>
5976
<TraceItemAttributeProvider traceItemType={TraceItemDataset.LOGS} enabled>
60-
<LogsIssueDrawer group={group} event={event} project={project} />
77+
<OurlogsDrawer group={group} event={event} project={project} />
6178
</TraceItemAttributeProvider>
6279
</LogsPageParamsProvider>
6380
),
@@ -75,7 +92,7 @@ export function LogsIssuesSection({
7592
// We may change this in the future if we have a trace-group or we generate trace sids for these issue types.
7693
return null;
7794
}
78-
if (tableData?.data?.length === 0) {
95+
if (!tableData || (tableData.data?.length === 0 && logsSearch.isEmpty())) {
7996
// Like breadcrumbs, we don't show the logs section if there are no logs.
8097
return null;
8198
}
@@ -85,52 +102,40 @@ export function LogsIssuesSection({
85102
type={SectionKey.LOGS}
86103
title={t('Logs')}
87104
data-test-id="logs-data-section"
88-
initialCollapse={initialCollapse}
89105
>
90-
<LogsPageParamsProvider
91-
analyticsPageSource={LogsAnalyticsPageSource.ISSUE_DETAILS}
92-
isOnEmbeddedView={isOnEmbeddedView}
93-
limitToTraceId={limitToTraceId}
94-
>
95-
<LogsSectionContent tableData={tableData} openDrawer={onOpenLogsDrawer} />
96-
</LogsPageParamsProvider>
106+
<LogContentWrapper onClick={() => onOpenLogsDrawer()}>
107+
<LogsTable
108+
showHeader={false}
109+
allowPagination={false}
110+
tableData={abbreviatedTableData}
111+
/>
112+
{tableData.data?.length > 5 ? (
113+
<div>
114+
<Button
115+
icon={<IconChevron direction="right" />}
116+
aria-label={t('View more')}
117+
size="md"
118+
onClick={() => onOpenLogsDrawer()}
119+
>
120+
{t('View more')}
121+
</Button>
122+
</div>
123+
) : null}
124+
</LogContentWrapper>
97125
</InterimSection>
98126
);
99127
}
100128

101-
function LogsSectionContent({
102-
tableData,
103-
openDrawer,
104-
}: {
105-
openDrawer: () => void;
106-
tableData: UseExploreLogsTableResult;
107-
}) {
108-
const abbreviatedTableData = {...tableData, data: (tableData.data ?? []).slice(0, 5)};
109-
return (
110-
<LogContentWrapper>
111-
<LogsTable
112-
showHeader={false}
113-
allowPagination={false}
114-
tableData={abbreviatedTableData}
115-
/>
116-
{tableData.data?.length > 5 ? (
117-
<div>
118-
<Button
119-
icon={<IconChevron direction="right" />}
120-
aria-label={t('View more')}
121-
size="md"
122-
onClick={() => openDrawer()}
123-
>
124-
{t('View more')}
125-
</Button>
126-
</div>
127-
) : null}
128-
</LogContentWrapper>
129-
);
130-
}
131-
132-
const LogContentWrapper = styled('div')`
129+
const LogContentWrapper = styled('button')`
130+
all: unset;
133131
display: flex;
134132
flex-direction: column;
135133
gap: ${space(1)};
134+
pointer-events: auto;
135+
cursor: pointer;
136+
137+
* {
138+
pointer-events: none !important;
139+
cursor: inherit !important;
140+
}
136141
`;

0 commit comments

Comments
 (0)