Skip to content

Commit

Permalink
[APM] Agent configuration phase 2 (#46995)
Browse files Browse the repository at this point in the history
* [APM] Agent Config Management Phase 2

* Add status indicator

* Extract TimestampTooltip component

* Remove unused StickyTransactionProperties component

* Fix snapshot and minor cleanup

* Minor cleanup

* Display settings conditionally by agent name

* Fix client

* Format timestamp

* Minor design feedback

* Clear cache when clicking refresh

* Fix test

* Revert t() short hand

* Fix translations

* Add support for “all” option

* Fix API tests

* Move delete button to footer

* Fix snapshots

* Add API tests

* Fix toasts

* Address feedback and ensure order when searching for configs

* Fix snapshots

* Remove timeout
  • Loading branch information
sorenlouv committed Oct 10, 2019
1 parent c933d2d commit 79fb749
Show file tree
Hide file tree
Showing 62 changed files with 1,884 additions and 1,565 deletions.
25 changes: 25 additions & 0 deletions x-pack/legacy/plugins/apm/common/agent_configuration_constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
* 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';

export const ALL_OPTION_VALUE = 'ALL_OPTION_VALUE';

// human-readable label for the option. The "All" option should be translated.
// Everything else should be returned verbatim
export function getOptionLabel(value: string | undefined) {
if (value === undefined || value === ALL_OPTION_VALUE) {
return i18n.translate('xpack.apm.settings.agentConf.allOptionLabel', {
defaultMessage: 'All'
});
}

return value;
}

export function omitAllOption(value: string) {
return value === ALL_OPTION_VALUE ? undefined : value;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
* 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 { transactionMaxSpansRt } from './index';
import { isRight } from 'fp-ts/lib/Either';

describe('transactionMaxSpans', () => {
it('does not accept empty values', () => {
expect(isRight(transactionMaxSpansRt.decode(undefined))).toBe(false);
expect(isRight(transactionMaxSpansRt.decode(null))).toBe(false);
expect(isRight(transactionMaxSpansRt.decode(''))).toBe(false);
});

it('accepts both strings and numbers as values', () => {
expect(isRight(transactionMaxSpansRt.decode('55'))).toBe(true);
expect(isRight(transactionMaxSpansRt.decode(55))).toBe(true);
});

it('checks if the number falls within 0, 32000', () => {
expect(isRight(transactionMaxSpansRt.decode(0))).toBe(true);
expect(isRight(transactionMaxSpansRt.decode(32000))).toBe(true);
expect(isRight(transactionMaxSpansRt.decode(-55))).toBe(false);
expect(isRight(transactionMaxSpansRt.decode(NaN))).toBe(false);
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/*
* 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 * as t from 'io-ts';

export const transactionMaxSpansRt = new t.Type<number, number, unknown>(
'transactionMaxSpans',
t.number.is,
(input, context) => {
const value = parseInt(input as string, 10);
return value >= 0 && value <= 32000
? t.success(value)
: t.failure(input, context);
},
t.identity
);
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ import { transactionSampleRateRt } from './index';
import { isRight } from 'fp-ts/lib/Either';

describe('transactionSampleRateRt', () => {
it('does not accept empty values', () => {
expect(isRight(transactionSampleRateRt.decode(undefined))).toBe(false);
expect(isRight(transactionSampleRateRt.decode(null))).toBe(false);
expect(isRight(transactionSampleRateRt.decode(''))).toBe(false);
});

it('accepts both strings and numbers as values', () => {
expect(isRight(transactionSampleRateRt.decode('0.5'))).toBe(true);
expect(isRight(transactionSampleRateRt.decode(0.5))).toBe(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ export const transactionSampleRateRt = new t.Type<number, number, unknown>(
'TransactionSampleRate',
t.number.is,
(input, context) => {
const value = Number(input);
return value >= 0 && value <= 1 && Number(value.toFixed(3)) === value
const value = parseFloat(input as string);
return value >= 0 && value <= 1 && parseFloat(value.toFixed(3)) === value
? t.success(value)
: t.failure(input, context);
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import {
logStacktraceTab
} from './ErrorTabs';
import { Summary } from '../../../shared/Summary';
import { TimestampSummaryItem } from '../../../shared/Summary/TimestampSummaryItem';
import { TimestampTooltip } from '../../../shared/TimestampTooltip';
import { HttpInfoSummaryItem } from '../../../shared/Summary/HttpInfoSummaryItem';
import { TransactionDetailLink } from '../../../shared/Links/apm/TransactionDetailLink';
import { UserAgentSummaryItem } from '../../../shared/Summary/UserAgentSummaryItem';
Expand Down Expand Up @@ -114,7 +114,7 @@ export function DetailView({ errorGroup, urlParams, location }: Props) {

<Summary
items={[
<TimestampSummaryItem time={error.timestamp.us / 1000} />,
<TimestampTooltip time={error.timestamp.us / 1000} />,
errorUrl && method ? (
<HttpInfoSummaryItem
url={errorUrl}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { TransactionDetails } from '../../TransactionDetails';
import { Home } from '../../Home';
import { BreadcrumbRoute } from '../ProvideBreadcrumbs';
import { RouteName } from './route_names';
import { Settings } from '../../Settings';
import { AgentConfigurations } from '../../Settings/AgentConfigurations';
import { toQuery } from '../../../shared/Links/url_helpers';
import { ServiceNodeMetrics } from '../../ServiceNodeMetrics';
import { resolveUrlParams } from '../../../../context/UrlParamsContext/resolveUrlParams';
Expand Down Expand Up @@ -67,7 +67,7 @@ export const routes: BreadcrumbRoute[] = [
{
exact: true,
path: '/settings',
component: Settings,
component: AgentConfigurations,
breadcrumb: i18n.translate('xpack.apm.breadcrumb.listSettingsTitle', {
defaultMessage: 'Settings'
}),
Expand Down
Loading

0 comments on commit 79fb749

Please sign in to comment.