From d836347afb58249964deb0d9bc4c2b1b18a9fec6 Mon Sep 17 00:00:00 2001 From: Raymond Feng Date: Fri, 20 Sep 2019 08:34:43 -0700 Subject: [PATCH] chore(extension-metrics): simplify configuration object --- extensions/metrics/README.md | 4 +--- .../src/__tests__/acceptance/metrics.acceptance.ts | 6 ++---- extensions/metrics/src/observers/metrics.observer.ts | 3 +-- extensions/metrics/src/types.ts | 8 ++------ 4 files changed, 6 insertions(+), 15 deletions(-) diff --git a/extensions/metrics/README.md b/extensions/metrics/README.md index b1670937860e..c36682b55357 100644 --- a/extensions/metrics/README.md +++ b/extensions/metrics/README.md @@ -42,9 +42,7 @@ this.configure(MetricsBindings.COMPONENT).to({ basePath: '/metrics', }, defaultMetrics: { - options: { - timeout: 5000, - }, + timeout: 5000, }, }); ``` diff --git a/extensions/metrics/src/__tests__/acceptance/metrics.acceptance.ts b/extensions/metrics/src/__tests__/acceptance/metrics.acceptance.ts index cb0496f0c925..7eef91ab337b 100644 --- a/extensions/metrics/src/__tests__/acceptance/metrics.acceptance.ts +++ b/extensions/metrics/src/__tests__/acceptance/metrics.acceptance.ts @@ -45,10 +45,8 @@ describe('Metrics (acceptance)', () => { it('honors prefix', async () => { await givenAppWithCustomConfig({ defaultMetrics: { - options: { - // `-` is not allowed - prefix: 'myapp_', - }, + // `-` is not allowed + prefix: 'myapp_', }, }); await request diff --git a/extensions/metrics/src/observers/metrics.observer.ts b/extensions/metrics/src/observers/metrics.observer.ts index 2359971c95dd..1db72c17d897 100644 --- a/extensions/metrics/src/observers/metrics.observer.ts +++ b/extensions/metrics/src/observers/metrics.observer.ts @@ -17,8 +17,7 @@ export class MetricsObserver implements LifeCycleObserver { ) {} start() { - const defaultMetricsConfig = - this.options.defaultMetrics && this.options.defaultMetrics.options; + const defaultMetricsConfig = this.options.defaultMetrics; this.interval = collectDefaultMetrics(defaultMetricsConfig); } diff --git a/extensions/metrics/src/types.ts b/extensions/metrics/src/types.ts index acbd63542aa1..5df3d8241c1c 100644 --- a/extensions/metrics/src/types.ts +++ b/extensions/metrics/src/types.ts @@ -13,14 +13,12 @@ export interface MetricsOptions { defaultMetrics?: { disabled?: boolean; - options?: DefaultMetricsCollectorConfiguration; - }; + } & DefaultMetricsCollectorConfiguration; pushGateway?: { disabled?: boolean; url: string; interval?: number; - options?: object; }; } @@ -29,8 +27,6 @@ export const DEFAULT_METRICS_OPTIONS: MetricsOptions = { basePath: '/metrics', }, defaultMetrics: { - options: { - timeout: 5000, - }, + timeout: 5000, }, };