-
Notifications
You must be signed in to change notification settings - Fork 365
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Added support for OpenMetrics format, including exemplars - Added support for exemplars with OpenTelemetry tracing data on default metrics - Added the option of passing params as one object to observe() and inc() methods
- Loading branch information
Showing
42 changed files
with
1,009 additions
and
151 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
'use strict'; | ||
|
||
const { register, Registry, Counter, Histogram } = require('..'); | ||
|
||
async function makeCounters() { | ||
const c = new Counter({ | ||
name: 'test_counter_exemplar', | ||
help: 'Example of a counter with exemplar', | ||
labelNames: ['code'], | ||
enableExemplars: true, | ||
}); | ||
|
||
const exemplarLabels = { traceId: '888', spanId: 'jjj' }; | ||
|
||
c.inc({ | ||
labels: { code: 300 }, | ||
value: 1, | ||
exemplarLabels, | ||
}); | ||
c.inc({ | ||
labels: { code: 200 }, | ||
exemplarLabels, | ||
}); | ||
|
||
c.inc({ exemplarLabels }); | ||
c.inc(); | ||
} | ||
|
||
async function makeHistograms() { | ||
const h = new Histogram({ | ||
name: 'test_histogram_exemplar', | ||
help: 'Example of a histogram with exemplar', | ||
labelNames: ['code'], | ||
enableExemplars: true, | ||
}); | ||
|
||
const exemplarLabels = { traceId: '111', spanId: 'zzz' }; | ||
|
||
h.observe({ | ||
labels: { code: '200' }, | ||
value: 1, | ||
exemplarLabels, | ||
}); | ||
|
||
h.observe({ | ||
labels: { code: '200' }, | ||
value: 3, | ||
exemplarLabels, | ||
}); | ||
|
||
h.observe({ | ||
labels: { code: '200' }, | ||
value: 0.3, | ||
exemplarLabels, | ||
}); | ||
|
||
h.observe({ | ||
labels: { code: '200' }, | ||
value: 300, | ||
exemplarLabels, | ||
}); | ||
} | ||
|
||
async function main() { | ||
// should only use exemplars with OpenMetrics registry types | ||
register.setContentType(Registry.OPENMETRICS_CONTENT_TYPE); | ||
|
||
makeCounters(); | ||
makeHistograms(); | ||
|
||
console.log(await register.metrics()); | ||
} | ||
|
||
main(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.