Skip to content

Setting metric unit to "total" #542

Closed

Description

@nritsche

a4dd93b enforced counters ending in _total, but the unit= parameter doesn't seem to interact well with that. If I pass unit="total" to a Counter, I get a _total_total suffix (but only in some places?).

$ python3.6
Python 3.6.8 (default, Aug  7 2019, 17:28:10) 
[GCC 4.8.5 20150623 (Red Hat 4.8.5-39)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from prometheus_client import Counter
>>> c = Counter('my_failures', 'Description of counter', unit="total")
>>> c.inc(6.6)
>>> from prometheus_client import start_http_server, Summary
>>> start_http_server(8000)
$ curl localhost:8000/metrics
...
# HELP my_failures_total_total Description of counter
# TYPE my_failures_total_total counter
my_failures_total 6.6
my_failures_created 1.5888939194938827e+09

This is with version 0.7.1.

Activity

  1. changed the title [-]Setting metric unit to "_total"[/-] [+]Setting metric unit to "total"[/+] on May 7, 2020
  2. brian-brazil commented on May 8, 2020

    @brian-brazil
    Contributor

    That behaviour sounds correct to me, however total is not a good unit. What are you trying to do?

  3. nritsche commented on May 8, 2020

    @nritsche
    Author

    Oh, I see. I didn't read this careful enough: https://prometheus.io/docs/practices/naming/. The _total goes behind the unit. Anyways, note that the exposed metric doesn't match it's "HELP" and "TYPE".

  4. brian-brazil commented on May 8, 2020

    @brian-brazil
    Contributor

    That would be a bug, though not something that should arise in practice.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions