mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Add feature tracking for LogRow.tsx (#56656)
* Add feature tracking for LogRow.tsx * Add type and logRowUid to reportInteraction * Rename logs variable
This commit is contained in:
@@ -78,6 +78,7 @@ export interface LogRowModel {
|
|||||||
timeUtc: string;
|
timeUtc: string;
|
||||||
uid: string;
|
uid: string;
|
||||||
uniqueLabels?: Labels;
|
uniqueLabels?: Labels;
|
||||||
|
datasourceType?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface LogsModel {
|
export interface LogsModel {
|
||||||
|
|||||||
@@ -207,7 +207,7 @@ export function dataFrameToLogsModel(
|
|||||||
queries?: DataQuery[]
|
queries?: DataQuery[]
|
||||||
): LogsModel {
|
): LogsModel {
|
||||||
const { logSeries } = separateLogsAndMetrics(dataFrame);
|
const { logSeries } = separateLogsAndMetrics(dataFrame);
|
||||||
const logsModel = logSeriesToLogsModel(logSeries);
|
const logsModel = logSeriesToLogsModel(logSeries, queries);
|
||||||
|
|
||||||
if (logsModel) {
|
if (logsModel) {
|
||||||
// Create histogram metrics from logs using the interval as bucket size for the line count
|
// Create histogram metrics from logs using the interval as bucket size for the line count
|
||||||
@@ -346,7 +346,7 @@ function getLabelsForFrameRow(fields: LogFields, index: number): Labels {
|
|||||||
* Converts dataFrames into LogsModel. This involves merging them into one list, sorting them and computing metadata
|
* Converts dataFrames into LogsModel. This involves merging them into one list, sorting them and computing metadata
|
||||||
* like common labels.
|
* like common labels.
|
||||||
*/
|
*/
|
||||||
export function logSeriesToLogsModel(logSeries: DataFrame[]): LogsModel | undefined {
|
export function logSeriesToLogsModel(logSeries: DataFrame[], queries: DataQuery[] = []): LogsModel | undefined {
|
||||||
if (logSeries.length === 0) {
|
if (logSeries.length === 0) {
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
@@ -432,6 +432,8 @@ export function logSeriesToLogsModel(logSeries: DataFrame[]): LogsModel | undefi
|
|||||||
logLevel = getLogLevel(entry);
|
logLevel = getLogLevel(entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const datasourceType = queries.find((query) => query.refId === series.refId)?.datasource?.type;
|
||||||
|
|
||||||
rows.push({
|
rows.push({
|
||||||
entryFieldIndex: stringField.index,
|
entryFieldIndex: stringField.index,
|
||||||
rowIndex: j,
|
rowIndex: j,
|
||||||
@@ -450,6 +452,7 @@ export function logSeriesToLogsModel(logSeries: DataFrame[]): LogsModel | undefi
|
|||||||
raw: message,
|
raw: message,
|
||||||
labels: labels || {},
|
labels: labels || {},
|
||||||
uid: idField ? idField.values.get(j) : j.toString(),
|
uid: idField ? idField.values.get(j) : j.toString(),
|
||||||
|
datasourceType,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import {
|
|||||||
GrafanaTheme2,
|
GrafanaTheme2,
|
||||||
CoreApp,
|
CoreApp,
|
||||||
} from '@grafana/data';
|
} from '@grafana/data';
|
||||||
|
import { reportInteraction } from '@grafana/runtime';
|
||||||
import { styleMixins, withTheme2, Themeable2, Icon, Tooltip } from '@grafana/ui';
|
import { styleMixins, withTheme2, Themeable2, Icon, Tooltip } from '@grafana/ui';
|
||||||
|
|
||||||
import { checkLogsError, escapeUnescapedString } from '../utils';
|
import { checkLogsError, escapeUnescapedString } from '../utils';
|
||||||
@@ -108,6 +109,14 @@ class UnThemedLogRow extends PureComponent<Props, State> {
|
|||||||
if (!this.props.enableLogDetails) {
|
if (!this.props.enableLogDetails) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
reportInteraction('grafana_explore_logs_log_details_clicked', {
|
||||||
|
datasourceType: this.props.row.datasourceType,
|
||||||
|
type: this.state.showDetails ? 'close' : 'open',
|
||||||
|
logRowUid: this.props.row.uid,
|
||||||
|
app: this.props.app,
|
||||||
|
});
|
||||||
|
|
||||||
this.setState((state) => {
|
this.setState((state) => {
|
||||||
return {
|
return {
|
||||||
showDetails: !state.showDetails,
|
showDetails: !state.showDetails,
|
||||||
|
|||||||
@@ -66,9 +66,11 @@ export const LogsPanel: React.FunctionComponent<LogsPanelProps> = ({
|
|||||||
|
|
||||||
// Important to memoize stuff here, as panel rerenders a lot for example when resizing.
|
// Important to memoize stuff here, as panel rerenders a lot for example when resizing.
|
||||||
const [logRows, deduplicatedRows, commonLabels] = useMemo(() => {
|
const [logRows, deduplicatedRows, commonLabels] = useMemo(() => {
|
||||||
const newResults = data ? dataFrameToLogsModel(data.series, data.request?.intervalMs) : null;
|
const logs = data
|
||||||
const logRows = newResults?.rows || [];
|
? dataFrameToLogsModel(data.series, data.request?.intervalMs, undefined, data.request?.targets)
|
||||||
const commonLabels = newResults?.meta?.find((m) => m.label === COMMON_LABELS);
|
: null;
|
||||||
|
const logRows = logs?.rows || [];
|
||||||
|
const commonLabels = logs?.meta?.find((m) => m.label === COMMON_LABELS);
|
||||||
const deduplicatedRows = dedupLogRows(logRows, dedupStrategy);
|
const deduplicatedRows = dedupLogRows(logRows, dedupStrategy);
|
||||||
return [logRows, deduplicatedRows, commonLabels];
|
return [logRows, deduplicatedRows, commonLabels];
|
||||||
}, [data, dedupStrategy]);
|
}, [data, dedupStrategy]);
|
||||||
|
|||||||
Reference in New Issue
Block a user