feat(observability-lib): add SortBy and SortDesc to LegendOptions#1799
feat(observability-lib): add SortBy and SortDesc to LegendOptions#1799
Conversation
Expose the underlying Grafana SDK's VizLegendOptions sorting fields to allow legend tables to be sorted by a specific calculation field (e.g., "Last *", "Max") in ascending or descending order. This enables dashboards to surface the most important series at the top of the legend table, improving readability for error rate panels.
✅ API Diff Results - No breaking changes |
There was a problem hiding this comment.
Pull request overview
This PR adds legend sorting capabilities to the observability-lib by exposing Grafana SDK's VizLegendOptions sorting fields. This enables dashboards to display the most important series (e.g., highest error rates) at the top of legend tables.
Changes:
- Added
SortByandSortDescfields toLegendOptionsstruct - Implemented conditional application of sorting options in
newLegendfunction
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Only set SortDesc when SortBy is specified, and pass the value directly rather than hardcoding true.
1342453 to
1ff9717
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Fix comment examples to match actual Grafana format ("Last *", "Max")
- Only set SortDesc when true to avoid unnecessary explicit false values
ad4f9a6 to
741332c
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Summary
Expose the underlying Grafana SDK's
VizLegendOptionssorting fields to allow legend tables to be sorted by a specific calculation field.SortByfield to specify which calculation to sort by (e.g., "Last *", "Max")SortDescfield to enable descending sort orderMotivation
This enables dashboards to surface the most important series at the top of the legend table, improving readability for error rate panels where you want to see the highest error rates first.
Test plan