Merge ~ilasc/turnip:gauge-name-to-operation into turnip:master

Proposed by Ioana Lasc
Status: Merged
Approved by: Ioana Lasc
Approved revision: 2a484246d5229e1eb608defe6863a55ac4238ffa
Merge reported by: Otto Co-Pilot
Merged at revision: not available
Proposed branch: ~ilasc/turnip:gauge-name-to-operation
Merge into: turnip:master
Diff against target: 53 lines (+11/-11)
2 files modified
turnip/pack/git.py (+9/-9)
turnip/pack/tests/test_functional.py (+2/-2)
Reviewer Review Type Date Requested Status
Colin Watson (community) Approve
Review via email: mp+392382@code.launchpad.net

Commit message

Set generic gauge name to git

Description of the change

1st approach in this MP
This will give us:
   turnip_qastaging_git_receive_pack
   turnip_qastaging_git_upload_pack
   turnip_prod_git_receive_pack
   turnip_prod_git_upload_pack

this gives the option to filter / group by repository, metric, host/unit.

2nd approach:

We could alternatively implement:
   gauge_name = ("git_operation,operation={},repo={},metric=system_time"..
which would give us one generic expression:
   turnip_qastaging_git
with the ability to filter by operation, repo, metric, host/unit.

To post a comment you must log in.
Revision history for this message
Colin Watson (cjwatson) wrote :

Thanks.

We should use something like your second approach, not the first. Relying on what the first label in the list happens to be to construct the name is too magical, and in any case we want to be able to filter on all these things.

review: Needs Fixing
Revision history for this message
Ioana Lasc (ilasc) wrote :

Fully agreed on the second approach being the best choice here.
Thanks Colin!

Test suite passes but I also performed local full end to end tests and got indeed one single top expression in Chronograf for multiple repositories, operations and metrics (https://chat.canonical.com/canonical/pl/kbadfr5qmfncprn4j4xeerec3e) lp_turnip_git that is filterable by all the attributes. In our environments this will become prefixed with what we defined in our yaml config files to form the correct top expressions/tags:
   turnip_qastaging_git
   turnip_production_git

MP now ready for another look.

Revision history for this message
Colin Watson (cjwatson) :
review: Approve
Revision history for this message
Colin Watson (cjwatson) wrote :

Could you update this MP's commit message too?

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/turnip/pack/git.py b/turnip/pack/git.py
2index f35732a..0d8292f 100644
3--- a/turnip/pack/git.py
4+++ b/turnip/pack/git.py
5@@ -327,24 +327,24 @@ class GitProcessProtocol(protocol.ProcessProtocol, object):
6 # can't be used in statsd
7 repository = re.sub('[^0-9a-zA-Z]+', '-',
8 self.peer.raw_pathname)
9- gauge_name = ("repo={},operation={},metric=max_rss"
10+ gauge_name = ("git,operation={},repo={},metric=max_rss"
11 .format(
12- repository,
13- self.peer.command))
14+ self.peer.command,
15+ repository))
16
17 self.statsd_client.gauge(gauge_name, resource_usage['max_rss'])
18
19- gauge_name = ("repo={},operation={},metric=system_time"
20+ gauge_name = ("git,operation={},repo={},metric=system_time"
21 .format(
22- repository,
23- self.peer.command))
24+ self.peer.command,
25+ repository))
26 self.statsd_client.gauge(gauge_name,
27 resource_usage['system_time'])
28
29- gauge_name = ("repo={},operation={},metric=user_time"
30+ gauge_name = ("git,operation={},repo={},metric=user_time"
31 .format(
32- repository,
33- self.peer.command))
34+ self.peer.command,
35+ repository))
36 self.statsd_client.gauge(gauge_name,
37 resource_usage['user_time'])
38
39diff --git a/turnip/pack/tests/test_functional.py b/turnip/pack/tests/test_functional.py
40index 1e9b2d1..fb168e7 100644
41--- a/turnip/pack/tests/test_functional.py
42+++ b/turnip/pack/tests/test_functional.py
43@@ -189,8 +189,8 @@ class FunctionalTestMixin(WithScenarios):
44 metrics = ['max_rss', 'system_time', 'user_time']
45 repository = re.sub('[^0-9a-zA-Z]+', '-', repo)
46 self.assertThat(self.statsd_client.vals, MatchesDict({
47- u'repo={},operation={},metric={}'.format(
48- repository, command, metric): Not(Is(None))
49+ u'git,operation={},repo={},metric={}'.format(
50+ command, repository, metric): Not(Is(None))
51 for metric in metrics}))
52
53 @defer.inlineCallbacks

Subscribers

People subscribed via source and target branches