Skip to content
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

Microseconds getting automatically converted to milliseconds? #29

Open
bryanhuntesl opened this issue Jul 9, 2019 · 4 comments
Open

Comments

@bryanhuntesl
Copy link

Is this expected behavior ?

I declare a metric with a microseconds suffix :

@histogram [
    name: :http_check_duration_microseconds,
    labels: [:target],
    buckets: :default,
    help: "Http check execution time"
  ]

And I then feed it a microseconds value (20481):

Histogram.observe(
      [name: :http_check_duration_microseconds, labels: [target]],
      time
    )

It is then silently converted to milliseconds - but the metric name still indicates microseconds.

http_check_duration_gauge_microseconds{target="http://google.com"} 20.481
# TYPE http_check_duration_microseconds histogram
# HELP http_check_duration_microseconds Http check execution time
http_check_duration_microseconds_bucket{target="http://google.com",le="0.005"} 0
http_check_duration_microseconds_bucket{target="http://google.com",le="0.01"} 0
http_check_duration_microseconds_bucket{target="http://google.com",le="0.025"} 0
http_check_duration_microseconds_bucket{target="http://google.com",le="0.05"} 0
http_check_duration_microseconds_bucket{target="http://google.com",le="0.1"} 0
http_check_duration_microseconds_bucket{target="http://google.com",le="0.25"} 0
http_check_duration_microseconds_bucket{target="http://google.com",le="0.5"} 0
http_check_duration_microseconds_bucket{target="http://google.com",le="1"} 0
http_check_duration_microseconds_bucket{target="http://google.com",le="2.5"} 0
http_check_duration_microseconds_bucket{target="http://google.com",le="5"} 0
http_check_duration_microseconds_bucket{target="http://google.com",le="10"} 0
http_check_duration_microseconds_bucket{target="http://google.com",le="+Inf"} 17
http_check_duration_microseconds_count{target="http://google.com"} 17
http_check_duration_microseconds_sum{target="http://google.com"} 364.862

The code in it's entirity can be seen here

@deadtrickster
Copy link
Owner

Basically, when it sees suffix like _microseconds it expects values to be native_time_unit. Please read here: https://hexdocs.pm/prometheus_ex/time.html#content

@danielfbnunes
Copy link

Hey @deadtrickster . In the documentation, this is what we can see:

Users can specify time unit explicitly via duration_unit or implicitly via
metric name (preferred, since prometheus best practices guide insists on
<name>_duration_<unit> metric name format).

I had a metric that contained milliseconds in its name but it didn't have the duration_ part. This converts the metric value too. Is this the expected behaviour?

Thanks 😄

@deadtrickster
Copy link
Owner

Cool question!

According to current code - yes that's expected. Does it disturb you? What is your metrics?

@danielfbnunes
Copy link

danielfbnunes commented Apr 2, 2020

What is your metrics?

The metric was created to measure the time that certain queries take to run. Since they are pretty fast, I want the metric value to be in milliseconds as an Integer.

Does it disturb you?

No, it's no problem. Can you just update the docs?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants