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

New time measurement system #32

Closed
deadtrickster opened this issue Sep 6, 2016 · 2 comments
Closed

New time measurement system #32

deadtrickster opened this issue Sep 6, 2016 · 2 comments
Milestone

Comments

@deadtrickster
Copy link
Collaborator

deadtrickster commented Sep 6, 2016

Durations measured as difference between start and end erlang:monotonic_times in so called native time units. native time units are meaningless and have to be converted using erlang:convert_time_unit. However as erlang:convert_time_unit documentation warns:

You may lose accuracy and precision when converting between time units.
In order to minimize such loss, collect all data at native time unit and do the 
conversion on the end result.

The idea is that set_duration/observe_duration functions always work with native time units and conversion is delayed until scraping/retrieving value. To implement this, metric needs to know desired time unit. Users can specify desired time unit explicitly via duration_unit or mplicitly via metric name ((preferred, since prometheus best practices insists on <name>_duration_<unit> metric name format).

Possible units:

  • microseconds;
  • milliseconds;
  • seconds;
  • minutes;
  • hours;
  • days;

Histogram will internally convert buckets bounds to native units if duration_unit is provided. It will convert it back when scraping or retrieving value.

@deadtrickster deadtrickster added this to the Version 3 milestone Sep 6, 2016
deadtrickster added a commit that referenced this issue Sep 7, 2016
@deadtrickster deadtrickster mentioned this issue Sep 8, 2016
@talentdeficit
Copy link
Contributor

this looks excellent. so creating a histogram via prometheus_histogram:new({thing_duration_milliseconds, ...}) will automatically report that metric as an (integer) millisecond, converted from native units?

@deadtrickster
Copy link
Collaborator Author

deadtrickster commented Sep 8, 2016

yep! and if you're not instrumenting directly e.g. Elli gives you 'standard' tuple soyou can turn this off with duration_unit: false. Also duration in the name isn't needed.

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

2 participants