forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[APM] Improve types for tabs and properties table (elastic#32462)
* [APM] Improve types for tabs * Update translations * Rename Tab to PropertyTab * Add comment about agent names
- Loading branch information
Showing
26 changed files
with
731 additions
and
574 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
x-pack/plugins/apm/public/components/app/ErrorGroupDetails/DetailView/ErrorTabs.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import { i18n } from '@kbn/i18n'; | ||
import { isEmpty } from 'lodash'; | ||
import { idx } from 'x-pack/plugins/apm/common/idx'; | ||
import { APMError } from 'x-pack/plugins/apm/typings/es_schemas/Error'; | ||
import { | ||
getTabsFromObject, | ||
PropertyTab | ||
} from '../../../shared/PropertiesTable/tabConfig'; | ||
|
||
export type ErrorTab = PropertyTab | ExceptionTab | LogTab; | ||
|
||
interface LogTab { | ||
key: 'log_stacktrace'; | ||
label: string; | ||
} | ||
|
||
export const logStacktraceTab: LogTab = { | ||
key: 'log_stacktrace', | ||
label: i18n.translate('xpack.apm.propertiesTable.tabs.logStacktraceLabel', { | ||
defaultMessage: 'Log stacktrace' | ||
}) | ||
}; | ||
|
||
interface ExceptionTab { | ||
key: 'exception_stacktrace'; | ||
label: string; | ||
} | ||
|
||
export const exceptionStacktraceTab: ExceptionTab = { | ||
key: 'exception_stacktrace', | ||
label: i18n.translate( | ||
'xpack.apm.propertiesTable.tabs.exceptionStacktraceLabel', | ||
{ | ||
defaultMessage: 'Exception stacktrace' | ||
} | ||
) | ||
}; | ||
|
||
export function getTabs(error: APMError) { | ||
const hasLogStacktrace = !isEmpty(idx(error, _ => _.error.log.stacktrace)); | ||
return [ | ||
...(hasLogStacktrace ? [logStacktraceTab] : []), | ||
exceptionStacktraceTab, | ||
...getTabsFromObject(error) | ||
]; | ||
} |
44 changes: 44 additions & 0 deletions
44
...ins/apm/public/components/app/ErrorGroupDetails/DetailView/StickyErrorProperties.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import { shallow } from 'enzyme'; | ||
import React from 'react'; | ||
import { APMError } from 'x-pack/plugins/apm/typings/es_schemas/Error'; | ||
import { Transaction } from 'x-pack/plugins/apm/typings/es_schemas/Transaction'; | ||
import { StickyErrorProperties } from './StickyErrorProperties'; | ||
|
||
describe('StickyErrorProperties', () => { | ||
it('should render StickyProperties', () => { | ||
const transaction = { | ||
http: { request: { method: 'GET' } }, | ||
url: { full: 'myUrl' }, | ||
trace: { id: 'traceId' }, | ||
transaction: { | ||
type: 'myTransactionType', | ||
name: 'myTransactionName', | ||
id: 'myTransactionName' | ||
}, | ||
service: { name: 'myService' }, | ||
user: { id: 'myUserId' } | ||
} as Transaction; | ||
|
||
const error = { | ||
'@timestamp': 'myTimestamp', | ||
http: { request: { method: 'GET' } }, | ||
url: { full: 'myUrl' }, | ||
service: { name: 'myService' }, | ||
user: { id: 'myUserId' }, | ||
error: { exception: [{ handled: true }] }, | ||
transaction: { id: 'myTransactionId', sampled: true } | ||
} as APMError; | ||
|
||
const wrapper = shallow( | ||
<StickyErrorProperties error={error} transaction={transaction} /> | ||
); | ||
|
||
expect(wrapper).toMatchSnapshot(); | ||
}); | ||
}); |
118 changes: 118 additions & 0 deletions
118
.../plugins/apm/public/components/app/ErrorGroupDetails/DetailView/StickyErrorProperties.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import { i18n } from '@kbn/i18n'; | ||
import React, { Fragment } from 'react'; | ||
import { | ||
ERROR_EXC_HANDLED, | ||
HTTP_REQUEST_METHOD, | ||
TRANSACTION_ID, | ||
URL_FULL, | ||
USER_ID | ||
} from 'x-pack/plugins/apm/common/elasticsearch_fieldnames'; | ||
import { NOT_AVAILABLE_LABEL } from 'x-pack/plugins/apm/common/i18n'; | ||
import { idx } from 'x-pack/plugins/apm/common/idx'; | ||
import { APMError } from 'x-pack/plugins/apm/typings/es_schemas/Error'; | ||
import { Transaction } from 'x-pack/plugins/apm/typings/es_schemas/Transaction'; | ||
import { KibanaLink } from '../../../shared/Links/KibanaLink'; | ||
import { legacyEncodeURIComponent } from '../../../shared/Links/url_helpers'; | ||
import { StickyProperties } from '../../../shared/StickyProperties'; | ||
|
||
interface Props { | ||
error: APMError; | ||
transaction: Transaction | undefined; | ||
} | ||
|
||
function TransactionLink({ error, transaction }: Props) { | ||
if (!transaction) { | ||
return <Fragment>{NOT_AVAILABLE_LABEL}</Fragment>; | ||
} | ||
|
||
const isSampled = error.transaction.sampled; | ||
if (!isSampled) { | ||
return <Fragment>{transaction.transaction.id}</Fragment>; | ||
} | ||
|
||
const path = `/${ | ||
transaction.service.name | ||
}/transactions/${legacyEncodeURIComponent( | ||
transaction.transaction.type | ||
)}/${legacyEncodeURIComponent(transaction.transaction.name)}`; | ||
|
||
return ( | ||
<KibanaLink | ||
hash={path} | ||
query={{ | ||
transactionId: transaction.transaction.id, | ||
traceId: transaction.trace.id | ||
}} | ||
> | ||
{transaction.transaction.id} | ||
</KibanaLink> | ||
); | ||
} | ||
|
||
export function StickyErrorProperties({ error, transaction }: Props) { | ||
const stickyProperties = [ | ||
{ | ||
fieldName: '@timestamp', | ||
label: i18n.translate('xpack.apm.errorGroupDetails.timestampLabel', { | ||
defaultMessage: 'Timestamp' | ||
}), | ||
val: error['@timestamp'], | ||
width: '50%' | ||
}, | ||
{ | ||
fieldName: URL_FULL, | ||
label: 'URL', | ||
val: | ||
idx(error, _ => _.context.page.url) || | ||
idx(error, _ => _.url.full) || | ||
NOT_AVAILABLE_LABEL, | ||
truncated: true, | ||
width: '50%' | ||
}, | ||
{ | ||
fieldName: HTTP_REQUEST_METHOD, | ||
label: i18n.translate('xpack.apm.errorGroupDetails.requestMethodLabel', { | ||
defaultMessage: 'Request method' | ||
}), | ||
val: idx(error, _ => _.http.request.method) || NOT_AVAILABLE_LABEL, | ||
width: '25%' | ||
}, | ||
{ | ||
fieldName: ERROR_EXC_HANDLED, | ||
label: i18n.translate('xpack.apm.errorGroupDetails.handledLabel', { | ||
defaultMessage: 'Handled' | ||
}), | ||
val: | ||
String(idx(error, _ => _.error.exception[0].handled)) || | ||
NOT_AVAILABLE_LABEL, | ||
width: '25%' | ||
}, | ||
{ | ||
fieldName: TRANSACTION_ID, | ||
label: i18n.translate( | ||
'xpack.apm.errorGroupDetails.transactionSampleIdLabel', | ||
{ | ||
defaultMessage: 'Transaction sample ID' | ||
} | ||
), | ||
val: <TransactionLink transaction={transaction} error={error} />, | ||
width: '25%' | ||
}, | ||
{ | ||
fieldName: USER_ID, | ||
label: i18n.translate('xpack.apm.errorGroupDetails.userIdLabel', { | ||
defaultMessage: 'User ID' | ||
}), | ||
val: idx(error, _ => _.user.id) || NOT_AVAILABLE_LABEL, | ||
width: '25%' | ||
} | ||
]; | ||
|
||
return <StickyProperties stickyProperties={stickyProperties} />; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.