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

Cleaning up name before appending unit on name #543

Merged
merged 1 commit into from
May 10, 2020

Conversation

knabben
Copy link
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.

@@ -527,6 +527,11 @@ def test_no_units_for_info_enum(self):
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
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
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
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
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
Contributor

Thanks!

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

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