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

[postgres] Collect StatIO per table & revamp test #1415

Merged
merged 9 commits into from Apr 7, 2015

Conversation

alq666
Copy link
Member

@alq666 alq666 commented Mar 7, 2015

Based on @adriandoolittle's work, but restricted to relations that are listed in the configuration to avoid blowing up the number of metrics.

@alq666
Copy link
Member Author

alq666 commented Mar 7, 2015

@remh I still have to update the test for it.

@LeoCavaille LeoCavaille added this to the 5.3.0 milestone Mar 13, 2015
@LeoCavaille LeoCavaille self-assigned this Mar 13, 2015
@LeoCavaille LeoCavaille force-pushed the alq666/pg-statio branch 2 times, most recently from 89d1b81 to f52c827 Compare March 20, 2015 00:49
@degemer degemer changed the title Collect StatIO per table [postgres] Collect StatIO per table & revamp test Mar 25, 2015
@@ -177,7 +177,7 @@ class PostgreSql(AgentCheck):
('schemaname', 'schema')
],
'metrics': {
'pg_stat_user_tables': ('postgresql.total_tables', GAUGE),
'pg_stat_user_tables': ('postgresql.table.count', GAUGE),
Copy link
Contributor

Choose a reason for hiding this comment

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

This might break existing user's screens, alerts, etc. Renaming a metric that's out there could be considered a breaking change.

Copy link
Member Author

Choose a reason for hiding this comment

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

Agreed. I checked and no such screens and monitors exist right now. We can recheck before we release.

Copy link
Contributor

Choose a reason for hiding this comment

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

👍

Copy link
Member

Choose a reason for hiding this comment

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

@alq666 @miketheman should have added a note.
That's normal b/c this is a new metric post 5.2 so it hasn't been released to the crowds yet. That's why I had no mercy renaming it.
See : bee8eec

Copy link
Contributor

Choose a reason for hiding this comment

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

Notes are good! :) Thanks for the explain @LeoCavaille .

@LeoCavaille LeoCavaille removed their assignment Mar 25, 2015
}
]

self.run_check(dict(instances=instances))
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's use run_check_twice instead ?

Copy link
Member

Choose a reason for hiding this comment

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

aha nice, of course. That didn't even existed when I submitted the PR ⏪

@remh
Copy link
Contributor

remh commented Apr 2, 2015

Looks great besides the tiny nitpicks. It was definitely not an easy refactoring.

adriandoolittle and others added 9 commits April 7, 2015 15:37
Some better metric names avoiding ugly abbreviations.
+ we make these new metrics relation-scoped meaning that we'll only
collect these metrics for the list of relation that has been input by
the user in the configuration file.
This avoids a possible unbounded (in number of relations) number of
metrics.
To be more consistent with the database count
`postgresql.db.count`
the table count has been renamed
from `postgresql.total_tables` to 'postgresql.table.count`
* Otherwise it will fail at formatting the query
* Removed unused `warning_func` def
* Renamed the scope for more consistency
Regression introduced by 70374b4.
Basically returning an empty dict as metrics generates a bad query
which then fails the whole transaction for this other database.
Instead we return None and skip the collection proeperly.
Fix regression introduced by #1395.
The idea is that because the pre-processing function
`_process_customer_metrics`
was modifying "in-place" instance attributes, and for instance
converting the string "GAUGE" to the method "AgentCheck.gauge" at the
first pass, the second time it would expect to find a string and fail
when it encounters a method.
Instead we cache the pre-preprocessed dict the first time, and hit this
dictionnary in the next runs if it is present.
* Use the `AgentCheckTest` class which makes the code much more readable
and enjoyable for edge cases.
* Factorize the SQL commands into SQL files that are input in psql
commands
* Minor logging facelift of the common test class
`test_postgresql` was the only file named postgresql instead of postgres
(ci/postgres.rb, checks.d/postgres.py), also breaking the implicit convention
that integration test of checks.d/my_test.py should be called
test_my_test.py
+ refactor a bit the code with the new handy methods that were added to
AgentCheckTest
+ added a bunch of FIXMEs in the code where me mutate caps-variables
which are supposed to be constant. Not doing it now b/c it involves a
further refactoring of the whole check logic
@LeoCavaille
Copy link
Member

CI passed, implemented your different comments @remh thanks. Merging.

LeoCavaille added a commit that referenced this pull request Apr 7, 2015
[postgres] Collect StatIO per table & revamp test
@LeoCavaille LeoCavaille merged commit c1570d8 into master Apr 7, 2015
@LeoCavaille LeoCavaille deleted the alq666/pg-statio branch April 7, 2015 23:15
@coveralls
Copy link

Coverage Status

Changes Unknown when pulling ab60a13 on alq666/pg-statio into * on master*.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants