-
Notifications
You must be signed in to change notification settings - Fork 4
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
node-artedi histograms should be compatible with Prometheus #17
Closed
Closed
Changes from 8 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
2936ec5
fixed buckets for histograms
joshwilsdon 4611844
update docs and package.json for histogram bucket fixes
joshwilsdon f66ac1d
fix tests
joshwilsdon 8674c5d
make it clear that this will break if you've been using histograms
joshwilsdon f61c176
include PR number
joshwilsdon 48369f4
add initial (incomplete) implementation of some bucket generator func…
joshwilsdon 48312bf
remove artedi1-compatible bucket generator, fix up log-linear and tests
joshwilsdon 2100b6c
add additional tests ad address PR feedback
joshwilsdon 93f99cf
cleanup
joshwilsdon 721cf3b
add artedi namespace
joshwilsdon 7867367
remove TODO after discussion
joshwilsdon 2cde183
add notes and example code for updating to version 2
joshwilsdon 97ac1cf
fix 'make check', fix formatting of small numbers
joshwilsdon 1a4edae
add support for detecting whether a collector requires fixed buckets
joshwilsdon File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 |
---|---|---|
|
@@ -83,21 +83,29 @@ var gauge = collector.gauge({ | |
}); | ||
``` | ||
### collector.histogram(opts) : Histogram | ||
Creates a new Histogram object with the given options (incl. labels). This call | ||
is idempotent. `opts` must include 'help' and 'name' fields, and may optionally | ||
include a 'labels' object. | ||
Creates a new Histogram object with the given options (incl. labels and | ||
buckets). This call is idempotent. `opts` must include 'help' and 'name' fields, | ||
and may optionally include a 'labels' object and/or a buckets array. | ||
|
||
Example: | ||
```javascript | ||
var histogram = collector.histogram({ | ||
name: 'http_request_latency_ms', | ||
name: 'http_request_latency_seconds', | ||
help: 'latency of http requests', | ||
labels: { | ||
component: 'muskie' | ||
} | ||
}, | ||
buckets: [0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5, 5, 10] | ||
}); | ||
``` | ||
|
||
Note: If `buckets` are not specified, the default buckets will be: | ||
|
||
``` | ||
[0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5, 5, 10] | ||
``` | ||
|
||
|
||
### collector.addTriggerFunction(func(Collector, callback)) | ||
Adds `func` to a list of triggers to call immediately before metrics are | ||
collected during a call to `collector.collect()`. | ||
|
@@ -191,6 +199,7 @@ Example: | |
counter.getValue( { operation: 'click' } ); | ||
``` | ||
|
||
|
||
## Gauge | ||
Gauges are similar to counters. Gauges can count up, or count down relative | ||
to their current value, or be set to an arbitrary value. Gauges start with an | ||
|
@@ -233,15 +242,54 @@ count values that fall between a number of buckets. | |
### histogram.observe(value, labels) | ||
Increment buckets with a value >= `value`. | ||
|
||
Note that it isn't necessary to specify which | ||
buckets to use. Log/linear buckets are automatically generated. More details | ||
about log/linear buckets can be found at the | ||
[DTrace blog](http://dtrace.org/blogs/bmc/2011/02/08/llquantize/). | ||
|
||
Example: | ||
```javascript | ||
histogram.observe(1111, { | ||
method: 'putobject', | ||
code: 204 | ||
}); | ||
``` | ||
|
||
### Bucket Generators | ||
Artedi includes several generator functions that help create `buckets` arrays | ||
for use with histograms. | ||
|
||
#### artedi.linearBuckets(min, width, count) | ||
Generate `count` buckets starting with `min` with each bucket being `width` | ||
larger than the previous. | ||
|
||
Example: | ||
```javascript | ||
artedi.linearBuckets(0.5, 0.5, 10); | ||
// returns [ 0.5, 1, 1.5, 2, 2.5, 3, 3.5, 4, 4.5, 5 ] | ||
``` | ||
|
||
Note: The min parameter must be > 0. It will likely be common to use the same | ||
value for `width` and `min` as in the example above. | ||
|
||
#### artedi.exponentialBuckets(min, factor, count) | ||
Generate `count` buckets starting with `min` with each bucket being `factor` | ||
times larger than the previous. | ||
|
||
Example: | ||
```javascript | ||
artedi.exponentialBuckets(1, 2, 5); | ||
// returns [ 1, 2, 4, 8, 16 ] | ||
``` | ||
|
||
#### logLinearBuckets(base, lowPower, highPower, bucketsPerMagnitude) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We're missing the |
||
Generate a set of log-linear buckets. This will create `bucketsPerMagnitude` | ||
buckets for the magnitude that contains base^lowPower, and each magnitude | ||
up to and including the magnitude that starts with highPower. | ||
|
||
Example: | ||
|
||
```javascript | ||
artedi.logLinearBuckets(10, -2, 1, 5); | ||
// returns [ 0.02, 0.04, 0.06, 0.08, 0.1, 0.2, 0.4, 0.6, 0.8, 1, 2, 4, 6, 8, 10, 20, 40, 60, 80, 100 ] | ||
``` | ||
|
||
Note in the above example, the lowPower was -2 so we started with 10^-2 = 0.01 | ||
and used that magnitude (10^-2 to 10^-1) as the first set of 5 buckets. Then we | ||
created buckets for the magnitudes 10^-1 to 10^0, 10^0 to 10^1 and finally 10^1 | ||
(our highPower parameter) to 10^2. |
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
I think this _sum value would be .998, right?