mirror of https://github.com/grafana/grafana
Traces: Add traces panel suggestion (#83089)
* Add traces panel suggestion * Render suggestion * Update styling * Update stylingpull/83172/head
parent
9bbb7f67e0
commit
2258e6bd16
@ -1,5 +1,6 @@ |
||||
import { PanelPlugin } from '@grafana/data'; |
||||
|
||||
import { TracesPanel } from './TracesPanel'; |
||||
import { TracesSuggestionsSupplier } from './suggestions'; |
||||
|
||||
export const plugin = new PanelPlugin(TracesPanel); |
||||
export const plugin = new PanelPlugin(TracesPanel).setSuggestionsSupplier(new TracesSuggestionsSupplier()); |
||||
|
@ -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, |
||||
}); |
||||
} |
||||
} |
||||
} |
Loading…
Reference in new issue