Skip to content

[FEATURE] Add metadata dialog for Exemplars - #278

Merged
AntoineThebaud merged 6 commits into
perses:mainfrom
julianocosta89:exemplars/3445-metadata-dialog
Sep 11, 2026
Merged

AntoineThebaud merged 6 commits into
perses:mainfrom
julianocosta89:exemplars/3445-metadata-dialog

Conversation

@julianocosta89

@julianocosta89 julianocosta89 commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

Part of #3445 (perses/perses#3445).

Adds an ExemplarMetadataTooltip to @perses-dev/components that shows the metadata of a single exemplar: the labels of its series, the exemplar's own labels (e.g. trace ID), its value and its timestamp. It follows the same pattern as the existing chart tooltips (TimeChartTooltip / annotation tooltip): it renders in a portal next to the chart, follows the mouse while an exemplar marker is hovered, and can be pinned in place when the marker is clicked — no modal dialog, the chart stays interactive.

Lives in shared from the start — as suggested in the issue — so HeatMapChart can reuse it later. It's a self-contained presentational component (props: exemplar, optional seriesLabels, optional FormatOptions for the value, pinnedPos, enablePinning, onUnpinClick), built on the shared tooltip positioning helpers (assembleTransform, getTooltipStyles, useMousePosition).

Note: this builds on the exemplars contract in @perses-dev/spec (merged as perses/spec#97, TimeSeriesData.exemplars); the exemplar types it imports land in the next spec release.

Testing

  • 4 new unit tests in components/src/ExemplarMetadata/ExemplarMetadataTooltip.test.tsx (renders labels/value when pinned, renders while following the mouse, unpin affordance + onUnpinClick, hides the series-labels section when undefined)
  • Full components suite: 889 tests pass; type-check, oxlint, oxfmt clean

Screenshots

Dark mode:

image

Mouse hover opens the dialog and if we click on it, it pins the dialog.

image

Light mode:

image image

@julianocosta89
julianocosta89 requested a review from a team as a code owner September 7, 2026 13:08
@julianocosta89
julianocosta89 force-pushed the exemplars/3445-metadata-dialog branch 2 times, most recently from 2230167 to 025919e Compare September 8, 2026 12:07
Tooltip showing a single exemplar's metadata (series labels, exemplar
labels, value and timestamp) that follows the mouse while an exemplar
marker is hovered and can be pinned in place when the marker is clicked,
built on the shared tooltip helpers (assembleTransform, getTooltipStyles,
useMousePosition) — same interaction as the annotation tooltip — so
panels can render it next to the chart, HeatMapChart included later.

Signed-off-by: Juliano Costa <juliano.costa@datadoghq.com>
@julianocosta89
julianocosta89 force-pushed the exemplars/3445-metadata-dialog branch from 025919e to 273ac03 Compare September 8, 2026 12:08
@AntoineThebaud

Copy link
Copy Markdown
Contributor

Can you please provide a screenshot of a sample metadata dialog in the Screenshots section of the PR desc? thank you in advance 🙏

@Nexucis

Nexucis commented Sep 9, 2026

Copy link
Copy Markdown
Member

@julianocosta89 I have updated the spec dependency. If you rebase your PR hopefully the CI should pass now.

@julianocosta89

Copy link
Copy Markdown
Contributor Author

@AntoineThebaud I added screenshots now.

In order to actually see the exemplars, we need to enable it.
I added a screenshot on the toggle enable/disable on perses/plugins#799.

@julianocosta89

Copy link
Copy Markdown
Contributor Author

@Nexucis would you be able to approve the run?

@AntoineThebaud AntoineThebaud changed the title Exemplars/3445 metadata dialog [FEATURE] Add metadata dialog for Exemplars Sep 10, 2026

@AntoineThebaud AntoineThebaud left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for your work! Just asking some small visual adjustments for the dialog, we'd like something like this:

Image

So basically:

  • timestamp at the top to align on the TimeSeriesTooltip:
Image
  • same vertical spacing between sections
  • horizontal align for series labels values.

@julianocosta89

Copy link
Copy Markdown
Contributor Author

Addressed @AntoineThebaud

image

