-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
[APM] Adds "Logs" tab to transaction details for related trace logs #85859
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 |
---|---|---|
|
@@ -9,27 +9,14 @@ import { i18n } from '@kbn/i18n'; | |
import { Location } from 'history'; | ||
import React from 'react'; | ||
import { useHistory } from 'react-router-dom'; | ||
import { LogStream } from '../../../../../../infra/public'; | ||
import { Transaction } from '../../../../../typings/es_schemas/ui/transaction'; | ||
import type { IUrlParams } from '../../../../context/url_params_context/types'; | ||
import { fromQuery, toQuery } from '../../../shared/Links/url_helpers'; | ||
import { TransactionMetadata } from '../../../shared/MetadataTable/TransactionMetadata'; | ||
import { WaterfallContainer } from './WaterfallContainer'; | ||
import { IWaterfall } from './WaterfallContainer/Waterfall/waterfall_helpers/waterfall_helpers'; | ||
|
||
const timelineTab = { | ||
key: 'timeline', | ||
label: i18n.translate('xpack.apm.propertiesTable.tabs.timelineLabel', { | ||
defaultMessage: 'Timeline', | ||
}), | ||
}; | ||
|
||
const metadataTab = { | ||
key: 'metadata', | ||
label: i18n.translate('xpack.apm.propertiesTable.tabs.metadataLabel', { | ||
defaultMessage: 'Metadata', | ||
}), | ||
}; | ||
|
||
interface Props { | ||
location: Location; | ||
transaction: Transaction; | ||
|
@@ -46,9 +33,10 @@ export function TransactionTabs({ | |
exceedsMax, | ||
}: Props) { | ||
const history = useHistory(); | ||
const tabs = [timelineTab, metadataTab]; | ||
const tabs = [timelineTab, metadataTab, logsTab]; | ||
const currentTab = | ||
urlParams.detailTab === metadataTab.key ? metadataTab : timelineTab; | ||
tabs.find(({ key }) => key === urlParams.detailTab) ?? timelineTab; | ||
const TabContent = currentTab.component; | ||
|
||
return ( | ||
<React.Fragment> | ||
|
@@ -76,16 +64,77 @@ export function TransactionTabs({ | |
|
||
<EuiSpacer /> | ||
|
||
{currentTab.key === timelineTab.key ? ( | ||
<WaterfallContainer | ||
location={location} | ||
urlParams={urlParams} | ||
waterfall={waterfall} | ||
exceedsMax={exceedsMax} | ||
/> | ||
) : ( | ||
<TransactionMetadata transaction={transaction} /> | ||
)} | ||
<TabContent | ||
location={location} | ||
urlParams={urlParams} | ||
waterfall={waterfall} | ||
exceedsMax={exceedsMax} | ||
transaction={transaction} | ||
/> | ||
</React.Fragment> | ||
); | ||
} | ||
|
||
const timelineTab = { | ||
key: 'timeline', | ||
label: i18n.translate('xpack.apm.propertiesTable.tabs.timelineLabel', { | ||
defaultMessage: 'Timeline', | ||
}), | ||
component: TimelineTabContent, | ||
}; | ||
|
||
const metadataTab = { | ||
key: 'metadata', | ||
label: i18n.translate('xpack.apm.propertiesTable.tabs.metadataLabel', { | ||
defaultMessage: 'Metadata', | ||
}), | ||
component: MetadataTabContent, | ||
}; | ||
|
||
const logsTab = { | ||
key: 'logs', | ||
label: i18n.translate('xpack.apm.propertiesTable.tabs.logsLabel', { | ||
defaultMessage: 'Logs', | ||
}), | ||
component: LogsTabContent, | ||
}; | ||
|
||
function TimelineTabContent({ | ||
location, | ||
urlParams, | ||
waterfall, | ||
exceedsMax, | ||
}: { | ||
location: Location<any>; | ||
urlParams: IUrlParams; | ||
waterfall: IWaterfall; | ||
exceedsMax: boolean; | ||
}) { | ||
return ( | ||
<WaterfallContainer | ||
location={location} | ||
urlParams={urlParams} | ||
waterfall={waterfall} | ||
exceedsMax={exceedsMax} | ||
/> | ||
); | ||
} | ||
|
||
function MetadataTabContent({ transaction }: { transaction: Transaction }) { | ||
return <TransactionMetadata transaction={transaction} />; | ||
} | ||
|
||
function LogsTabContent({ transaction }: { transaction: Transaction }) { | ||
const startTimestamp = Math.floor(transaction.timestamp.us / 1000); | ||
const endTimestamp = Math.ceil( | ||
startTimestamp + transaction.transaction.duration.us / 1000 | ||
); | ||
const framePaddingMs = 1000 * 60 * 60 * 24; // 24 hours | ||
return ( | ||
<LogStream | ||
startTimestamp={startTimestamp - framePaddingMs} | ||
endTimestamp={endTimestamp + framePaddingMs} | ||
query={`trace.id:"${transaction.trace.id}" OR "${transaction.trace.id}"`} | ||
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. This matches the filter for the "Trace logs" link in the action menu: https://github.com/elastic/kibana/blob/master/x-pack/plugins/apm/public/components/shared/TransactionActionMenu/sections.ts#L183, but i'm not sure why this needs to be an 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. My guess is that is will pick up entries that don't have the trace.id attribute set but contain the trace id in other fields, but first matching with the field name gives exact matches. |
||
/> | ||
); | ||
} |
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.
nit: might want to define this outside the component to indicate that it is static.
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.
Nvm, I see a green build. Feel free to merge.