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

Unexport Format strings #576

Merged
merged 1 commit into from Feb 20, 2024
Merged

Unexport Format strings #576

merged 1 commit into from Feb 20, 2024

Conversation

ywwg
Copy link
Contributor

@ywwg ywwg commented Feb 14, 2024

With the addition of the escaping term, format strings now have many permutations and doing direct string comparisons of formats is not reliable. Instead, users should call FormatType and compare the result against the possible enum values.

I am making this change after breaking a test in prometheus that relied on string matching of formats.

With the addition of the escaping term, format strings now have many permutations and doing direct string comparisons of formats is not reliable.
Instead, users should call FormatType and compare the result against the possible enum values.

Signed-off-by: Owen Williams <owen.williams@grafana.com>
Copy link
Member

@beorn7 beorn7 left a comment

Choose a reason for hiding this comment

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

Let's try it. If this breaks use cases we haven't anticipated, we can still modify or revert.

@beorn7 beorn7 merged commit bd41eb6 into prometheus:main Feb 20, 2024
6 checks passed
@ywwg
Copy link
Contributor Author

ywwg commented Feb 21, 2024

can you do a new library release with this change?

@beorn7
Copy link
Member

beorn7 commented Feb 22, 2024

Ack, will do it ASAP.

@beorn7
Copy link
Member

beorn7 commented Feb 22, 2024

@nicolaasuni-vonage
Copy link

This change breaks an existing workflow:
#577

@ywwg
Copy link
Contributor Author

ywwg commented Feb 23, 2024

@nyetwurk
Copy link

This breaks a lot of things for us... is there an example porting guide?

@ArthurSens
Copy link
Member

This breaks a lot of things for us... is there an example porting guide?

We're currently in the process of cutting a new client_golang release. Client_golang 1.19 should work with common 0.48

return fmtProtoText
case TypeTextPlain:
return fmtText
case TypeOpenMetrics:
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a way to generate a fmtOpenMetrics_0_0_1?

Copy link

@slonka slonka Mar 1, 2024

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, the new functions in expfmt.go can create these for you: https://github.com/prometheus/common/blob/main/expfmt/expfmt.go#L77

The story is, because the exposition formats are getting more complex, simple string comparison is no longer safe. There are too many equivalent permutations, and therefore things were moved to functions. If the available NewFormat function is not sufficient for your needs, please @ me or file an issue and I can fix it up

Copy link
Contributor

@mrueg mrueg Mar 1, 2024

Choose a reason for hiding this comment

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

Right now TypeOpenMetrics only generates fmtOpenMetrics_1_0_0

If for some reason you need fmtOpenMetrics_0_0_1 there's no way to generate it.

We probably need a TypeOpenMetrics_0_0_1 or an optional version argument for the NewFormat func

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I see -- yup I can prep a PR

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it looks like I should also increase the test coverage -- I'll get to this next week. sorry for the breakage in the meantime!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@mrueg please let me know if this approach works for you

#596

roobre added a commit to grafana/synthetic-monitoring-agent that referenced this pull request Mar 5, 2024
roobre added a commit to grafana/synthetic-monitoring-agent that referenced this pull request Mar 5, 2024
metalmatze added a commit to polarsignals/vault that referenced this pull request Mar 6, 2024
The previous exposed constants are no longer exposed and we can use expfmt.Format instead.
prometheus/common#576
peteski22 added a commit to hashicorp/vault that referenced this pull request Mar 14, 2024
* helper/metricsutil: Update usage of expfmt

The previous exposed constants are no longer exposed and we can use expfmt.Format instead.
prometheus/common#576

* reodered imports

---------

Co-authored-by: Matthias Loibl <mail@matthiasloibl.com>
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.

None yet

7 participants