From 144e11ab704f90a15e76c22df13a8ee927a3bc61 Mon Sep 17 00:00:00 2001 From: naseemkullah <24660299+naseemkullah@users.noreply.github.com> Date: Tue, 22 Feb 2022 14:51:54 -0500 Subject: [PATCH] docs(prom-example): remove deprecated startServer option (#2802) Co-authored-by: Valentin Marchaud --- examples/prometheus/index.js | 17 +++++++-------- .../examples/metrics/metrics/observer.js | 21 ++++++++----------- 2 files changed, 16 insertions(+), 22 deletions(-) diff --git a/examples/prometheus/index.js b/examples/prometheus/index.js index ea3f2e6882..8f638d66a1 100644 --- a/examples/prometheus/index.js +++ b/examples/prometheus/index.js @@ -3,16 +3,13 @@ const { MeterProvider } = require('@opentelemetry/sdk-metrics-base'); const { PrometheusExporter } = require('@opentelemetry/exporter-prometheus'); -const exporter = new PrometheusExporter( - { - startServer: true, - }, - () => { - console.log( - `prometheus scrape endpoint: http://localhost:${PrometheusExporter.DEFAULT_OPTIONS.port}${PrometheusExporter.DEFAULT_OPTIONS.endpoint}`, - ); - }, -); +const { endpoint, port } = PrometheusExporter.DEFAULT_OPTIONS; + +const exporter = new PrometheusExporter({}, () => { + console.log( + `prometheus scrape endpoint: http://localhost:${port}${endpoint}`, + ); +}); const meter = new MeterProvider({ exporter, diff --git a/experimental/packages/opentelemetry-sdk-metrics-base/examples/metrics/metrics/observer.js b/experimental/packages/opentelemetry-sdk-metrics-base/examples/metrics/metrics/observer.js index 2f3d3f9a53..87d0e3817c 100644 --- a/experimental/packages/opentelemetry-sdk-metrics-base/examples/metrics/metrics/observer.js +++ b/experimental/packages/opentelemetry-sdk-metrics-base/examples/metrics/metrics/observer.js @@ -7,16 +7,13 @@ const { PrometheusExporter } = require('@opentelemetry/exporter-prometheus'); // Optional and only needed to see the internal diagnostic logging (during development) diag.setLogger(new DiagConsoleLogger(), DiagLogLevel.DEBUG); -const exporter = new PrometheusExporter( - { - startServer: true, - }, - () => { - console.log( - `prometheus scrape endpoint: http://localhost:${PrometheusExporter.DEFAULT_OPTIONS.port}${PrometheusExporter.DEFAULT_OPTIONS.endpoint}`, - ); - }, -); +const { endpoint, port } = PrometheusExporter.DEFAULT_OPTIONS; + +const exporter = new PrometheusExporter({}, () => { + console.log( + `prometheus scrape endpoint: http://localhost:${port}${endpoint}`, + ); +}); const meter = new MeterProvider({ exporter, @@ -34,12 +31,12 @@ meter.createObservableGauge('cpu_core_usage', { function getAsyncValue() { return new Promise((resolve) => { - setTimeout(()=> { + setTimeout(() => { resolve(Math.random()); }, 100); }); } -setInterval(function(){ +setInterval(function () { console.log("simulating an app being kept open") }, 5000);