Traces: Add traces panel suggestion (#83089)

* Add traces panel suggestion

* Render suggestion

* Update styling

* Update styling
This commit is contained in:
Joey
2024-02-21 13:49:41 +00:00
committed by GitHub
parent 9bbb7f67e0
commit 2258e6bd16
8 changed files with 79 additions and 56 deletions

View File

@ -3339,10 +3339,6 @@ exports[`better eslint`] = {
"public/app/features/explore/TraceView/components/TracePageHeader/Actions/ActionButton.tsx:5381": [ "public/app/features/explore/TraceView/components/TracePageHeader/Actions/ActionButton.tsx:5381": [
[0, 0, 0, "Styles should be written using objects.", "0"] [0, 0, 0, "Styles should be written using objects.", "0"]
], ],
"public/app/features/explore/TraceView/components/TracePageHeader/Actions/TracePageActions.tsx:5381": [
[0, 0, 0, "Styles should be written using objects.", "0"],
[0, 0, 0, "Styles should be written using objects.", "1"]
],
"public/app/features/explore/TraceView/components/TracePageHeader/SearchBar/NextPrevResult.tsx:5381": [ "public/app/features/explore/TraceView/components/TracePageHeader/SearchBar/NextPrevResult.tsx:5381": [
[0, 0, 0, "Styles should be written using objects.", "0"], [0, 0, 0, "Styles should be written using objects.", "0"],
[0, 0, 0, "Styles should be written using objects.", "1"], [0, 0, 0, "Styles should be written using objects.", "1"],
@ -3402,11 +3398,7 @@ exports[`better eslint`] = {
[0, 0, 0, "Styles should be written using objects.", "5"], [0, 0, 0, "Styles should be written using objects.", "5"],
[0, 0, 0, "Styles should be written using objects.", "6"], [0, 0, 0, "Styles should be written using objects.", "6"],
[0, 0, 0, "Styles should be written using objects.", "7"], [0, 0, 0, "Styles should be written using objects.", "7"],
[0, 0, 0, "Styles should be written using objects.", "8"], [0, 0, 0, "Styles should be written using objects.", "8"]
[0, 0, 0, "Styles should be written using objects.", "9"],
[0, 0, 0, "Styles should be written using objects.", "10"],
[0, 0, 0, "Styles should be written using objects.", "11"],
[0, 0, 0, "Styles should be written using objects.", "12"]
], ],
"public/app/features/explore/TraceView/components/TraceTimelineViewer/SpanBarRow.tsx:5381": [ "public/app/features/explore/TraceView/components/TraceTimelineViewer/SpanBarRow.tsx:5381": [
[0, 0, 0, "Styles should be written using objects.", "0"], [0, 0, 0, "Styles should be written using objects.", "0"],

View File

@ -3838,12 +3838,6 @@
"count": 1 "count": 1
} }
], ],
"/public/app/features/explore/TraceView/components/TracePageHeader/Actions/TracePageActions.tsx": [
{
"message": "Styles should be written using objects.",
"count": 2
}
],
"/public/app/features/explore/TraceView/components/TracePageHeader/SearchBar/NextPrevResult.tsx": [ "/public/app/features/explore/TraceView/components/TracePageHeader/SearchBar/NextPrevResult.tsx": [
{ {
"message": "Styles should be written using objects.", "message": "Styles should be written using objects.",
@ -3895,7 +3889,7 @@
"/public/app/features/explore/TraceView/components/TracePageHeader/TracePageHeader.tsx": [ "/public/app/features/explore/TraceView/components/TracePageHeader/TracePageHeader.tsx": [
{ {
"message": "Styles should be written using objects.", "message": "Styles should be written using objects.",
"count": 13 "count": 9
} }
], ],
"/public/app/features/explore/TraceView/components/TraceTimelineViewer/SpanBarRow.tsx": [ "/public/app/features/explore/TraceView/components/TraceTimelineViewer/SpanBarRow.tsx": [

View File

@ -12,21 +12,22 @@ import ActionButton from './ActionButton';
export const getStyles = (theme: GrafanaTheme2) => { export const getStyles = (theme: GrafanaTheme2) => {
return { return {
TracePageActions: css` TracePageActions: css({
label: TracePageActions; label: 'TracePageActions',
display: flex; display: 'flex',
align-items: center; alignItems: 'center',
justify-content: center; justifyContent: 'center',
gap: 4px; gap: '4px',
`, marginBottom: '10px',
feedback: css` }),
margin: 6px; feedback: css({
color: ${theme.colors.text.secondary}; margin: '6px 6px 6px 0',
font-size: ${theme.typography.bodySmall.fontSize}; color: theme.colors.text.secondary,
&:hover { fontSize: theme.typography.bodySmall.fontSize,
color: ${theme.colors.text.link}; '&:hover': {
} color: theme.colors.text.link,
`, },
}),
}; };
}; };

View File

@ -202,30 +202,34 @@ const getNewStyles = (theme: GrafanaTheme2) => {
color: unset; color: unset;
} }
`, `,
header: css` header: css({
label: TracePageHeader; label: 'TracePageHeader',
background-color: ${theme.colors.background.primary}; backgroundColor: theme.colors.background.primary,
padding: 0.5em 0 0 0; padding: '0.5em 0 0 0',
position: sticky; position: 'sticky',
top: 0; top: 0,
z-index: 5; zIndex: 5,
`, textAlign: 'left',
titleRow: css` }),
align-items: flex-start; titleRow: css({
display: flex; alignItems: 'flex-start',
padding: 0 8px; display: 'flex',
`, padding: '0 8px',
title: css` flexWrap: 'wrap',
color: inherit; }),
flex: 1; title: css({
font-size: 1.7em; color: 'inherit',
line-height: 1em; flex: 1,
`, fontSize: '1.7em',
subtitle: css` lineHeight: '1em',
flex: 1; marginBottom: 0,
line-height: 1em; minWidth: '200px',
margin: -0.5em 0.5em 0.75em 0.5em; }),
`, subtitle: css({
flex: 1,
lineHeight: '1em',
margin: '-0.5em 0.5em 0.75em 0.5em',
}),
tag: css` tag: css`
margin: 0 0.5em 0 0; margin: 0 0.5em 0 0;
`, `,

View File

@ -21,6 +21,7 @@ export const panelsToCheckFirst = [
'logs', 'logs',
'candlestick', 'candlestick',
'flamegraph', 'flamegraph',
'traces',
]; ];
export async function getAllSuggestions(data?: PanelData, panel?: PanelModel): Promise<VisualizationSuggestion[]> { export async function getAllSuggestions(data?: PanelData, panel?: PanelModel): Promise<VisualizationSuggestion[]> {

View File

@ -1,5 +1,6 @@
import { PanelPlugin } from '@grafana/data'; import { PanelPlugin } from '@grafana/data';
import { TracesPanel } from './TracesPanel'; import { TracesPanel } from './TracesPanel';
import { TracesSuggestionsSupplier } from './suggestions';
export const plugin = new PanelPlugin(TracesPanel); export const plugin = new PanelPlugin(TracesPanel).setSuggestionsSupplier(new TracesSuggestionsSupplier());

View File

@ -0,0 +1,29 @@
import { VisualizationSuggestionsBuilder, VisualizationSuggestionScore } from '@grafana/data';
import { SuggestionName } from 'app/types/suggestions';
export class TracesSuggestionsSupplier {
getListWithDefaults(builder: VisualizationSuggestionsBuilder) {
return builder.getListAppender<{}, {}>({
name: SuggestionName.Trace,
pluginId: 'traces',
});
}
getSuggestionsForData(builder: VisualizationSuggestionsBuilder) {
if (!builder.data) {
return;
}
const dataFrame = builder.data.series[0];
if (!dataFrame) {
return;
}
if (builder.data.series[0].meta?.preferredVisualisationType === 'trace') {
this.getListWithDefaults(builder).append({
name: SuggestionName.Trace,
score: VisualizationSuggestionScore.Best,
});
}
}
}

View File

@ -28,4 +28,5 @@ export enum SuggestionName {
DashboardList = 'Dashboard list', DashboardList = 'Dashboard list',
Logs = 'Logs', Logs = 'Logs',
FlameGraph = 'Flame graph', FlameGraph = 'Flame graph',
Trace = 'Trace',
} }