Skip to content

Cleaning up name before appending unit on name#543

Merged
brian-brazil merged 1 commit intoprometheus:masterfrom
knabben:unit-naming
May 10, 2020
Merged

Cleaning up name before appending unit on name#543
brian-brazil merged 1 commit intoprometheus:masterfrom
knabben:unit-naming

Conversation

@knabben
Copy link
Copy Markdown
Contributor

@knabben knabben commented May 9, 2020

Unit append in the name were being removed when _total exists. This moves the clean up before appending the unit.

Refs #542

@brian-brazil Should this "repeated" unit raise an ValueError exception instead since this suffix is already append when dumping on WSGI.

self.assertRaises(ValueError, Info, 'foo', 'help', unit="x")
self.assertRaises(ValueError, Enum, 'foo', 'help', unit="x")

def test_name_cleanup_before_unit_append(self):
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can we also add a test that this is exposed correctly somewhere?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Added on tests/test_asgi.py and tests/test_wsgi.py

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Those are additional handlers, text_exposition would be the best place to put it.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

PTAL

@knabben knabben force-pushed the unit-naming branch 2 times, most recently from 695e1bd to 644d4cf Compare May 9, 2020 21:44
Signed-off-by: Amim Knabben <amim.knabben@gmail.com>
@brian-brazil brian-brazil merged commit 18d9371 into prometheus:master May 10, 2020
@brian-brazil
Copy link
Copy Markdown
Contributor

Thanks!

@knabben knabben deleted the unit-naming branch May 13, 2020 01:57
@Sebadst
Copy link
Copy Markdown

Sebadst commented May 28, 2020

Hello,

is this change intended?
I have just updated my prometheus-client from 0.7.1 to 0.8.0 and, as a result, all my metrics are broken.
Basically, if I had a metric like this:

JOBS = Counter(
    namespace=PROJECT,
    subsystem=ORCHESTRATOR,
    name="jobs",
    unit="total",
    documentation="Total number of jobs generated by the orchestrator.",
)

I was looking at it with the following:
sum(irate(project_orchestrator_jobs_total[5m])).
Now I need to do:
sum(irate(project_orchestrator_jobs_total_total[5m])).
It seems weird that such a change is from version 0.7.x to 0.8.x as it looks breaking.
Could you please let me know your thoughts on that?
Thank you.

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