Skip to content

feat(observability-lib): add SortBy and SortDesc to LegendOptions#1799

Merged
Atrax1 merged 3 commits intomainfrom
feat/observability-lib-legend-sorting
Jan 27, 2026
Merged

feat(observability-lib): add SortBy and SortDesc to LegendOptions#1799
Atrax1 merged 3 commits intomainfrom
feat/observability-lib-legend-sorting

Conversation

@leeyikjiun
Copy link
Contributor

Summary

Expose the underlying Grafana SDK's VizLegendOptions sorting fields to allow legend tables to be sorted by a specific calculation field.

  • Add SortBy field to specify which calculation to sort by (e.g., "Last *", "Max")
  • Add SortDesc field to enable descending sort order

Motivation

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

  • Verified SDK methods exist and are called correctly
  • Tested locally with cre-platform-data dashboard changes

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.
@github-actions
Copy link

github-actions bot commented Jan 27, 2026

✅ API Diff Results - No breaking changes


📄 View full apidiff report

@leeyikjiun leeyikjiun requested a review from Copilot January 27, 2026 12:11
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 SortBy and SortDesc fields to LegendOptions struct
  • Implemented conditional application of sorting options in newLegend function

💡 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.
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@leeyikjiun leeyikjiun requested a review from Atrax1 January 27, 2026 12:29
@leeyikjiun leeyikjiun marked this pull request as ready for review January 27, 2026 12:29
@leeyikjiun leeyikjiun requested a review from a team as a code owner January 27, 2026 12:29
@Atrax1 Atrax1 added this pull request to the merge queue Jan 27, 2026
Merged via the queue into main with commit f04b59e Jan 27, 2026
36 of 37 checks passed
@Atrax1 Atrax1 deleted the feat/observability-lib-legend-sorting branch January 27, 2026 15:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants