Skip to content

Commit

Permalink
docs(prometheus-exporter): fix prometheus exporter examples in README (
Browse files Browse the repository at this point in the history
…#3110)


Co-authored-by: Daniel Dyla <dyladan@users.noreply.github.com>
  • Loading branch information
legendecas and dyladan authored Aug 17, 2022
1 parent 43f4e5a commit 34c5bdb
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
12 changes: 6 additions & 6 deletions experimental/packages/opentelemetry-api-metrics/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,12 @@ const api = require("@opentelemetry/api-metrics");
const { MeterProvider } = require("@opentelemetry/sdk-metrics");
const { PrometheusExporter } = require("@opentelemetry/exporter-prometheus");

const meterProvider = new MeterProvider({
// The Prometheus exporter runs an HTTP server which
// the Prometheus backend scrapes to collect metrics.
exporter: new PrometheusExporter({ startServer: true }),
interval: 1000,
});
// The Prometheus exporter runs an HTTP server which the Prometheus backend
// scrapes to collect metrics.
const exporter = new PrometheusExporter({ startServer: true });
// Creates MeterProvider and installs the exporter as a MetricReader
const meterProvider = new MeterProvider();
meterProvider.addMetricReader(exporter);

/**
* Registering the provider with the API allows it to be discovered
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,10 @@ const { MeterProvider } = require('@opentelemetry/sdk-metrics');
const options = {port: 9464, startServer: true};
const exporter = new PrometheusExporter(options);

// Register the exporter
const meter = new MeterProvider({
exporter,
interval: 1000,
}).getMeter('example-prometheus');
// Creates MeterProvider and installs the exporter as a MetricReader
const meterProvider = new MeterProvider();
meterProvider.addMetricReader(exporter);
const meter = meterProvider.getMeter('example-prometheus');

// Now, start recording data
const counter = meter.createCounter('metric_name', {
Expand Down

0 comments on commit 34c5bdb

Please sign in to comment.