Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs(prometheus-exporter): fix prometheus exporter examples in README #3110

Merged
merged 7 commits into from
Aug 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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