Skip to content

Conversation

@jharshman
Copy link
Contributor

@jharshman jharshman commented Jul 8, 2025

Support sourcing legend value from metric or resource sources. The legend key may belong to either a metric label or resource label.

@jharshman jharshman requested a review from Copilot July 8, 2025 22:28
Copy link

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 enhances the legend generation in tsplot/plot.go by allowing the legend key to be sourced from either metric labels or resource labels when the metric label is empty.

  • Added fallback logic to use resource labels if the metric label lookup returns an empty string.
  • Renamed and clarified the polygon variable (legendThumbnail) for rendering the legend.
  • Retained existing legend styling (alignment and padding) while updating how entries are added.
Comments suppressed due to low confidence (1)

tsplot/plot.go:113

  • There are no unit tests covering the new fallback logic from resource labels. Please add tests for both cases where the metric label is present and where it falls back to the resource label.
			legendEntry := timeSeries.GetMetric().GetLabels()[legendKey]

@jharshman jharshman force-pushed the support-resource-labels-in-legend branch from eabd4bb to 56e7363 Compare July 9, 2025 01:02
Copy link

@nckrse nckrse left a comment

Choose a reason for hiding this comment

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

LGTM 👍

@jharshman jharshman merged commit 30cb5b3 into bitly:master Jul 10, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants