mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Merge pull request #14411 from grafana/davkal/fix-14362
Explore: dont pass all rows to all rows, fixes profiler
This commit is contained in:
commit
c58f818ea2
@ -69,7 +69,7 @@ export class Stats extends PureComponent<{
|
|||||||
|
|
||||||
class Label extends PureComponent<
|
class Label extends PureComponent<
|
||||||
{
|
{
|
||||||
allRows?: LogRow[];
|
getRows?: () => LogRow[];
|
||||||
label: string;
|
label: string;
|
||||||
plain?: boolean;
|
plain?: boolean;
|
||||||
value: string;
|
value: string;
|
||||||
@ -98,13 +98,14 @@ class Label extends PureComponent<
|
|||||||
if (state.showStats) {
|
if (state.showStats) {
|
||||||
return { showStats: false, stats: null };
|
return { showStats: false, stats: null };
|
||||||
}
|
}
|
||||||
const stats = calculateLogsLabelStats(this.props.allRows, this.props.label);
|
const allRows = this.props.getRows();
|
||||||
|
const stats = calculateLogsLabelStats(allRows, this.props.label);
|
||||||
return { showStats: true, stats };
|
return { showStats: true, stats };
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { allRows, label, plain, value } = this.props;
|
const { getRows, label, plain, value } = this.props;
|
||||||
const { showStats, stats } = this.state;
|
const { showStats, stats } = this.state;
|
||||||
const tooltip = `${label}: ${value}`;
|
const tooltip = `${label}: ${value}`;
|
||||||
return (
|
return (
|
||||||
@ -115,12 +116,12 @@ class Label extends PureComponent<
|
|||||||
{!plain && (
|
{!plain && (
|
||||||
<span title="Filter for label" onClick={this.onClickLabel} className="logs-label__icon fa fa-search-plus" />
|
<span title="Filter for label" onClick={this.onClickLabel} className="logs-label__icon fa fa-search-plus" />
|
||||||
)}
|
)}
|
||||||
{!plain && allRows && <span onClick={this.onClickStats} className="logs-label__icon fa fa-signal" />}
|
{!plain && getRows && <span onClick={this.onClickStats} className="logs-label__icon fa fa-signal" />}
|
||||||
{showStats && (
|
{showStats && (
|
||||||
<span className="logs-label__stats">
|
<span className="logs-label__stats">
|
||||||
<Stats
|
<Stats
|
||||||
stats={stats}
|
stats={stats}
|
||||||
rowCount={allRows.length}
|
rowCount={getRows().length}
|
||||||
label={label}
|
label={label}
|
||||||
value={value}
|
value={value}
|
||||||
onClickClose={this.onClickClose}
|
onClickClose={this.onClickClose}
|
||||||
@ -133,15 +134,15 @@ class Label extends PureComponent<
|
|||||||
}
|
}
|
||||||
|
|
||||||
export default class LogLabels extends PureComponent<{
|
export default class LogLabels extends PureComponent<{
|
||||||
allRows?: LogRow[];
|
getRows?: () => LogRow[];
|
||||||
labels: LogsStreamLabels;
|
labels: LogsStreamLabels;
|
||||||
plain?: boolean;
|
plain?: boolean;
|
||||||
onClickLabel?: (label: string, value: string) => void;
|
onClickLabel?: (label: string, value: string) => void;
|
||||||
}> {
|
}> {
|
||||||
render() {
|
render() {
|
||||||
const { allRows, labels, onClickLabel, plain } = this.props;
|
const { getRows, labels, onClickLabel, plain } = this.props;
|
||||||
return Object.keys(labels).map(key => (
|
return Object.keys(labels).map(key => (
|
||||||
<Label key={key} allRows={allRows} label={key} value={labels[key]} plain={plain} onClickLabel={onClickLabel} />
|
<Label key={key} getRows={getRows} label={key} value={labels[key]} plain={plain} onClickLabel={onClickLabel} />
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -56,13 +56,13 @@ const FieldHighlight = onClick => props => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
interface RowProps {
|
interface RowProps {
|
||||||
allRows: LogRow[];
|
|
||||||
highlighterExpressions?: string[];
|
highlighterExpressions?: string[];
|
||||||
row: LogRow;
|
row: LogRow;
|
||||||
showDuplicates: boolean;
|
showDuplicates: boolean;
|
||||||
showLabels: boolean | null; // Tristate: null means auto
|
showLabels: boolean | null; // Tristate: null means auto
|
||||||
showLocalTime: boolean;
|
showLocalTime: boolean;
|
||||||
showUtc: boolean;
|
showUtc: boolean;
|
||||||
|
getRows: () => LogRow[];
|
||||||
onClickLabel?: (label: string, value: string) => void;
|
onClickLabel?: (label: string, value: string) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -107,11 +107,12 @@ class Row extends PureComponent<RowProps, RowState> {
|
|||||||
};
|
};
|
||||||
|
|
||||||
onClickHighlight = (fieldText: string) => {
|
onClickHighlight = (fieldText: string) => {
|
||||||
const { allRows } = this.props;
|
const { getRows } = this.props;
|
||||||
const { parser } = this.state;
|
const { parser } = this.state;
|
||||||
|
|
||||||
const fieldMatch = fieldText.match(parser.fieldRegex);
|
const fieldMatch = fieldText.match(parser.fieldRegex);
|
||||||
if (fieldMatch) {
|
if (fieldMatch) {
|
||||||
|
const allRows = getRows();
|
||||||
// Build value-agnostic row matcher based on the field label
|
// Build value-agnostic row matcher based on the field label
|
||||||
const fieldLabel = fieldMatch[1];
|
const fieldLabel = fieldMatch[1];
|
||||||
const fieldValue = fieldMatch[2];
|
const fieldValue = fieldMatch[2];
|
||||||
@ -151,7 +152,7 @@ class Row extends PureComponent<RowProps, RowState> {
|
|||||||
|
|
||||||
render() {
|
render() {
|
||||||
const {
|
const {
|
||||||
allRows,
|
getRows,
|
||||||
highlighterExpressions,
|
highlighterExpressions,
|
||||||
onClickLabel,
|
onClickLabel,
|
||||||
row,
|
row,
|
||||||
@ -193,7 +194,7 @@ class Row extends PureComponent<RowProps, RowState> {
|
|||||||
)}
|
)}
|
||||||
{showLabels && (
|
{showLabels && (
|
||||||
<div className="logs-row__labels">
|
<div className="logs-row__labels">
|
||||||
<LogLabels allRows={allRows} labels={row.uniqueLabels} onClickLabel={onClickLabel} />
|
<LogLabels getRows={getRows} labels={row.uniqueLabels} onClickLabel={onClickLabel} />
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
<div className="logs-row__message" onMouseEnter={this.onMouseOverMessage} onMouseLeave={this.onMouseOutMessage}>
|
<div className="logs-row__message" onMouseEnter={this.onMouseOverMessage} onMouseLeave={this.onMouseOutMessage}>
|
||||||
@ -416,6 +417,9 @@ export default class Logs extends PureComponent<LogsProps, LogsState> {
|
|||||||
|
|
||||||
const scanText = scanRange ? `Scanning ${rangeUtil.describeTimeRange(scanRange)}` : 'Scanning...';
|
const scanText = scanRange ? `Scanning ${rangeUtil.describeTimeRange(scanRange)}` : 'Scanning...';
|
||||||
|
|
||||||
|
// React profiler becomes unusable if we pass all rows to all rows and their labels, using getter instead
|
||||||
|
const getRows = () => processedRows;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="logs-panel">
|
<div className="logs-panel">
|
||||||
<div className="logs-panel-graph">
|
<div className="logs-panel-graph">
|
||||||
@ -473,7 +477,7 @@ export default class Logs extends PureComponent<LogsProps, LogsState> {
|
|||||||
firstRows.map(row => (
|
firstRows.map(row => (
|
||||||
<Row
|
<Row
|
||||||
key={row.key + row.duplicates}
|
key={row.key + row.duplicates}
|
||||||
allRows={processedRows}
|
getRows={getRows}
|
||||||
highlighterExpressions={highlighterExpressions}
|
highlighterExpressions={highlighterExpressions}
|
||||||
row={row}
|
row={row}
|
||||||
showDuplicates={showDuplicates}
|
showDuplicates={showDuplicates}
|
||||||
@ -489,7 +493,7 @@ export default class Logs extends PureComponent<LogsProps, LogsState> {
|
|||||||
lastRows.map(row => (
|
lastRows.map(row => (
|
||||||
<Row
|
<Row
|
||||||
key={row.key + row.duplicates}
|
key={row.key + row.duplicates}
|
||||||
allRows={processedRows}
|
getRows={getRows}
|
||||||
row={row}
|
row={row}
|
||||||
showDuplicates={showDuplicates}
|
showDuplicates={showDuplicates}
|
||||||
showLabels={showLabels}
|
showLabels={showLabels}
|
||||||
|
Loading…
Reference in New Issue
Block a user