Skip to content

Commit

Permalink
[APM] Add User agent to trace summary
Browse files Browse the repository at this point in the history
  • Loading branch information
smith committed Oct 7, 2019
1 parent c30a2f9 commit 583deb8
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 1 deletion.
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};
font-size: ${theme.euiFontSizeS};
`;

export function UserAgentSummaryItem({
name,
version
}: UserAgentSummaryItemProps) {
return (
<EuiToolTip
content={i18n.translate('xpack.apm.transactionDetails.userAgentLabel', {
defaultMessage: 'User agent'
})}
>
<>
{name}&nbsp;
{version && <Version>({version})</Version>}
</>
</EuiToolTip>
);
}

0 comments on commit 583deb8

Please sign in to comment.