Skip to content

[FEATURE](components): add dtdhms and additional throughput rate units - #287

Open
colivi wants to merge 3 commits into
perses:mainfrom
colivi:feat/format-units-dtdhms-throughput
Open

[FEATURE](components): add dtdhms and additional throughput rate units#287
colivi wants to merge 3 commits into
perses:mainfrom
colivi:feat/format-units-dtdhms-throughput

Conversation

@colivi

@colivi colivi commented Sep 11, 2026

Copy link
Copy Markdown

Description

Extend value formatters for dashboard panel units:

"dtdhms" ("time.ts")

  • Input: duration in seconds
  • Output: "D d HH:MM:SS" (or "HH:MM:SS" if < 1 day)
  • Does not auto-scale to months/years (unlike "seconds")

Throughput rates ("throughput.ts")

New units (id = display suffix):
"tps", "trc/s", "trx/s", "e/s", "op/s", "ops/s", "msg/s", "msg/sec", "errors/s", "calls/s", "qps", "drop/s", "reject/s", "requests/s", "flows/s", "fail/sec", "to/s", "c/s", "gc/s", "tk/s", "cxn/s"

"count:*" variants ("count:tps", "count:traces/s", "count:msg/s") display without the "count:" prefix.

Unit tests added in "time.test.ts" and "throughput.test.ts".

Companion Go SDK PR: "perses/perses" branch "feat/format-units-dtdhms-throughput".

Screenshots

N/A — unit string formatting only (no layout/CSS). Example outputs from tests:

  • "format({ unit: 'dtdhms' }, 14093232)" → "163 d 02:47:12"
  • "format({ unit: 'tps' }, 42)" → "42 tps"
  • "format({ unit: 'count:tps' }, 6)" → "6 tps"

Checklist

  • Pull request has a descriptive title and context useful to a reviewer.
  • Pull request title follows the "[FEATURE] …" naming convention.
  • All commits have DCO signoffs.

UI Changes

  • Formatting-only change; screenshots N/A (covered by unit tests).
  • Follows existing unit formatter patterns in "components/src/model/".
  • No E2E impact (pure format helpers).

- dtdhms: format duration in seconds as D d HH:MM:SS
- throughput: tps, trc/s, trx/s, op/s, msg/s, qps, errors/s, and related rates
- count:* units display without the count: prefix

Signed-off-by: colivi <charles.olivi@gmail.com>
@colivi
colivi requested a review from a team as a code owner September 11, 2026 13:20
@colivi colivi changed the title feat(components): add dtdhms and additional throughput rate units [FEATURE](components): add dtdhms and additional throughput rate units Sep 11, 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.

The new units have to be supported on backend (CUE) side too, here, otherwise the backend validation will fail. Example of past PR that added units.

Additionally & optionally, if you can map these new units to Grafana ones it would improve the migration quality https://github.com/perses/shared/blob/main/cue/common/migrate/mapping.cue#L18

Backend validation must accept the same unit ids as the TS formatters.
Also map Grafana dtdhms and rate aliases in migrate/mapping.cue.

Signed-off-by: colivi <charles.olivi@gmail.com>
@colivi

colivi commented Sep 14, 2026

Copy link
Copy Markdown
Author

The new units have to be supported on backend (CUE) side too, here, otherwise the backend validation will fail. Example of past PR that added units.

Additionally & optionally, if you can map these new units to Grafana ones it would improve the migration quality https://github.com/perses/shared/blob/main/cue/common/migrate/mapping.cue#L18

Thanks Antoine, added backend CUE support in cue/common/format.cue so validation accepts dtdhms and the new throughput unit ids (aligned with the TS formatters).
Also extended cue/common/migrate/mapping.cue so Grafana dtdhms and the rate aliases map to the same Perses unit ids.

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.

2 participants