Skip to content

Add openmetric parser[1]: add type,unit,help parser#710

Closed
jyz0309 wants to merge 3 commits intoprometheus:mainfrom
jyz0309:om-parse-1
Closed

Add openmetric parser[1]: add type,unit,help parser#710
jyz0309 wants to merge 3 commits intoprometheus:mainfrom
jyz0309:om-parse-1

Conversation

@jyz0309
Copy link
Copy Markdown

@jyz0309 jyz0309 commented Oct 28, 2024

Ref: prometheus/prometheus#8932
Part of #669
Add openmetrics protocol decoder, for promtool to support check openmetric protocol.
This pr just parse the HELP, TYPE, UNIT as the comment suggest

Signed-off-by: Yi <45495947@qq.com>
Copy link
Copy Markdown
Member

@ArthurSens ArthurSens left a comment

Choose a reason for hiding this comment

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

Good work here! I can see that this is basically a copy of the current text parser alongside its tests, but I think we can improve things a bit.

Comments are mostly around test readability

Comment thread expfmt/openmetrics_parse_test.go Outdated
Comment thread expfmt/openmetrics_parse_test.go Outdated
Comment thread expfmt/openmetrics_parse_test.go Outdated
Comment on lines +217 to +225
scenarios := []struct {
in string
err string
}{
// 0:
{
in: `# TYPE metric counter
# TYPE metric untyped
`,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Let's do the same here! Adding name to the scenarios and then using t.Run should provide more context about what each scenario is about :)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

has a little confusing about this, because now there's benchmark for the test, so the arg in test function is testing.TB, and arg required by t.Run is *testing.T(t.Run(name string, f func(t *testing.T))), the testing.TB has not implement the interface

Comment thread expfmt/openmetrics_parse.go
jyz0309 and others added 2 commits November 11, 2024 12:10
@jyz0309 jyz0309 closed this Apr 23, 2025
martincostello added a commit to martincostello/common that referenced this pull request May 3, 2026
Picking up from prometheus#710 to add an OpenMetrics parser to work towards support for OpenMetrics in promtool.

Contributes to prometheus/prometheus#8932.

Co-Authored-By: Yi <38248129+jyz0309@users.noreply.github.com>

Signed-off-by: martincostello <martin@martincostello.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.

2 participants