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] Add User agent to trace summary #47526

Merged
merged 2 commits into from
Oct 8, 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 @@ -39,6 +39,7 @@ import { Summary } from '../../../shared/Summary';
import { TimestampSummaryItem } from '../../../shared/Summary/TimestampSummaryItem';
import { HttpInfoSummaryItem } from '../../../shared/Summary/HttpInfoSummaryItem';
import { TransactionDetailLink } from '../../../shared/Links/apm/TransactionDetailLink';
import { UserAgentSummaryItem } from '../../../shared/Summary/UserAgentSummaryItem';

const HeaderContainer = styled.div`
display: flex;
Expand Down Expand Up @@ -121,6 +122,9 @@ export function DetailView({ errorGroup, urlParams, location }: Props) {
status={status}
/>
) : null,
transaction && transaction.user_agent ? (
<UserAgentSummaryItem {...transaction.user_agent} />
) : null,
transaction && (
<EuiToolTip
content={i18n.translate(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { ErrorCountSummaryItem } from './ErrorCountSummaryItem';
import { isRumAgentName } from '../../../../common/agent_name';
import { HttpInfoSummaryItem } from './HttpInfoSummaryItem';
import { TransactionResultSummaryItem } from './TransactionResultSummaryItem';
import { UserAgentSummaryItem } from './UserAgentSummaryItem';

interface Props {
transaction: Transaction;
Expand Down Expand Up @@ -54,7 +55,10 @@ const TransactionSummary = ({
parentType="trace"
/>,
getTransactionResultSummaryItem(transaction),
errorCount ? <ErrorCountSummaryItem count={errorCount} /> : null
errorCount ? <ErrorCountSummaryItem count={errorCount} /> : null,
transaction.user_agent ? (
<UserAgentSummaryItem {...transaction.user_agent} />
) : null
];

return <Summary items={items}></Summary>;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
* 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, render } from 'enzyme';
import { UserAgentSummaryItem } from './UserAgentSummaryItem';

describe('UserAgentSummaryItem', () => {
describe('render', () => {
const props = { original: 'Other' };

it('renders', () => {
expect(() =>
shallow(<UserAgentSummaryItem {...props} />)
).not.toThrowError();
});

describe('with a version', () => {
it('shows the version', () => {
const p = { ...props, version: '1.0' };
const wrapper = render(<UserAgentSummaryItem {...p} />);

expect(wrapper.text()).toContain('(1.0)');
});
});
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* 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 { EuiToolTip } from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import { UserAgent } from '../../../../typings/es_schemas/raw/fields/UserAgent';

type UserAgentSummaryItemProps = UserAgent;

const Version = styled('span')`
color: ${theme.textColors.subdued};
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we can remove the subdued text here and make it consistent with how we display the trace % in the other part of the summary.

font-size: ${theme.euiFontSizeS};
`;

export function UserAgentSummaryItem({
name,
version
}: UserAgentSummaryItemProps) {
return (
<EuiToolTip
content={i18n.translate('xpack.apm.transactionDetails.userAgentLabel', {
defaultMessage: 'User agent'
Copy link
Contributor

Choose a reason for hiding this comment

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

Perhaps just "User agent & version" as the default message as that's what is expected to display.

})}
>
<>
{name}&nbsp;
{version && <Version>({version})</Version>}
</>
</EuiToolTip>
);
}