@@ -9,27 +9,14 @@ import { i18n } from '@kbn/i18n';
99import { Location } from 'history' ;
1010import React from 'react' ;
1111import { useHistory } from 'react-router-dom' ;
12+ import { LogStream } from '../../../../../../infra/public' ;
1213import { Transaction } from '../../../../../typings/es_schemas/ui/transaction' ;
1314import type { IUrlParams } from '../../../../context/url_params_context/types' ;
1415import { fromQuery , toQuery } from '../../../shared/Links/url_helpers' ;
1516import { TransactionMetadata } from '../../../shared/MetadataTable/TransactionMetadata' ;
1617import { WaterfallContainer } from './WaterfallContainer' ;
1718import { IWaterfall } from './WaterfallContainer/Waterfall/waterfall_helpers/waterfall_helpers' ;
1819
19- const timelineTab = {
20- key : 'timeline' ,
21- label : i18n . translate ( 'xpack.apm.propertiesTable.tabs.timelineLabel' , {
22- defaultMessage : 'Timeline' ,
23- } ) ,
24- } ;
25-
26- const metadataTab = {
27- key : 'metadata' ,
28- label : i18n . translate ( 'xpack.apm.propertiesTable.tabs.metadataLabel' , {
29- defaultMessage : 'Metadata' ,
30- } ) ,
31- } ;
32-
3320interface Props {
3421 location : Location ;
3522 transaction : Transaction ;
@@ -46,9 +33,10 @@ export function TransactionTabs({
4633 exceedsMax,
4734} : Props ) {
4835 const history = useHistory ( ) ;
49- const tabs = [ timelineTab , metadataTab ] ;
36+ const tabs = [ timelineTab , metadataTab , logsTab ] ;
5037 const currentTab =
51- urlParams . detailTab === metadataTab . key ? metadataTab : timelineTab ;
38+ tabs . find ( ( { key } ) => key === urlParams . detailTab ) ?? timelineTab ;
39+ const TabContent = currentTab . component ;
5240
5341 return (
5442 < React . Fragment >
@@ -76,16 +64,77 @@ export function TransactionTabs({
7664
7765 < EuiSpacer />
7866
79- { currentTab . key === timelineTab . key ? (
80- < WaterfallContainer
81- location = { location }
82- urlParams = { urlParams }
83- waterfall = { waterfall }
84- exceedsMax = { exceedsMax }
85- />
86- ) : (
87- < TransactionMetadata transaction = { transaction } />
88- ) }
67+ < TabContent
68+ location = { location }
69+ urlParams = { urlParams }
70+ waterfall = { waterfall }
71+ exceedsMax = { exceedsMax }
72+ transaction = { transaction }
73+ />
8974 </ React . Fragment >
9075 ) ;
9176}
77+
78+ const timelineTab = {
79+ key : 'timeline' ,
80+ label : i18n . translate ( 'xpack.apm.propertiesTable.tabs.timelineLabel' , {
81+ defaultMessage : 'Timeline' ,
82+ } ) ,
83+ component : TimelineTabContent ,
84+ } ;
85+
86+ const metadataTab = {
87+ key : 'metadata' ,
88+ label : i18n . translate ( 'xpack.apm.propertiesTable.tabs.metadataLabel' , {
89+ defaultMessage : 'Metadata' ,
90+ } ) ,
91+ component : MetadataTabContent ,
92+ } ;
93+
94+ const logsTab = {
95+ key : 'logs' ,
96+ label : i18n . translate ( 'xpack.apm.propertiesTable.tabs.logsLabel' , {
97+ defaultMessage : 'Logs' ,
98+ } ) ,
99+ component : LogsTabContent ,
100+ } ;
101+
102+ function TimelineTabContent ( {
103+ location,
104+ urlParams,
105+ waterfall,
106+ exceedsMax,
107+ } : {
108+ location : Location < any > ;
109+ urlParams : IUrlParams ;
110+ waterfall : IWaterfall ;
111+ exceedsMax : boolean ;
112+ } ) {
113+ return (
114+ < WaterfallContainer
115+ location = { location }
116+ urlParams = { urlParams }
117+ waterfall = { waterfall }
118+ exceedsMax = { exceedsMax }
119+ />
120+ ) ;
121+ }
122+
123+ function MetadataTabContent ( { transaction } : { transaction : Transaction } ) {
124+ return < TransactionMetadata transaction = { transaction } /> ;
125+ }
126+
127+ function LogsTabContent ( { transaction } : { transaction : Transaction } ) {
128+ const startTimestamp = Math . floor ( transaction . timestamp . us / 1000 ) ;
129+ const endTimestamp = Math . ceil (
130+ startTimestamp + transaction . transaction . duration . us / 1000
131+ ) ;
132+ const framePaddingMs = 1000 * 60 * 60 * 24 ; // 24 hours
133+ return (
134+ < LogStream
135+ startTimestamp = { startTimestamp - framePaddingMs }
136+ endTimestamp = { endTimestamp + framePaddingMs }
137+ query = { `trace.id:"${ transaction . trace . id } " OR "${ transaction . trace . id } "` }
138+ />
139+ ) ;
140+ }
0 commit comments