Skip to content
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] Transaction page throws unhandled exception if transactions doesn't have http.request #53760

Merged
merged 2 commits into from
Dec 24, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -126,4 +126,31 @@ describe('DetailView', () => {
expect(wrapper.exists()).toBe(true);
expect(wrapper).toMatchSnapshot();
});

it('should render without http request info', () => {
const errorGroup = {
occurrencesCount: 10,
transaction: undefined,
error: {
timestamp: {
us: 0
},
http: { response: { status_code: 404 } },
url: { full: 'myUrl' },
service: { name: 'myService' },
user: { id: 'myUserId' },
error: { exception: { handled: true } },
transaction: { id: 'myTransactionId', sampled: true }
} as any
};
expect(() =>
shallow(
<DetailView
errorGroup={errorGroup}
urlParams={{}}
location={{} as Location}
/>
)
).not.toThrowError();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export function DetailView({ errorGroup, urlParams, location }: Props) {

const errorUrl = error.error.page?.url || error.url?.full;

const method = error.http?.request.method;
const method = error.http?.request?.method;
const status = error.http?.response?.status_code;

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,21 @@ describe('TransactionSummary', () => {
transaction
};

it('renders', () => {
expect(() =>
shallow(<TransactionSummary {...props} />)
).not.toThrowError();
});
});
describe('renders RUM transaction without request info', () => {
const transaction: Transaction = exampleTransactions.httpRumOK;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think you need the explicit type

Suggested change
const transaction: Transaction = exampleTransactions.httpRumOK;
const transaction = exampleTransactions.httpRumOK;


const props = {
errorCount: 0,
totalDuration: 0,
transaction
};

it('renders', () => {
expect(() =>
shallow(<TransactionSummary {...props} />)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const getTransactionResultSummaryItem = (transaction: Transaction) => {
: transaction.url?.full;

if (url) {
const method = transaction.http?.request.method;
const method = transaction.http?.request?.method;
const status = transaction.http?.response?.status_code;

return <HttpInfoSummaryItem method={method} status={status} url={url} />;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,25 @@ export const httpOk: Transaction = {
duration: { us: 0 }
}
};

export const httpRumOK: Transaction = {
'@timestamp': '0',
agent: { name: 'rum-js', version: '0' },
http: {
response: { status_code: 200 }
},
processor: { event: 'transaction', name: 'transaction' },
service: { name: 'testServiceName' },
timestamp: { us: 0 },
trace: { id: 'testTrace' },
transaction: {
page: {
url: 'elastic.co'
},
name: 'testTransaction',
id: 'testId',
sampled: false,
type: 'testType',
duration: { us: 0 }
}
};
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/

export interface Http {
request: { method: string; [key: string]: unknown };
request?: { method: string; [key: string]: unknown };
response?: { status_code: number; [key: string]: unknown };
version?: string;
}