-
Notifications
You must be signed in to change notification settings - Fork 356
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
Check for base unit when adjusting unit label #1447
Conversation
@yaacov Cannot apply the following label because they are not recognized: providers/containers |
@miq-bot add_label compute/containers |
@zeari please review |
@zeari (raised original question) 👍 thanks @simon3z @serenamarie125 @himdel please help: The problem Possible options Solution used in this PR Question |
@simon3z I found this lib: but I think it's an overkill for just ms, ns, milliseconds ... |
@simon3z @serenamarie125 @himdel please review |
@miq-bot add_label fine/yes https://bugzilla.redhat.com/show_bug.cgi?id=1456246 target 5.8.2 |
|
||
// get base unit for special case units | ||
switch (units) { | ||
case 'milliseconde': |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
millisecond
;) Unless you really wanted this in french..?
baseUnit = units; | ||
} | ||
|
||
// adjuat to base units and calc exponent |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
adjust
|
||
// adjuat to base units and calc exponent | ||
baseUnitMaxValue = maxValue * baseUnitMultiplier; | ||
exp = parseInt(Math.log10(baseUnitMaxValue) / 3, 10) * 3; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
parseInt
to convert from float to int? Sounds like ~~
might do the trick better..
|
||
// calc output unit label and multiplier | ||
metricPrefixes = { | ||
3: {unitLable: 'K' + baseUnit, multiplier: baseUnitMultiplier * Math.pow(10, -3)}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unitLabel
? (all over the place)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@himdel Sorry 👍 fixed ( all above notes also ... )
@yaacov As for jq-quantities, possibly an overkill, possibly not, but..
(Also there's a bunch of custom formatters in |
@yaacov Is the time formatting something you want to solve in this PR, or do kilosecs, etc. make sense for now? I'm good with this as it is 👍 (but to be honest I do already have a calendar entry to celebrate reaching 1Gs of age :)) |
|
||
// adjust to base units and calc exponent | ||
baseUnitMaxValue = maxValue * baseUnitMultiplier; | ||
exp = ~~(Math.log10(baseUnitMaxValue) / 3, 10) * 3; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missed the , 10
;) (Don't want this to always yield 30, I guess..)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry ....
Checked commit yaacov@0786f27 with ruby 2.2.6, rubocop 0.47.1, and haml-lint 0.20.0 |
Agreed, |
@yaacov what is the time interval representing, and why do we need to be so granular? |
@serenamarie125 @simon3z @himdel hi, This PR is solving the bug of "Kns" and "Tms", killo nano second and tera milli second are simply not metric unit, we must fix that. The problem of "tera-milli-second" (this is not a unit) may have different solutions. We choose to convert to base unit and use the metric system, e.g. Km, Ggr, Ts ... this is correct, but "tera second", may sound bad to a none engineer :-) We wanted to know if MiQ has a UX policy for cases like this, (Using "engineer" vs "human" language) ? If MiQ policy is to use "human" in this cases, we can do this too, @himdel suggested usind moment.js for this.
Some metrics are measured in time intervals, with unit tag set to "ns", "ms" and "millisecond", we do not currently collect metrics with other time units. For example: CPU usage is measured in nano seconds since power on, the unit tag is set to "ns"
The units "ms", "ns" comes with the measurement collected (we get a value and a unit, e.g byte, ms, ns), nano seconds is a common unit to measure CPU utilization. High granularity may show important things, for example,
CPU usage is a time interval, it is the time in ns that the CPU was in use since power on. |
p.s. Looking how others solved this: |
Check for base unit when adjusting unit label
Check for base unit when adjusting unit label (cherry picked from commit e2865c1) https://bugzilla.redhat.com/show_bug.cgi?id=1478379
Fine backport details:
|
Description
Currently we do not check the base unit when creating the unit label.
For example 1000s will become 1Ks, and 1000ms will become 1Kms.
This is wrong, we want to take into account the base units.
For example 1000s will become 1Ks, and 1000ms will become 1s.
BZ: https://bugzilla.redhat.com/show_bug.cgi?id=1456246
Screenshots
Bug
Fix