1
- import { useCallback } from 'react' ;
1
+ import { useCallback , useState } from 'react' ;
2
2
import styled from '@emotion/styled' ;
3
3
4
4
import { openModal } from 'sentry/actionCreators/modal' ;
@@ -14,6 +14,8 @@ import {IconTable} from 'sentry/icons';
14
14
import { t } from 'sentry/locale' ;
15
15
import { space } from 'sentry/styles/space' ;
16
16
import { LogsAnalyticsPageSource } from 'sentry/utils/analytics/logsAnalyticsEvent' ;
17
+ import { DiscoverDatasets } from 'sentry/utils/discover/types' ;
18
+ import { ExploreCharts } from 'sentry/views/explore/charts' ;
17
19
import SchemaHintsList , {
18
20
SchemaHintsSection ,
19
21
} from 'sentry/views/explore/components/schemaHintsList' ;
@@ -31,15 +33,19 @@ import {
31
33
useSetLogsPageParams ,
32
34
useSetLogsQuery ,
33
35
} from 'sentry/views/explore/contexts/logs/logsPageParams' ;
36
+ import type { Visualize } from 'sentry/views/explore/contexts/pageParamsContext/visualizes' ;
34
37
import { useTraceItemAttributes } from 'sentry/views/explore/contexts/traceItemAttributeContext' ;
35
38
import { useLogAnalytics } from 'sentry/views/explore/hooks/useAnalytics' ;
39
+ import { useChartInterval } from 'sentry/views/explore/hooks/useChartInterval' ;
36
40
import { HiddenColumnEditorLogFields } from 'sentry/views/explore/logs/constants' ;
37
- import { LogsChart } from 'sentry/views/explore/logs/logsChart' ;
38
41
import { LogsTable } from 'sentry/views/explore/logs/logsTable' ;
42
+ import { OurLogKnownFieldKey } from 'sentry/views/explore/logs/types' ;
39
43
import { useExploreLogsTable } from 'sentry/views/explore/logs/useLogsQuery' ;
40
44
import { ColumnEditorModal } from 'sentry/views/explore/tables/columnEditorModal' ;
41
45
import { TraceItemDataset } from 'sentry/views/explore/types' ;
42
46
import type { DefaultPeriod , MaxPickableDays } from 'sentry/views/explore/utils' ;
47
+ import { ChartType } from 'sentry/views/insights/common/components/chart' ;
48
+ import { useSortedTimeSeries } from 'sentry/views/insights/common/queries/useSortedTimeSeries' ;
43
49
44
50
export type LogsTabProps = {
45
51
defaultPeriod : DefaultPeriod ;
@@ -59,6 +65,25 @@ export function LogsTabContent({
59
65
const setLogsPageParams = useSetLogsPageParams ( ) ;
60
66
const tableData = useExploreLogsTable ( { } ) ;
61
67
68
+ const [ interval ] = useChartInterval ( ) ;
69
+
70
+ const timeseriesResult = useSortedTimeSeries (
71
+ {
72
+ search : logsSearch ,
73
+ yAxis : [ `count(${ OurLogKnownFieldKey . MESSAGE } )` ] ,
74
+ interval,
75
+ } ,
76
+ 'explore.ourlogs.main-chart' ,
77
+ DiscoverDatasets . OURLOGS
78
+ ) ;
79
+ const [ visualizes , setVisualizes ] = useState < Visualize [ ] > ( [
80
+ {
81
+ chartType : ChartType . BAR ,
82
+ yAxes : [ `count(${ OurLogKnownFieldKey . MESSAGE } )` ] ,
83
+ label : 'A' ,
84
+ } ,
85
+ ] ) ;
86
+
62
87
const { attributes : stringAttributes , isLoading : stringAttributesLoading } =
63
88
useTraceItemAttributes ( 'string' ) ;
64
89
const { attributes : numberAttributes , isLoading : numberAttributesLoading } =
@@ -142,7 +167,16 @@ export function LogsTabContent({
142
167
</ Feature >
143
168
< Feature features = "organizations:ourlogs-graph" >
144
169
< LogsItemContainer >
145
- < LogsChart />
170
+ < ExploreCharts
171
+ canUsePreviousResults
172
+ confidences = { [ 'high' ] }
173
+ query = { logsSearch . formatString ( ) }
174
+ timeseriesResult = { timeseriesResult }
175
+ visualizes = { visualizes }
176
+ setVisualizes = { setVisualizes }
177
+ // TODO: we do not support log alerts nor adding to dashboards yet
178
+ hideContextMenu
179
+ />
146
180
</ LogsItemContainer >
147
181
</ Feature >
148
182
< LogsItemContainer >
0 commit comments