From 121b03d5ef3a2dbe8d2b40ba8d124cc627d396a3 Mon Sep 17 00:00:00 2001 From: Naseem Date: Thu, 4 Jun 2020 14:39:42 -0400 Subject: [PATCH] chore: template prometheus endpoint in examples rather than hardcode (#1142) Signed-off-by: Naseem --- examples/metrics/metrics/observer.js | 4 +++- examples/prometheus/index.js | 4 +++- getting-started/README.md | 7 ++++++- getting-started/monitored-example/monitoring.js | 4 +++- getting-started/ts-example/README.md | 7 ++++++- getting-started/ts-example/monitoring.ts | 4 +++- 6 files changed, 24 insertions(+), 6 deletions(-) diff --git a/examples/metrics/metrics/observer.js b/examples/metrics/metrics/observer.js index 6cced2142c..c73d8f67f4 100644 --- a/examples/metrics/metrics/observer.js +++ b/examples/metrics/metrics/observer.js @@ -8,7 +8,9 @@ const exporter = new PrometheusExporter( startServer: true, }, () => { - console.log('prometheus scrape endpoint: http://localhost:9464/metrics'); + console.log( + `prometheus scrape endpoint: http://localhost:${PrometheusExporter.DEFAULT_OPTIONS.port}${PrometheusExporter.DEFAULT_OPTIONS.endpoint}`, + ); }, ); diff --git a/examples/prometheus/index.js b/examples/prometheus/index.js index 5d9b52c17a..24b4c4bfa2 100644 --- a/examples/prometheus/index.js +++ b/examples/prometheus/index.js @@ -8,7 +8,9 @@ const exporter = new PrometheusExporter( startServer: true, }, () => { - console.log('prometheus scrape endpoint: http://localhost:9464/metrics'); + console.log( + `prometheus scrape endpoint: http://localhost:${PrometheusExporter.DEFAULT_OPTIONS.port}${PrometheusExporter.DEFAULT_OPTIONS.endpoint}`, + ); }, ); diff --git a/getting-started/README.md b/getting-started/README.md index ce7b341dc5..531c434797 100644 --- a/getting-started/README.md +++ b/getting-started/README.md @@ -303,12 +303,17 @@ Next, modify your `monitoring.js` file to look like this: const { MeterProvider } = require('@opentelemetry/metrics'); const { PrometheusExporter } = require('@opentelemetry/exporter-prometheus'); +const prometheusPort = PrometheusExporter.DEFAULT_OPTIONS.port +const prometheusEndpoint = PrometheusExporter.DEFAULT_OPTIONS.endpoint + const exporter = new PrometheusExporter( { startServer: true, }, () => { - console.log('prometheus scrape endpoint: http://localhost:9464/metrics'); + console.log( + `prometheus scrape endpoint: http://localhost:${prometheusPort}${Prometheusendpoint}`, + ); }, ); diff --git a/getting-started/monitored-example/monitoring.js b/getting-started/monitored-example/monitoring.js index 3f34387711..42b37385e4 100644 --- a/getting-started/monitored-example/monitoring.js +++ b/getting-started/monitored-example/monitoring.js @@ -8,7 +8,9 @@ const exporter = new PrometheusExporter( startServer: true, }, () => { - console.log('prometheus scrape endpoint: http://localhost:9464/metrics'); + console.log( + `prometheus scrape endpoint: http://localhost:${PrometheusExporter.DEFAULT_OPTIONS.port}${PrometheusExporter.DEFAULT_OPTIONS.endpoint}`, + ); }, ); diff --git a/getting-started/ts-example/README.md b/getting-started/ts-example/README.md index 4414049bf7..daa91c50e6 100644 --- a/getting-started/ts-example/README.md +++ b/getting-started/ts-example/README.md @@ -301,12 +301,17 @@ import { MeterProvider } from '@opentelemetry/metrics'; import { Metric, BoundCounter } from '@opentelemetry/api'; import { PrometheusExporter } from '@opentelemetry/exporter-prometheus'; +const prometheusPort = PrometheusExporter.DEFAULT_OPTIONS.port +const prometheusEndpoint = PrometheusExporter.DEFAULT_OPTIONS.endpoint + const exporter = new PrometheusExporter( { startServer: true, }, () => { - console.log('prometheus scrape endpoint: http://localhost:9464/metrics'); + console.log( + `prometheus scrape endpoint: http://localhost:${prometheusPort}${Prometheusendpoint}`, + ); }, ); diff --git a/getting-started/ts-example/monitoring.ts b/getting-started/ts-example/monitoring.ts index a7e544d762..0e08363aab 100644 --- a/getting-started/ts-example/monitoring.ts +++ b/getting-started/ts-example/monitoring.ts @@ -7,7 +7,9 @@ const exporter = new PrometheusExporter( startServer: true, }, () => { - console.log('prometheus scrape endpoint: http://localhost:9464/metrics'); + console.log( + `prometheus scrape endpoint: http://localhost:${PrometheusExporter.DEFAULT_OPTIONS.port}${PrometheusExporter.DEFAULT_OPTIONS.endpoint}`, + ); }, );