From 11430bb057fef3d5ad177b5233485df5190e9b5b Mon Sep 17 00:00:00 2001 From: orthagonal Date: Mon, 15 Oct 2018 21:41:58 +0000 Subject: [PATCH] working --- conf/default-envs.yaml | 1 + conf/default.yaml | 1 + test/initialize.test.js | 2 ++ 3 files changed, 4 insertions(+) diff --git a/conf/default-envs.yaml b/conf/default-envs.yaml index 74cc83e..a958057 100644 --- a/conf/default-envs.yaml +++ b/conf/default-envs.yaml @@ -5,6 +5,7 @@ envVars: routePrefix: "{{ getEnv('ROUTE_PREFIX', getEnv('PATH_PREFIX', '')) }}" healthToken: "{{ getEnv('HEALTH_TOKEN', false) }}" enableProm: '{{ truthy(ENV.ENABLE_PROM)}}' + promDefaults: '{{ truthy(ENV.PROM_DEFAULTS)}}' promPath: "{{ getEnv('PROM_PATH', '/metrics') }}" forceHttps: '{{ truthy(getEnv("FORCE_HTTPS", false)) }}' logRequests: '{{ truthy(ENV.ACCESS_LOGS) }}' diff --git a/conf/default.yaml b/conf/default.yaml index 26b866b..b4fb158 100644 --- a/conf/default.yaml +++ b/conf/default.yaml @@ -23,6 +23,7 @@ plugins: hapi-prom: _enabled: "{{ envVars.enableProm }}" metricsPath: "{{ envVars.promPath }}" + defaultMetrics: "{{ envVars.promDefaults}}" hapi-logr: unhandledRejection: true uncaughtException: true diff --git a/test/initialize.test.js b/test/initialize.test.js index 4c2dce3..e5f5ad5 100644 --- a/test/initialize.test.js +++ b/test/initialize.test.js @@ -85,6 +85,7 @@ tap.test('server stops when SIGTERM event is emitted ', async t => { tap.test('be able to conditionally load hapi-prom', async t => { process.env.ENABLE_PROM = true; + process.env.PROM_DEFAULTS = true; const rapptor = new Rapptor({ cwd: __dirname, }); @@ -94,6 +95,7 @@ tap.test('be able to conditionally load hapi-prom', async t => { url: '/metrics' }); t.equal(response.statusCode, 200, 'registers hapi-prom route'); + t.match(response.result, 'nodejs_heap_space_size_total_bytes', 'ENV.PROM_DEFAULTS registers default metrics'); await rapptor.stop(); t.end(); });