Strip shared pod-name prefix from metric chart legends#189
Merged
Conversation
Per-pod metric lines are keyed by the full k8s pod name
(`<resourceName>-<projectID>-<rsHash>-<podHash>`). That prefix is
identical on every pod of a deployment, so in the legend it's pure noise
that pushes the only distinguishing part — the pod hash — off the edge.
With id-based deployment naming the prefix is also an opaque `0d<id>`
resource name the user never chose.
Chart.svelte now computes the longest prefix common to every line in a
panel, trimmed back to a '-' boundary so whole name segments are removed
(never a hash mid-token), and shows only the remaining suffix
("Usage · x2k9p"). When lines share no '-'-bounded prefix the function
returns 0 and labels are unchanged, so non-pod charts (project usage,
aggregate mode) are unaffected.
Also makes the mock `deployment.metrics` fixture faithful to live
(non-aggregate) mode: two pods of an id-named deployment, every line
keyed by full pod name — which is what exercises the new stripping.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Deploying deploys-app--console with
|
| Latest commit: |
09183c3
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://8a2673cf.deploys-app--console.pages.dev |
| Branch Preview URL: | https://hide-pod-prefix.deploys-app--console.pages.dev |
Extends the metrics-legend prefix stripping to the deployment logs and events pages. Pod names there are the full k8s name (`<kubeName>-<projectID>-<rsHash>-<podHash>`) — the logs chip shows it verbatim, and event messages embed it in free text. The shared `<kubeName>-<projectID>` part is noise (and, for id-named deployments, the opaque `0d<id>`). New `$lib/deployment/podName.js` derives the prefix from the deployment's `internalAddress` (which the API sets to exactly `<kubeName>-<projectID>`) and strips it wherever it appears, with a `0d<id>-<projectID>` fallback so id-named pods are hidden even if internalAddress is unavailable. - logs: chip shows the `<rsHash>-<podHash>` suffix; full name kept for the hash color and the hover title. - events: pod refs in reason/message are stripped; full text kept on hover. Container names and namespaces are left intact. Mocks made faithful so this is exercisable offline: deployment internalAddress is now the real `<kubeName>-<projectID>` format, and the mock log/event feeds use full id-named pod names. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The apiserver resource-name prefix changed from `0d<id>` to `d<id>` so the derived k8s Service name is a valid DNS-1035 label. Update the pod-name stripper's fallback regex (`0d\d+-\d+` → `d\d+-\d+`) and the mock pod names/internalAddress to match. The primary strip path (exact internalAddress) is unaffected. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Deployment/disk metric charts label each per-pod line by its full k8s pod name —
<resourceName>-<projectID>-<rsHash>-<podHash>. Every pod of one deployment shares that long prefix, so the legend repeats it on every entry and the only part that actually distinguishes one pod from another — the trailing pod hash — gets pushed off the edge. With the new id-based deployment naming (deploy-by-id), that shared prefix is also an opaque0d<id>resource name the user never chose.This strips the shared prefix and shows only the distinguishing suffix:
Usage · 0d128-77-7d8f9b6c5-x2k9p→Usage · x2k9pHow
Chart.sveltecomputes the longest prefix common to all lines in a panel, trimmed back to a-boundary so only whole name segments are removed (never a hash cut mid-token), then rendersname.slice(prefixLen).--bounded prefix, the helper returns0and labels are byte-identical to today. Project-level usage charts (single-line series) and aggregate mode (one line per series, named by deployment) are therefore unaffected —podLabelis only reached for multi-line series.deployment.metrics, every line (usage and limit/allocated) is keyed by thepodlabel, so the common-prefix strip applies uniformly across a panel. In aggregate mode each series is a single deployment-named line, so the label path isn't taken.Also makes the mock
deployment.metricsfixture faithful to live (non-aggregate) mode — two pods of an id-named deployment, every line keyed by full pod name — which is what exercises the new behavior offline.Verification
bun lint✅ ·bun check✅ (0 errors) · rendered in mock mode, light + dark.Legend before:
Usage · 0d128-77-7d8f9b6c5-x2k9p,Usage · 0d128-77-7d8f9b6c5-q8m2t, …Legend after:
Usage · x2k9p,Usage · q8m2t,Limit · x2k9p,Limit · q8m2t, …🤖 Generated with Claude Code