Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

feat: expose Desc error through public Err() method#1902

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
duricanikolic wants to merge1 commit intoprometheus:main
base:main
Choose a base branch
Loading
fromduricanikolic:yuri/expose-err-desc

Conversation

@duricanikolic
Copy link

@duricanikolicduricanikolic commentedOct 31, 2025
edited
Loading

Adds a publicErr() method toDesc type to allow users to check if an error occurred during descriptor construction. Previously, the error field was private and inaccessible.

Our use case is as follows:

  • We create aDesc.
  • We define and register a custom collector.
  • In the collector’sCollect() method, we dynamically create aMetric usingNewConstMetric() to report the current value.

However, if theDesc was constructed with an error (for example, due to an invalid label name), that error remains hidden until the collector’sCollect() method is invoked for the first time.

It would be much more practical if the Prometheus API exposed a method such asDesc.Err(), which would return any error that occurred during the creation of theDesc. That's the motivation for the present PR.

Signed-off-by: Yuri Nikolicdurica.nikolic@grafana.com

Adds a public Err() method to Desc type to allow users to check ifan error occurred during descriptor construction. Previously, the errorfield was private and inaccessible.🤖 Generated with [Claude Code](https://claude.com/claude-code)Co-Authored-By: Claude <noreply@anthropic.com>Signed-off-by: Yuri Nikolic <durica.nikolic@grafana.com>
Copy link
Member

@bborehambboreham left a comment

Choose a reason for hiding this comment

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

lgtm

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@bborehambborehambboreham approved these changes

@ArthurSensArthurSensAwaiting requested review from ArthurSensArthurSens is a code owner

@bwplotkabwplotkaAwaiting requested review from bwplotkabwplotka is a code owner

@kakkoyunkakkoyunAwaiting requested review from kakkoyunkakkoyun is a code owner

@vesarivesariAwaiting requested review from vesarivesari is a code owner

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

2 participants

@duricanikolic@bboreham

[8]ページ先頭

©2009-2025 Movatter.jp