Merge lp:~hloeung/ubuntu-repository-cache/metadata-sync-metrics-only-once into lp:ubuntu-repository-cache

Proposed by Haw Loeung
Status: Merged
Approved by: Haw Loeung
Approved revision: 369
Merged at revision: 369
Proposed branch: lp:~hloeung/ubuntu-repository-cache/metadata-sync-metrics-only-once
Merge into: lp:ubuntu-repository-cache
Diff against target: 43 lines (+6/-5)
1 file modified
lib/ubuntu_repository_cache/metadata_sync.py (+6/-5)
To merge this branch: bzr merge lp:~hloeung/ubuntu-repository-cache/metadata-sync-metrics-only-once
Reviewer Review Type Date Requested Status
Loïc Gomez +1 Approve
Canonical IS Reviewers Pending
Review via email: mp+428333@code.launchpad.net

Commit message

Add metrics for when success (zero failures); also only once at the end rather than metric for each failure

To post a comment you must log in.
Revision history for this message
🤖 Canonical IS Merge Bot (canonical-is-mergebot) wrote :

This merge proposal is being monitored by mergebot. Change the status to Approved to merge.

Revision history for this message
Loïc Gomez (kotodama) :
review: Approve (+1)
Revision history for this message
🤖 Canonical IS Merge Bot (canonical-is-mergebot) wrote :

Change successfully merged at revision 369

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/ubuntu_repository_cache/metadata_sync.py'
2--- lib/ubuntu_repository_cache/metadata_sync.py 2022-08-09 09:18:55 +0000
3+++ lib/ubuntu_repository_cache/metadata_sync.py 2022-08-15 23:27:16 +0000
4@@ -293,6 +293,10 @@
5
6 log("Executing hook: {}".format(cmd))
7
8+ metric_name = 'ubuntu_repository_cache_metadata_sync_failures'
9+ label = 'meta_ver={}'.format(meta_ver)
10+ failures = 0
11+
12 errors = []
13 # Work around Juju instability issues causing juju-run to abort
14 # (LP:1977798).
15@@ -303,6 +307,7 @@
16 msg = "{}".format(output)
17 log(msg)
18 except subprocess.CalledProcessError as e:
19+ failures = attempt
20 # Save the exact exception and reuse when we need to
21 # reraise it after exhausting all available attempts.
22 exp = e
23@@ -313,9 +318,6 @@
24 log(e.output.decode())
25 errors.append(msg)
26 errors.append(e.output.decode())
27- metric_name = 'ubuntu_repository_cache_metadata_sync_failures'
28- label = 'meta_ver={}'.format(meta_ver)
29- send_to_influx(render_influx(metric_name, label, attempt))
30 time.sleep(sleep)
31 else:
32 break
33@@ -326,11 +328,10 @@
34 log(msg)
35 print(msg)
36 print('\n'.join(errors))
37- metric_name = 'ubuntu_repository_cache_metadata_sync_failures'
38- label = 'meta_ver={}'.format(meta_ver)
39 send_to_influx(render_influx(metric_name, label, max_retries))
40 raise exp
41
42+ send_to_influx(render_influx(metric_name, label, failures))
43 return meta_ver
44
45

Subscribers

People subscribed via source and target branches