mirror of
https://github.com/grafana/grafana.git
synced 2025-02-13 00:55:47 -06:00
Logs: Use millisecond precision for open context in split view (#67385)
Log: Use millisecond precision for open context in split view
This commit is contained in:
parent
d01ea9902c
commit
3a8bb226bd
@ -12,7 +12,8 @@ import {
|
|||||||
LogsDedupStrategy,
|
LogsDedupStrategy,
|
||||||
LogsSortOrder,
|
LogsSortOrder,
|
||||||
SelectableValue,
|
SelectableValue,
|
||||||
rangeUtil,
|
dateTime,
|
||||||
|
TimeRange,
|
||||||
} from '@grafana/data';
|
} from '@grafana/data';
|
||||||
import { config, reportInteraction } from '@grafana/runtime';
|
import { config, reportInteraction } from '@grafana/runtime';
|
||||||
import { DataQuery, TimeZone } from '@grafana/schema';
|
import { DataQuery, TimeZone } from '@grafana/schema';
|
||||||
@ -23,6 +24,7 @@ import { splitOpen } from 'app/features/explore/state/main';
|
|||||||
import { SETTINGS_KEYS } from 'app/features/explore/utils/logs';
|
import { SETTINGS_KEYS } from 'app/features/explore/utils/logs';
|
||||||
import { useDispatch } from 'app/types';
|
import { useDispatch } from 'app/types';
|
||||||
|
|
||||||
|
import { sortLogRows } from '../../utils';
|
||||||
import { LogRows } from '../LogRows';
|
import { LogRows } from '../LogRows';
|
||||||
|
|
||||||
import { LoadMoreOptions, LogContextButtons } from './LogContextButtons';
|
import { LoadMoreOptions, LogContextButtons } from './LogContextButtons';
|
||||||
@ -154,16 +156,26 @@ export const LogRowContextModal: React.FunctionComponent<LogRowContextModalProps
|
|||||||
|
|
||||||
const getFullTimeRange = useCallback(() => {
|
const getFullTimeRange = useCallback(() => {
|
||||||
const { before, after } = context;
|
const { before, after } = context;
|
||||||
const allRows = [...before, row, ...after].sort((a, b) => a.timeEpochMs - b.timeEpochMs);
|
const allRows = sortLogRows([...before, row, ...after], LogsSortOrder.Ascending);
|
||||||
const first = allRows[0];
|
const fromMs = allRows[0].timeEpochMs;
|
||||||
const last = allRows[allRows.length - 1];
|
let toMs = allRows[allRows.length - 1].timeEpochMs;
|
||||||
return rangeUtil.convertRawToRange(
|
// In case we have a lot of logs and from and to have same millisecond
|
||||||
{
|
// we add 1 millisecond to toMs to make sure we have a range
|
||||||
from: first.timeUtc,
|
if (fromMs === toMs) {
|
||||||
to: last.timeUtc,
|
toMs += 1;
|
||||||
|
}
|
||||||
|
const from = dateTime(fromMs);
|
||||||
|
const to = dateTime(toMs);
|
||||||
|
|
||||||
|
const range: TimeRange = {
|
||||||
|
from,
|
||||||
|
to,
|
||||||
|
raw: {
|
||||||
|
from,
|
||||||
|
to,
|
||||||
},
|
},
|
||||||
'utc'
|
};
|
||||||
);
|
return range;
|
||||||
}, [context, row]);
|
}, [context, row]);
|
||||||
|
|
||||||
const onChangeLimitOption = (option: SelectableValue<number>) => {
|
const onChangeLimitOption = (option: SelectableValue<number>) => {
|
||||||
|
Loading…
Reference in New Issue
Block a user