Skip to content

Commit

Permalink
docs(prom-example): remove deprecated startServer opt
Browse files Browse the repository at this point in the history
Also, destructure DEFAULT OPTIONS to get port and endpoint

Signed-off-by: Naseem Ullah <24660299+naseemkullah@users.noreply.github.com>
  • Loading branch information
naseemkullah committed Feb 22, 2022
1 parent b756b7c commit 48dc997
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 22 deletions.
17 changes: 7 additions & 10 deletions examples/prometheus/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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);

0 comments on commit 48dc997

Please sign in to comment.