Explore: Add more meta information when line limit is hit (#33069)

* WIP: Add more info ro log line limit, remove redundant info

* Refactor

* Clean up

* Adjust tests

* Adjust spacing

* Add test for new functionality

* Update snapshot

* Change solution, simplify

* Remove redundant variables, makees it more clear

* Update public/app/core/logs_model.ts

Co-authored-by: Piotr Jamróz <pm.jamroz@gmail.com>

Co-authored-by: Piotr Jamróz <pm.jamroz@gmail.com>
This commit is contained in:
Ivana Huckova
2021-04-21 12:02:34 +02:00
committed by GitHub
parent 0463164f8c
commit 1c838f5872
6 changed files with 140 additions and 61 deletions

View File

@@ -261,6 +261,23 @@ export function secondsToHms(seconds: number): string {
return 'less than a millisecond'; //'just now' //or other string you like;
}
// Format timeSpan (in sec) to string used in log's meta info
export function msRangeToTimeString(rangeMs: number): string {
const rangeSec = Number((rangeMs / 1000).toFixed());
const h = Math.floor(rangeSec / 60 / 60);
const m = Math.floor(rangeSec / 60) - h * 60;
const s = Number((rangeSec % 60).toFixed());
let formattedH = h ? h + 'h' : '';
let formattedM = m ? m + 'min' : '';
let formattedS = s ? s + 'sec' : '';
formattedH && formattedM ? (formattedH = formattedH + ' ') : (formattedH = formattedH);
(formattedM || formattedH) && formattedS ? (formattedM = formattedM + ' ') : (formattedM = formattedM);
return formattedH + formattedM + formattedS || 'less than 1sec';
}
export function calculateInterval(range: TimeRange, resolution: number, lowLimitInterval?: string): IntervalValues {
let lowLimitMs = 1; // 1 millisecond default low limit
if (lowLimitInterval) {