Skip to content

Conversation

@Alhanaqtah
Copy link

@Alhanaqtah Alhanaqtah commented Aug 5, 2025

This PR enhances extfmt behavior when incorrect metrics privided by user — metrics without name. Now TextParser throws error "invalid metrics name" instead of panicing (#3374)

@roidelapluie

@Alhanaqtah
Copy link
Author

@roidelapluie could you review PR, please?)

@ywwg
Copy link
Member

ywwg commented Aug 11, 2025

This change looks good to me. Can you add a test to exercise this case so we can catch regressions? And can you sign your commit to pass the DCO check? Thanks!

@ywwg
Copy link
Member

ywwg commented Aug 14, 2025

Hi, I would like to do a release of prom/common and this would be a nice fix to include, do you think you can add the test and fix DCO soon?

Signed-off-by: Banana Duck <a.usama@yandex.ru>
@Alhanaqtah Alhanaqtah force-pushed the initiate-error-when-metric-without-name branch from cfaa159 to ec048aa Compare August 15, 2025 08:57
@Alhanaqtah
Copy link
Author

Alhanaqtah commented Aug 15, 2025

Hi, I would like to do a release of prom/common and this would be a nice fix to include, do you think you can add the test and fix DCO soon?

I've done everything. You can merge it)

P.S.
I also extended (*TextParser).reset() with p.currentMetric assignment to nil so that testcases wouldn't affect each other

@Alhanaqtah
Copy link
Author

@ywwg Could you merge PR, please?)

@Alhanaqtah
Copy link
Author

Hello! I would be glad if someone of you approved PR)
@roidelapluie @gotjosh @ArthurSens

Copy link
Contributor

@jan--f jan--f left a comment

Choose a reason for hiding this comment

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

Apologies for the delay here.
I don't think this is quite correct. This test case already exists at https://github.com/prometheus/common/pull/811/files#diff-f94ed3d7ef59cf8de9ae97ae9e654cadda29ab3257af8a5112d93e2290e6bad2R804, though without HELP and TYPE annotation. In these lines though you do pass a metric name.
On current main this new test case no longer causes a panic, so I assume this was fixed elsewhere and the parser can take the name from the HELP/TYPE lines. Without those lines the parser returns the expected parsing error.

@jan--f
Copy link
Contributor

jan--f commented Dec 22, 2025

It is entirely possible though that this new test case covers a corner case in the parser we need to fix. I reached out for more eyes on this.

Copy link
Contributor

@jan--f jan--f left a comment

Choose a reason for hiding this comment

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

So yes this is a corner case previously not tested for, thanks for fixing this.
Can you please rebase on current main?

Comment on lines +940 to +943
# HELP backupmonitor_size The size of the given backup.
# TYPE backupmonitor_size counter
{host="local", dir="alpha"} 1834194837
{host="remote", dir="beta"} 133638016
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
# HELP backupmonitor_size The size of the given backup.
# TYPE backupmonitor_size counter
{host="local", dir="alpha"} 1834194837
{host="remote", dir="beta"} 133638016
# HELP metric a metric.
# TYPE metric counter
{label="bla"} 3.14

Just to be consistent with previous test cases.

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.

3 participants