Skip to content

fix(default-metrics): register metrics alphabetically - #811

Open
salman-frs wants to merge 1 commit into
prometheus:mainfrom
salman-frs:fix/alphabetize-default-metrics
Open

fix(default-metrics): register metrics alphabetically#811
salman-frs wants to merge 1 commit into
prometheus:mainfrom
salman-frs:fix/alphabetize-default-metrics

Conversation

@salman-frs

Copy link
Copy Markdown

Default metrics currently follow collector registration order, so the output is not ordered by metric name.

This reorders metric groups and metrics inside multi-metric collectors where needed. Shared collect() callbacks move to the first registered metric so sibling values are populated before the registry reads them.

Collectors such as heapSizeAndUsed register names under more than one prefix, so object order alone cannot produce a globally sorted result. collectDefaultMetrics() therefore sorts only the newly registered default metrics once after registration. Existing custom metrics keep their registration order.

Tests:

  • npm test
  • bun test-unit

Fixes #810.

Signed-off-by: salman-frs <sallman.alffarisi@gmail.com>
@jdmarshall jdmarshall added this to the v1 milestone Aug 22, 2026
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.

Alphabetize default metrics

2 participants