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] Error stack trace improvements (elastic#49254) (elastic#51072)
- Loading branch information
Showing
20 changed files
with
1,463 additions
and
1,157 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
41 changes: 41 additions & 0 deletions
41
...ugins/apm/public/components/app/ErrorGroupDetails/DetailView/ExceptionStacktrace.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,41 @@ | ||
/* | ||
* 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 React from 'react'; | ||
import { shallow } from 'enzyme'; | ||
import { ExceptionStacktrace } from './ExceptionStacktrace'; | ||
|
||
describe('ExceptionStacktrace', () => { | ||
describe('render', () => { | ||
it('renders', () => { | ||
const props = { exceptions: [] }; | ||
|
||
expect(() => | ||
shallow(<ExceptionStacktrace {...props} />) | ||
).not.toThrowError(); | ||
}); | ||
|
||
describe('with a stack trace', () => { | ||
it('renders the stack trace', () => { | ||
const props = { exceptions: [{}] }; | ||
|
||
expect( | ||
shallow(<ExceptionStacktrace {...props} />).find('Stacktrace') | ||
).toHaveLength(1); | ||
}); | ||
}); | ||
|
||
describe('with more than one stack trace', () => { | ||
it('renders a cause stack trace', () => { | ||
const props = { exceptions: [{}, {}] }; | ||
|
||
expect( | ||
shallow(<ExceptionStacktrace {...props} />).find('CauseStacktrace') | ||
).toHaveLength(1); | ||
}); | ||
}); | ||
}); | ||
}); |
49 changes: 49 additions & 0 deletions
49
...cy/plugins/apm/public/components/app/ErrorGroupDetails/DetailView/ExceptionStacktrace.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,49 @@ | ||
/* | ||
* 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 React from 'react'; | ||
import { EuiTitle } from '@elastic/eui'; | ||
import { idx } from '@kbn/elastic-idx/target'; | ||
import { Exception } from '../../../../../typings/es_schemas/raw/ErrorRaw'; | ||
import { Stacktrace } from '../../../shared/Stacktrace'; | ||
import { CauseStacktrace } from '../../../shared/Stacktrace/CauseStacktrace'; | ||
|
||
interface ExceptionStacktraceProps { | ||
codeLanguage?: string; | ||
exceptions: Exception[]; | ||
} | ||
|
||
export function ExceptionStacktrace({ | ||
codeLanguage, | ||
exceptions | ||
}: ExceptionStacktraceProps) { | ||
const title = idx(exceptions, _ => _[0].message); | ||
|
||
return ( | ||
<> | ||
<EuiTitle size="xs"> | ||
<h4>{title}</h4> | ||
</EuiTitle> | ||
{exceptions.map((ex, index) => { | ||
return index === 0 ? ( | ||
<Stacktrace | ||
key={index} | ||
stackframes={ex.stacktrace} | ||
codeLanguage={codeLanguage} | ||
/> | ||
) : ( | ||
<CauseStacktrace | ||
codeLanguage={codeLanguage} | ||
key={index} | ||
id={index.toString()} | ||
message={ex.message} | ||
stackframes={ex.stacktrace} | ||
/> | ||
); | ||
})} | ||
</> | ||
); | ||
} |
4 changes: 2 additions & 2 deletions
4
.../apm/public/components/app/ErrorGroupDetails/DetailView/__snapshots__/index.test.tsx.snap
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
20 changes: 0 additions & 20 deletions
20
x-pack/legacy/plugins/apm/public/components/shared/Icons.tsx
This file was deleted.
Oops, something went wrong.
52 changes: 52 additions & 0 deletions
52
x-pack/legacy/plugins/apm/public/components/shared/Stacktrace/CauseStacktrace.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,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 React from 'react'; | ||
import { mount, shallow } from 'enzyme'; | ||
import { CauseStacktrace } from './CauseStacktrace'; | ||
|
||
describe('CauseStacktrace', () => { | ||
describe('render', () => { | ||
describe('with no stack trace', () => { | ||
it('renders without the accordion', () => { | ||
const props = { id: 'testId', message: 'testMessage' }; | ||
|
||
expect( | ||
mount(<CauseStacktrace {...props} />).find('CausedBy') | ||
).toHaveLength(1); | ||
}); | ||
}); | ||
|
||
describe('with no message and a stack trace', () => { | ||
it('says "Caused by …', () => { | ||
const props = { | ||
id: 'testId', | ||
stackframes: [{ filename: 'testFilename', line: { number: 1 } }] | ||
}; | ||
|
||
expect( | ||
mount(<CauseStacktrace {...props} />) | ||
.find('EuiTitle span') | ||
.text() | ||
).toEqual('…'); | ||
}); | ||
}); | ||
|
||
describe('with a message and a stack trace', () => { | ||
it('renders with the accordion', () => { | ||
const props = { | ||
id: 'testId', | ||
message: 'testMessage', | ||
stackframes: [{ filename: 'testFilename', line: { number: 1 } }] | ||
}; | ||
|
||
expect( | ||
shallow(<CauseStacktrace {...props} />).find('Styled(EuiAccordion)') | ||
).toHaveLength(1); | ||
}); | ||
}); | ||
}); | ||
}); |
79 changes: 79 additions & 0 deletions
79
x-pack/legacy/plugins/apm/public/components/shared/Stacktrace/CauseStacktrace.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,79 @@ | ||
/* | ||
* 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 React from 'react'; | ||
import styled from 'styled-components'; | ||
import theme from '@elastic/eui/dist/eui_theme_light.json'; | ||
import { i18n } from '@kbn/i18n'; | ||
import { EuiAccordion, EuiTitle } from '@elastic/eui'; | ||
import { px, unit } from '../../../style/variables'; | ||
import { Stacktrace } from '.'; | ||
import { IStackframe } from '../../../../typings/es_schemas/raw/fields/Stackframe'; | ||
|
||
// @ts-ignore Styled Components has trouble inferring the types of the default props here. | ||
const Accordion = styled(EuiAccordion)` | ||
border-top: ${theme.euiBorderThin}; | ||
`; | ||
|
||
const CausedByContainer = styled('h5')` | ||
padding: ${theme.spacerSizes.s} 0; | ||
`; | ||
|
||
const CausedByHeading = styled('span')` | ||
color: ${theme.textColors.subdued}; | ||
display: block; | ||
font-size: ${theme.euiFontSizeXS}; | ||
font-weight: ${theme.euiFontWeightBold}; | ||
text-transform: uppercase; | ||
`; | ||
|
||
const FramesContainer = styled('div')` | ||
padding-left: ${px(unit)}; | ||
`; | ||
|
||
function CausedBy({ message }: { message: string }) { | ||
return ( | ||
<CausedByContainer> | ||
<CausedByHeading> | ||
{i18n.translate( | ||
'xpack.apm.stacktraceTab.causedByFramesToogleButtonLabel', | ||
{ | ||
defaultMessage: 'Caused By' | ||
} | ||
)} | ||
</CausedByHeading> | ||
<EuiTitle size="xxs"> | ||
<span>{message}</span> | ||
</EuiTitle> | ||
</CausedByContainer> | ||
); | ||
} | ||
|
||
interface CauseStacktraceProps { | ||
codeLanguage?: string; | ||
id: string; | ||
message?: string; | ||
stackframes?: IStackframe[]; | ||
} | ||
|
||
export function CauseStacktrace({ | ||
codeLanguage, | ||
id, | ||
message = '…', | ||
stackframes = [] | ||
}: CauseStacktraceProps) { | ||
if (stackframes.length === 0) { | ||
return <CausedBy message={message} />; | ||
} | ||
|
||
return ( | ||
<Accordion buttonContent={<CausedBy message={message} />} id={id}> | ||
<FramesContainer> | ||
<Stacktrace stackframes={stackframes} codeLanguage={codeLanguage} /> | ||
</FramesContainer> | ||
</Accordion> | ||
); | ||
} |
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
Oops, something went wrong.