Skip to content

Commit 2258e6b

Browse files
authored
Traces: Add traces panel suggestion (#83089)
* Add traces panel suggestion * Render suggestion * Update styling * Update styling
1 parent 9bbb7f6 commit 2258e6b

File tree

8 files changed

+79
-56
lines changed

8 files changed

+79
-56
lines changed

.betterer.results

+1-9
Original file line numberDiff line numberDiff line change
@@ -3339,10 +3339,6 @@ exports[`better eslint`] = {
33393339
"public/app/features/explore/TraceView/components/TracePageHeader/Actions/ActionButton.tsx:5381": [
33403340
[0, 0, 0, "Styles should be written using objects.", "0"]
33413341
],
3342-
"public/app/features/explore/TraceView/components/TracePageHeader/Actions/TracePageActions.tsx:5381": [
3343-
[0, 0, 0, "Styles should be written using objects.", "0"],
3344-
[0, 0, 0, "Styles should be written using objects.", "1"]
3345-
],
33463342
"public/app/features/explore/TraceView/components/TracePageHeader/SearchBar/NextPrevResult.tsx:5381": [
33473343
[0, 0, 0, "Styles should be written using objects.", "0"],
33483344
[0, 0, 0, "Styles should be written using objects.", "1"],
@@ -3402,11 +3398,7 @@ exports[`better eslint`] = {
34023398
[0, 0, 0, "Styles should be written using objects.", "5"],
34033399
[0, 0, 0, "Styles should be written using objects.", "6"],
34043400
[0, 0, 0, "Styles should be written using objects.", "7"],
3405-
[0, 0, 0, "Styles should be written using objects.", "8"],
3406-
[0, 0, 0, "Styles should be written using objects.", "9"],
3407-
[0, 0, 0, "Styles should be written using objects.", "10"],
3408-
[0, 0, 0, "Styles should be written using objects.", "11"],
3409-
[0, 0, 0, "Styles should be written using objects.", "12"]
3401+
[0, 0, 0, "Styles should be written using objects.", "8"]
34103402
],
34113403
"public/app/features/explore/TraceView/components/TraceTimelineViewer/SpanBarRow.tsx:5381": [
34123404
[0, 0, 0, "Styles should be written using objects.", "0"],

.betterer.results.json

+1-7
Original file line numberDiff line numberDiff line change
@@ -3838,12 +3838,6 @@
38383838
"count": 1
38393839
}
38403840
],
3841-
"/public/app/features/explore/TraceView/components/TracePageHeader/Actions/TracePageActions.tsx": [
3842-
{
3843-
"message": "Styles should be written using objects.",
3844-
"count": 2
3845-
}
3846-
],
38473841
"/public/app/features/explore/TraceView/components/TracePageHeader/SearchBar/NextPrevResult.tsx": [
38483842
{
38493843
"message": "Styles should be written using objects.",
@@ -3895,7 +3889,7 @@
38953889
"/public/app/features/explore/TraceView/components/TracePageHeader/TracePageHeader.tsx": [
38963890
{
38973891
"message": "Styles should be written using objects.",
3898-
"count": 13
3892+
"count": 9
38993893
}
39003894
],
39013895
"/public/app/features/explore/TraceView/components/TraceTimelineViewer/SpanBarRow.tsx": [

public/app/features/explore/TraceView/components/TracePageHeader/Actions/TracePageActions.tsx

+16-15
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,22 @@ import ActionButton from './ActionButton';
1212

1313
export const getStyles = (theme: GrafanaTheme2) => {
1414
return {
15-
TracePageActions: css`
16-
label: TracePageActions;
17-
display: flex;
18-
align-items: center;
19-
justify-content: center;
20-
gap: 4px;
21-
`,
22-
feedback: css`
23-
margin: 6px;
24-
color: ${theme.colors.text.secondary};
25-
font-size: ${theme.typography.bodySmall.fontSize};
26-
&:hover {
27-
color: ${theme.colors.text.link};
28-
}
29-
`,
15+
TracePageActions: css({
16+
label: 'TracePageActions',
17+
display: 'flex',
18+
alignItems: 'center',
19+
justifyContent: 'center',
20+
gap: '4px',
21+
marginBottom: '10px',
22+
}),
23+
feedback: css({
24+
margin: '6px 6px 6px 0',
25+
color: theme.colors.text.secondary,
26+
fontSize: theme.typography.bodySmall.fontSize,
27+
'&:hover': {
28+
color: theme.colors.text.link,
29+
},
30+
}),
3031
};
3132
};
3233

public/app/features/explore/TraceView/components/TracePageHeader/TracePageHeader.tsx

+28-24
Original file line numberDiff line numberDiff line change
@@ -202,30 +202,34 @@ const getNewStyles = (theme: GrafanaTheme2) => {
202202
color: unset;
203203
}
204204
`,
205-
header: css`
206-
label: TracePageHeader;
207-
background-color: ${theme.colors.background.primary};
208-
padding: 0.5em 0 0 0;
209-
position: sticky;
210-
top: 0;
211-
z-index: 5;
212-
`,
213-
titleRow: css`
214-
align-items: flex-start;
215-
display: flex;
216-
padding: 0 8px;
217-
`,
218-
title: css`
219-
color: inherit;
220-
flex: 1;
221-
font-size: 1.7em;
222-
line-height: 1em;
223-
`,
224-
subtitle: css`
225-
flex: 1;
226-
line-height: 1em;
227-
margin: -0.5em 0.5em 0.75em 0.5em;
228-
`,
205+
header: css({
206+
label: 'TracePageHeader',
207+
backgroundColor: theme.colors.background.primary,
208+
padding: '0.5em 0 0 0',
209+
position: 'sticky',
210+
top: 0,
211+
zIndex: 5,
212+
textAlign: 'left',
213+
}),
214+
titleRow: css({
215+
alignItems: 'flex-start',
216+
display: 'flex',
217+
padding: '0 8px',
218+
flexWrap: 'wrap',
219+
}),
220+
title: css({
221+
color: 'inherit',
222+
flex: 1,
223+
fontSize: '1.7em',
224+
lineHeight: '1em',
225+
marginBottom: 0,
226+
minWidth: '200px',
227+
}),
228+
subtitle: css({
229+
flex: 1,
230+
lineHeight: '1em',
231+
margin: '-0.5em 0.5em 0.75em 0.5em',
232+
}),
229233
tag: css`
230234
margin: 0 0.5em 0 0;
231235
`,

public/app/features/panel/state/getAllSuggestions.ts

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ export const panelsToCheckFirst = [
2121
'logs',
2222
'candlestick',
2323
'flamegraph',
24+
'traces',
2425
];
2526

2627
export async function getAllSuggestions(data?: PanelData, panel?: PanelModel): Promise<VisualizationSuggestion[]> {
+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { PanelPlugin } from '@grafana/data';
22

33
import { TracesPanel } from './TracesPanel';
4+
import { TracesSuggestionsSupplier } from './suggestions';
45

5-
export const plugin = new PanelPlugin(TracesPanel);
6+
export const plugin = new PanelPlugin(TracesPanel).setSuggestionsSupplier(new TracesSuggestionsSupplier());
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import { VisualizationSuggestionsBuilder, VisualizationSuggestionScore } from '@grafana/data';
2+
import { SuggestionName } from 'app/types/suggestions';
3+
4+
export class TracesSuggestionsSupplier {
5+
getListWithDefaults(builder: VisualizationSuggestionsBuilder) {
6+
return builder.getListAppender<{}, {}>({
7+
name: SuggestionName.Trace,
8+
pluginId: 'traces',
9+
});
10+
}
11+
12+
getSuggestionsForData(builder: VisualizationSuggestionsBuilder) {
13+
if (!builder.data) {
14+
return;
15+
}
16+
17+
const dataFrame = builder.data.series[0];
18+
if (!dataFrame) {
19+
return;
20+
}
21+
22+
if (builder.data.series[0].meta?.preferredVisualisationType === 'trace') {
23+
this.getListWithDefaults(builder).append({
24+
name: SuggestionName.Trace,
25+
score: VisualizationSuggestionScore.Best,
26+
});
27+
}
28+
}
29+
}

public/app/types/suggestions.ts

+1
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,5 @@ export enum SuggestionName {
2828
DashboardList = 'Dashboard list',
2929
Logs = 'Logs',
3030
FlameGraph = 'Flame graph',
31+
Trace = 'Trace',
3132
}

0 commit comments

Comments
 (0)