Skip to content

Commit 765ce10

Browse files
committed
Switch prometheus timings to seconds #2
This effectively reverts commit 844fe44, whose parent was mistakenly pushed instead of being merged as a PR. Below is the original PR Date.now() returns milliseconds and startTime is assumed to be a Date.now() call result too. In prometheus land, the rule is to always use seconds[1] and not have to care about the prefixes of units[2] The vast majority of metric names out there follow that pattern. Instead of diverging, causing confusions to developers who need to adapt their heads around naming metric differently as well as setting histogram buckets differently, conform to the status quo and divide by 1000. Precision won't be lost as we just move around the decimal separator. This is a breaking change for applications/services that have migrated to prometheus, so bump to 3.1.0. Charts and statistics might have to be updated as well as dashboards. [1] https://prometheus.io/docs/instrumenting/writing_exporters/#naming [2] https://www.robustperception.io/who-wants-seconds
1 parent 844fe44 commit 765ce10

File tree

3 files changed

+5362
-17
lines changed

3 files changed

+5362
-17
lines changed

lib/metrics/prometheus.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ class PrometheusMetric {
9898

9999
endTiming(startTime, labelValues) {
100100
const updatedLabelValues = this._getLabelValues(labelValues);
101-
this.timing(Date.now() - startTime, updatedLabelValues);
101+
this.timing((Date.now() - startTime) / 1000, updatedLabelValues);
102102
}
103103
}
104104

0 commit comments

Comments
 (0)