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

fix readme: setting labelKeys when creating the counter #1056

Merged
merged 1 commit into from
May 14, 2020
Merged
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
9 changes: 6 additions & 3 deletions packages/opentelemetry-exporter-prometheus/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,15 @@ const meter = new MeterProvider({
}).getMeter('example-prometheus');

// Now, start recording data
const counter = meter.createCounter('metric_name');
counter.add(10, { [key]: 'value' });
const counter = meter.createCounter('metric_name', {
labelKeys: ['pid'],
description: 'Example of a counter'
});
counter.add(10, { pid: process.pid });

// Record data using Instrument: It is recommended to keep a reference to the Bound Instrument instead of
// always calling `bind()` method for every operations.
const boundCounter = counter.bind({ [key]: 'value' });
const boundCounter = counter.bind({ pid: process.pid });
boundCounter.add(10);

// .. some other work
Expand Down