Skip to content

Commit

Permalink
fix: setting labelKeys when creating the counter (#1056)
Browse files Browse the repository at this point in the history
  • Loading branch information
luebken authored May 14, 2020
1 parent 7ccf1d0 commit c0aad1d
Showing 1 changed file with 6 additions and 3 deletions.
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

0 comments on commit c0aad1d

Please sign in to comment.