Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: expfmt/text: optionally include empty MetricFamilies #706

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

dgrisonnet
Copy link

When parsing text format it is sometimes useful to keep all the MetricFamilies around, even the ones that don't have any timeseries. This is the case for the testutil library in client_golang where we need to distinguish registered metrics from erronous inputs.

When parsing text format it is sometimes useful to keep all the
MetricFamilies around, even the ones that don't have any timeseries.
This is the case for the testutil library in client_golang where we need
to distinguish registered metrics from erronous inputs.

Signed-off-by: Damien Grisonnet <[email protected]>
Comment on lines -79 to -82
// Fail-fast checks.
if len(in.Metric) == 0 {
return 0, fmt.Errorf("MetricFamily has no metrics: %s", in)
}
Copy link
Author

@dgrisonnet dgrisonnet Oct 10, 2024

Choose a reason for hiding this comment

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

Tests are failing because of this. I guess I will need to introduce a new function just to keep MetricFamilies without timeseries around

Copy link
Member

Choose a reason for hiding this comment

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

...or variadic option 🤔 or "both", so

NewMFConverter(opts).MetricFamilyToText

then keeping MetricFamilyToText as NewMFConverter(nil).MetricFamilyToText(....)

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