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

3786 Add OpenMetrics (Prometheus) statistics endpoint #1125

Merged
merged 35 commits into from Sep 28, 2021

Conversation

hacklschorsch
Copy link
Contributor

@hacklschorsch hacklschorsch commented Sep 10, 2021

@exarkun exarkun requested a review from a team September 10, 2021 13:50
Copy link
Member

@exarkun exarkun left a comment

Choose a reason for hiding this comment

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

Thanks! Some comments left inline.

src/allmydata/test/test_openmetrics.py Outdated Show resolved Hide resolved
src/allmydata/web/status.py Outdated Show resolved Hide resolved
tox.ini Outdated Show resolved Hide resolved
src/allmydata/web/status.py Show resolved Hide resolved
src/allmydata/test/test_openmetrics.py Outdated Show resolved Hide resolved
src/allmydata/test/test_openmetrics.py Outdated Show resolved Hide resolved
src/allmydata/test/test_openmetrics.py Outdated Show resolved Hide resolved
@hacklschorsch
Copy link
Contributor Author

Uff

CI Problemo:

Expected to find no classic classes.

[...]

class HackItResource(Resource):

Is this a classic class?

@exarkun
Copy link
Member

exarkun commented Sep 17, 2021

Uff

CI Problemo:

Expected to find no classic classes.

[...]

class HackItResource(Resource):

Is this a classic class?

I guess it is because twisted.web.resource.Resource is. Mix in object (HackItResource(Resource, object)) et voila...

@hacklschorsch
Copy link
Contributor Author

hacklschorsch commented Sep 17, 2021

class HackItResource(Resource):

Is this a classic class?

I guess it is because twisted.web.resource.Resource is. Mix in object (HackItResource(Resource, object)) et voila...

Ah thanks! I had hoped it was this easy :)

@hacklschorsch
Copy link
Contributor Author

d'uh! I wanted to close the conversation thread, not the PR of course :(

@hacklschorsch hacklschorsch reopened this Sep 17, 2021
@coveralls
Copy link
Collaborator

Coverage Status

Coverage increased (+0.02%) to 95.499% when pulling 7183d53 on hacklschorsch:3786.openmetrics into bec813f on tahoe-lafs:master.

@hacklschorsch
Copy link
Contributor Author

@exarkun please update the ticket status (the pending re-review) if you are good with this as it stands - I don't have the authority to do it.

@exarkun exarkun requested a review from meejah September 27, 2021 13:34
Copy link
Member

@exarkun exarkun left a comment

Choose a reason for hiding this comment

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

I like this now (also I am an author on some of it).

Copy link
Contributor

@meejah meejah left a comment

Choose a reason for hiding this comment

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

Overall looks good.

I find the test a little hard to follow .. since it only asserts a single thing in the end, maybe the "fake stats" could also just include that one thing? On the plus side, it does say how to re-create the huge dict. :)

Super minor nit, but could render_OPENMETRICS just be render_openmetrics or is there a need/reason for the all-uppercase?

@hacklschorsch
Copy link
Contributor Author

Hi @meejah! Thank you for your review and feedback!

Super minor nit, but could render_OPENMETRICS just be render_openmetrics or is there a need/reason for the all-uppercase?

The other methods like that one are named similarly and this code makes it look like that specific part of the name should be upper cased.

@hacklschorsch
Copy link
Contributor Author

since it only asserts a single thing in the end, maybe the "fake stats" could also just include that one thing?

The real check is that list(parser.text_string_to_metric_families(body)) doesn't raise an Exception, i.e. the OpenMetrics parser accepts our output as valid OpenMetrics.

The check for families[-1].name Equals("tahoe_stats_storage_server_total_bucket_count") is a mere safeguard to make sure the parser did make some output from its input - in other words, check against the output being a valid but empty string. (which wouldn't really be valid since it still needs the #EOF marker, but alas)

@exarkun
Copy link
Member

exarkun commented Sep 28, 2021

FWIW I think the complexity of the test follows from the complexity of Tahoe's implementation of metrics collection. There is very little structure in the metrics Tahoe is gathering - mostly they are free-form strings associated with with a (probably) number. The test has no way to automatically collect all real metrics from the codebase (the only way to get them is to run Tahoe and make sure you hit every metrics-generating codepath).

A great future cleanup could be introducing some more structure in the metrics gathering code. This could have a specific goal (among others) of allowing tests to easily verify all metrics that are reported can be exported into the necessary format.

@meejah gave an approval along with this comment which I would interpret to mean "it would be nice to improve this area but it is not required before merging". I think we should go ahead and merge this with the complex test and as there is motivation to further Tahoe metrics improvements, we can incrementally improve the factoring and testing.

@meejah
Copy link
Contributor

meejah commented Sep 28, 2021

Yes, my comments (along with the "approve") was meant to mean, "here are things I was slightly confused about, update or not then merge". Hopefully I'm not screwing anything up by just merging this now since it seems ready-to-go...

@meejah meejah merged commit 0a072a9 into tahoe-lafs:master Sep 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants