Skip to content

Commit d2a4bd7

Browse files
authored
*: Follow metric naming convention for unit-less count (#360)
By convention unit-less Prometheus counters are postfixed with `_total`. See https://prometheus.io/docs/practices/naming/ for details. Signed-off-by: Max Inden <[email protected]>
1 parent 0b02704 commit d2a4bd7

File tree

9 files changed

+20
-20
lines changed

9 files changed

+20
-20
lines changed

examples/example_hyper.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use prometheus::{Counter, Encoder, Gauge, HistogramVec, TextEncoder};
1515
lazy_static! {
1616
static ref HTTP_COUNTER: Counter = register_counter!(opts!(
1717
"example_http_requests_total",
18-
"Total number of HTTP requests made.",
18+
"Number of HTTP requests made.",
1919
labels! {"handler" => "all",}
2020
))
2121
.unwrap();

src/vec.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ impl<T: MetricVecBuilder> MetricVec<T> {
249249
/// ```
250250
/// use prometheus::{CounterVec, Opts};
251251
/// let vec = CounterVec::new(
252-
/// Opts::new("requests", "Number of requests"),
252+
/// Opts::new("requests_total", "Number of requests."),
253253
/// &["code", "http_method"]
254254
/// ).unwrap();
255255
/// vec.with_label_values(&["404", "POST"]).inc()

static-metric/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,8 @@ make_auto_flush_static_metric! {
125125
lazy_static! {
126126
pub static ref HTTP_COUNTER_VEC: IntCounterVec =
127127
register_int_counter_vec ! (
128-
"http_requests",
129-
"Total number of HTTP requests.",
128+
"http_requests_total",
129+
"Number of HTTP requests.",
130130
& ["product", "method", "version"] // it doesn't matter for the label order
131131
).unwrap();
132132
}

static-metric/examples/advanced.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ make_static_metric! {
3131
lazy_static! {
3232
pub static ref HTTP_COUNTER_VEC: IntCounterVec =
3333
register_int_counter_vec!(
34-
"http_requests",
35-
"Total number of HTTP requests.",
34+
"http_requests_total",
35+
"Number of HTTP requests.",
3636
&["product", "method", "version"] // it doesn't matter for the label order
3737
).unwrap();
3838

static-metric/examples/local.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ make_static_metric! {
3434
lazy_static! {
3535
pub static ref HTTP_COUNTER_VEC: IntCounterVec =
3636
register_int_counter_vec!(
37-
"http_requests",
38-
"Total number of HTTP requests.",
37+
"http_requests_total",
38+
"Number of HTTP requests.",
3939
&["product", "method", "version"] // it doesn't matter for the label order
4040
).unwrap();
4141
}

static-metric/examples/make_auto_flush_static_counter.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ make_auto_flush_static_metric! {
4141
lazy_static! {
4242
pub static ref HTTP_COUNTER_VEC: IntCounterVec =
4343
register_int_counter_vec ! (
44-
"http_requests",
45-
"Total number of HTTP requests.",
44+
"http_requests_total",
45+
"Number of HTTP requests.",
4646
& ["product", "method", "version"] // it doesn't matter for the label order
4747
).unwrap();
4848
}
@@ -377,8 +377,8 @@ impl Lhrs {
377377
lazy_static! {
378378
pub static ref HTTP_COUNTER_VEC: IntCounterVec =
379379
register_int_counter_vec ! (
380-
"http_requests",
381-
"Total number of HTTP requests.",
380+
"http_requests_total",
381+
"Number of HTTP requests.",
382382
& ["product", "method", "version"] // it doesn't matter for the label order
383383
).unwrap();
384384
}

static-metric/examples/make_auto_flush_static_metric_histogram.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ make_auto_flush_static_metric! {
4141
lazy_static! {
4242
pub static ref HTTP_HISTO_VEC: HistogramVec =
4343
register_histogram_vec ! (
44-
"http_requests",
45-
"Total number of HTTP requests.",
44+
"http_requests_total",
45+
"Number of HTTP requests.",
4646
& ["product", "method", "version"] // it doesn't matter for the label order
4747
).unwrap();
4848
}
@@ -371,8 +371,8 @@ impl Lhrs {
371371
lazy_static! {
372372
pub static ref HTTP_HISTO_VEC: HistogramVec =
373373
register_histogram_vec ! (
374-
"http_requests",
375-
"Total number of HTTP requests.",
374+
"http_requests_total",
375+
"Number of HTTP requests.",
376376
& ["product", "method", "version"] // it doesn't matter for the label order
377377
).unwrap();
378378
}

static-metric/examples/register_integration.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ make_static_metric! {
4242
lazy_static! {
4343
pub static ref HTTP_COUNTER: HttpRequestStatistics = register_static_counter_vec!(
4444
HttpRequestStatistics,
45-
"http_requests",
46-
"Total number of HTTP requests.",
45+
"http_requests_total",
46+
"Number of HTTP requests.",
4747
&["method", "product"]
4848
)
4949
.unwrap();

static-metric/examples/with_lazy_static.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ make_static_metric! {
2626

2727
lazy_static! {
2828
pub static ref HTTP_COUNTER_VEC: CounterVec = register_counter_vec!(
29-
"http_requests",
30-
"Total number of HTTP requests.",
29+
"http_requests_total",
30+
"Number of HTTP requests.",
3131
&["method", "product"]
3232
)
3333
.unwrap();

0 commit comments

Comments
 (0)