Skip to content

Commit

Permalink
chore(extension-metrics): simplify configuration object
Browse files Browse the repository at this point in the history
  • Loading branch information
raymondfeng committed Oct 17, 2019
1 parent a7f9ad0 commit d836347
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 15 deletions.
4 changes: 1 addition & 3 deletions extensions/metrics/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,7 @@ this.configure(MetricsBindings.COMPONENT).to({
basePath: '/metrics',
},
defaultMetrics: {
options: {
timeout: 5000,
},
timeout: 5000,
},
});
```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions extensions/metrics/src/observers/metrics.observer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
8 changes: 2 additions & 6 deletions extensions/metrics/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,12 @@ export interface MetricsOptions {

defaultMetrics?: {
disabled?: boolean;
options?: DefaultMetricsCollectorConfiguration;
};
} & DefaultMetricsCollectorConfiguration;

pushGateway?: {
disabled?: boolean;
url: string;
interval?: number;
options?: object;
};
}

Expand All @@ -29,8 +27,6 @@ export const DEFAULT_METRICS_OPTIONS: MetricsOptions = {
basePath: '/metrics',
},
defaultMetrics: {
options: {
timeout: 5000,
},
timeout: 5000,
},
};

0 comments on commit d836347

Please sign in to comment.