Skip to content

Commit

Permalink
feat: make prometheus config preventServerStart optional (#1375)
Browse files Browse the repository at this point in the history
* feat: make prometheus config startServer mandatory

* fix: degrade log level on startServer is false

* fix: remove the log on not starting server

* fix: callbacks shall be called asynchronously unconditionally

* fixup!: update the options with `preventServerStart`
  • Loading branch information
legendecas authored Sep 29, 2020
1 parent 75fc663 commit 24ffd16
Show file tree
Hide file tree
Showing 3 changed files with 159 additions and 187 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import { PrometheusLabelsBatcher } from './PrometheusLabelsBatcher';
export class PrometheusExporter implements MetricExporter {
static readonly DEFAULT_OPTIONS = {
port: 9464,
startServer: false,
endpoint: '/metrics',
prefix: '',
};
Expand Down Expand Up @@ -59,7 +58,7 @@ export class PrometheusExporter implements MetricExporter {
config.endpoint || PrometheusExporter.DEFAULT_OPTIONS.endpoint
).replace(/^([^/])/, '/$1');

if (config.startServer || PrometheusExporter.DEFAULT_OPTIONS.startServer) {
if (config.preventServerStart !== true) {
this.startServer().then(callback);
} else if (callback) {
callback();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ export interface ExporterConfig {
port?: number;

/**
* Define if the Prometheus exporter server will be started
* Prevent the Prometheus exporter server from starting
* @default false
*/
startServer?: boolean;
preventServerStart?: boolean;

/** Standard logging interface */
logger?: api.Logger;
Expand Down
Loading

0 comments on commit 24ffd16

Please sign in to comment.