Signed-off-by: Juliano Costa <juliano.costa@datadoghq.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Changes recommended

Initial pinned positioning is incorrect, and the interactive unpin control is inaccessible to keyboard users.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

Adds a reusable exemplar metadata tooltip to the components package.

Changes:

  • Displays exemplar labels, series labels, formatted value, and timestamp.
  • Supports mouse-following and pinned positioning.
  • Adds public exports and focused component tests.
File summaries
File Description
components/src/index.ts Exports exemplar metadata APIs.
components/src/ExemplarMetadata/index.ts Defines the feature barrel export.
components/src/ExemplarMetadata/ExemplarMetadataTooltip.tsx Implements the tooltip UI and positioning.
components/src/ExemplarMetadata/ExemplarMetadataTooltip.test.tsx Tests rendering, following, and unpinning behavior.
Review details

Suppressed comments (1)

components/src/ExemplarMetadata/ExemplarMetadataTooltip.tsx:138

  • Exemplar.labels may be empty; in that case LabelGrid returns null while this divider still renders immediately above Value. Render the grid and divider together only when labels contain entries.
            <LabelGrid title="Exemplar labels" labels={labels} />
            <Divider />
  • Files reviewed: 4/4 changed files
  • Comments generated: 4
  • Review effort level: Balanced

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread components/src/ExemplarMetadata/ExemplarMetadataTooltip.tsx Outdated
Comment thread components/src/ExemplarMetadata/ExemplarMetadataTooltip.tsx Outdated
Comment thread components/src/ExemplarMetadata/ExemplarMetadataTooltip.tsx Outdated
Comment thread components/src/ExemplarMetadata/ExemplarMetadataTooltip.tsx Outdated
- Fall back to pinnedPos when no mousemove has happened yet, so a pinned
  tooltip renders at its saved position instead of (0, 0)
- Wrap the unpin Pin icon in an IconButton with an aria-label so keyboard
  and screen-reader users can invoke it
- Document containerId as a CSS selector, matching document.querySelector
- Build the body from non-empty sections so no divider is left dangling
  when series or exemplar labels are empty, plus a test for that case

Signed-off-by: Juliano Costa <juliano.costa@datadoghq.com>
@julianocosta89

Copy link
Copy Markdown
Contributor Author

@Nexucis copilot comments addressed ✅

@Nexucis

Nexucis commented Sep 10, 2026

Copy link
Copy Markdown
Member

So cool, thank you @julianocosta89 !

@Gladorme can you check for the final review before moving forward please ?

@AntoineThebaud

Copy link
Copy Markdown
Contributor

Looking at your latest screenshot it's still missing these 2 suggested changes:

  • same vertical spacing between sections
  • horizontal align for series labels values.

Btw I just realized now that when light theme is on, the color of the separator between section is not right (it becomes dark gray, so barely visible that I didn't even notice the separators the first time).

…nd divider color

- Even vertical spacing between sections: sections are now laid out in a
  Stack with spacing, so the gap around every separator is identical
- Horizontally align series/exemplar label values: label rows now use a
  CSS grid whose first column is sized by the longest label name, so all
  values start at the same x position
- Fix separators being barely visible in light theme: section dividers
  were using the default theme divider color, which becomes a dark
  overlay on the always-dark tooltip background. Pin them to
  grey['500'] like the header divider

Signed-off-by: Juliano Costa <juliano.costa@datadoghq.com>
@julianocosta89
julianocosta89 force-pushed the exemplars/3445-metadata-dialog branch from 07d6e0f to 503d783 Compare September 11, 2026 06:58
@julianocosta89

Copy link
Copy Markdown
Contributor Author

Thanks for the feedback @AntoineThebaud, I indeed missed the 2 suggestions that were at the bottom.
I've addressed them in my last commit, and now the preview looks like this:

Light mode:
image

Dark mode:
image

@AntoineThebaud AntoineThebaud left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Great! Thank you for this contribution 🙏

@AntoineThebaud
AntoineThebaud merged commit 365e449 into perses:main Sep 11, 2026
13 checks passed
@julianocosta89
julianocosta89 deleted the exemplars/3445-metadata-dialog branch September 11, 2026 12:07
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