docs(prom-example): remove deprecated startServer option (#2802)
Co-authored-by: Valentin Marchaud <contact@vmarchaud.fr>
This commit is contained in:
parent
630a26182a
commit
144e11ab70
|
|
@ -3,16 +3,13 @@
|
||||||
const { MeterProvider } = require('@opentelemetry/sdk-metrics-base');
|
const { MeterProvider } = require('@opentelemetry/sdk-metrics-base');
|
||||||
const { PrometheusExporter } = require('@opentelemetry/exporter-prometheus');
|
const { PrometheusExporter } = require('@opentelemetry/exporter-prometheus');
|
||||||
|
|
||||||
const exporter = new PrometheusExporter(
|
const { endpoint, port } = PrometheusExporter.DEFAULT_OPTIONS;
|
||||||
{
|
|
||||||
startServer: true,
|
const exporter = new PrometheusExporter({}, () => {
|
||||||
},
|
|
||||||
() => {
|
|
||||||
console.log(
|
console.log(
|
||||||
`prometheus scrape endpoint: http://localhost:${PrometheusExporter.DEFAULT_OPTIONS.port}${PrometheusExporter.DEFAULT_OPTIONS.endpoint}`,
|
`prometheus scrape endpoint: http://localhost:${port}${endpoint}`,
|
||||||
);
|
);
|
||||||
},
|
});
|
||||||
);
|
|
||||||
|
|
||||||
const meter = new MeterProvider({
|
const meter = new MeterProvider({
|
||||||
exporter,
|
exporter,
|
||||||
|
|
|
||||||
|
|
@ -7,16 +7,13 @@ const { PrometheusExporter } = require('@opentelemetry/exporter-prometheus');
|
||||||
// Optional and only needed to see the internal diagnostic logging (during development)
|
// Optional and only needed to see the internal diagnostic logging (during development)
|
||||||
diag.setLogger(new DiagConsoleLogger(), DiagLogLevel.DEBUG);
|
diag.setLogger(new DiagConsoleLogger(), DiagLogLevel.DEBUG);
|
||||||
|
|
||||||
const exporter = new PrometheusExporter(
|
const { endpoint, port } = PrometheusExporter.DEFAULT_OPTIONS;
|
||||||
{
|
|
||||||
startServer: true,
|
const exporter = new PrometheusExporter({}, () => {
|
||||||
},
|
|
||||||
() => {
|
|
||||||
console.log(
|
console.log(
|
||||||
`prometheus scrape endpoint: http://localhost:${PrometheusExporter.DEFAULT_OPTIONS.port}${PrometheusExporter.DEFAULT_OPTIONS.endpoint}`,
|
`prometheus scrape endpoint: http://localhost:${port}${endpoint}`,
|
||||||
);
|
);
|
||||||
},
|
});
|
||||||
);
|
|
||||||
|
|
||||||
const meter = new MeterProvider({
|
const meter = new MeterProvider({
|
||||||
exporter,
|
exporter,
|
||||||
|
|
@ -34,12 +31,12 @@ meter.createObservableGauge('cpu_core_usage', {
|
||||||
|
|
||||||
function getAsyncValue() {
|
function getAsyncValue() {
|
||||||
return new Promise((resolve) => {
|
return new Promise((resolve) => {
|
||||||
setTimeout(()=> {
|
setTimeout(() => {
|
||||||
resolve(Math.random());
|
resolve(Math.random());
|
||||||
}, 100);
|
}, 100);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
setInterval(function(){
|
setInterval(function () {
|
||||||
console.log("simulating an app being kept open")
|
console.log("simulating an app being kept open")
|
||||||
}, 5000);
|
}, 5000);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue