-
Notifications
You must be signed in to change notification settings - Fork 96
Add gauge example #460
Add gauge example #460
Conversation
Codecov Report
@@ Coverage Diff @@
## master #460 +/- ##
==========================================
+ Coverage 94.7% 94.73% +0.03%
==========================================
Files 150 150
Lines 9785 9785
Branches 738 735 -3
==========================================
+ Hits 9267 9270 +3
+ Misses 518 515 -3
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM pending a few comments
// [END setup_exporter ==============================================] | ||
|
||
setTimeout(() => { | ||
console.log('Timeout executed.'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you document what this timeout is for? I remember in another example the timeout kept the Node process alive while the metric was being collected.
}; | ||
const gauge = metricRegistry.addDerivedInt64Gauge('active_handles_total', metricOptions); | ||
|
||
gauge.createTimeSeries(labelValues, process._getActiveHandles()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do you pass process._getActiveHandles()
vs. passing the function itself process._getActiveHandles
? I would have expected it to take a function that it calls to calculate the gauge value rather than the output of a function for a single value.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The createTimeSeries
method accepts the object with AccessorInterface
type.
AccessorInterface = LengthAttributeInterface | LengthMethodInterface |
SizeAttributeInterface | SizeMethodInterface | ToValueInterface;
I have changed the example to show derived gauge example with queue depth. Do you think we should add support for function based extractor?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, makes sense. Yes, I think supporting a function as well would be nice so that people can just pass in an anonymous arrow function easily.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok sure, I will open an issue to include function based extractor in derived gauge API. Thanks
Fixes #459