Skip to content

Commit f6b43d2

Browse files
Daniel Xufacebook-github-bot
authored andcommitted
Add some counters for email stats
Summary: After this lands and ships, we'll want to add an alarm if email notification success rates drop. It's signal that the RC release is buggy. Reviewed By: chantra Differential Revision: D66548174 fbshipit-source-id: 1e088502a76d7d72ddd856be818b4182975a8f8a
1 parent cfb1bda commit f6b43d2

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

kernel_patches_daemon/branch_worker.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,10 @@
6060
git_fetch_counter: metrics.Counter = meter.create_counter(name="fetch")
6161
git_fetch_duration: metrics.Histogram = meter.create_histogram(name="fetch.duration_ms")
6262
pr_summary_report: metrics.Counter = meter.create_counter(name="pr_summary_reports")
63+
email_success_counter: metrics.Counter = meter.create_counter(name="email.success")
64+
email_failure_counter: metrics.Counter = meter.create_counter(name="email.failure")
65+
email_conflict_counter: metrics.Counter = meter.create_counter(name="email.conflict")
66+
email_send_fail_counter: metrics.Counter = meter.create_counter(name="email.send_fail")
6367
pr_created: metrics.Counter = meter.create_counter(name="pull_requests.created")
6468
pr_updated: metrics.Counter = meter.create_counter(name="pull_requests.updated")
6569
pr_closed: metrics.Counter = meter.create_counter(name="pull_requests.closed")
@@ -227,6 +231,15 @@ def furnish_ci_email_body(ctx: EmailBodyContext) -> str:
227231
)
228232

229233

234+
def bump_email_status_counters(status: Status):
235+
if status == Status.SUCCESS:
236+
email_success_counter.add(1)
237+
elif status == Status.FAILURE:
238+
email_failure_counter.add(1)
239+
else:
240+
email_conflict_counter.add(1)
241+
242+
230243
def generate_msg_id(host: str) -> str:
231244
"""Generate an email message ID based on the provided host."""
232245
checksum = hashlib.sha256(str(time.time()).encode("utf-8")).hexdigest()
@@ -331,6 +344,7 @@ async def send_email(
331344
rc = await proc.wait()
332345
if rc != 0:
333346
logger.error(f"failed to send email: {stdout.decode()} {stderr.decode()}")
347+
email_send_fail_counter.add(1)
334348

335349

336350
def _is_pr_flagged(pr: PullRequest) -> bool:
@@ -1201,6 +1215,7 @@ async def evaluate_ci_result(
12011215
ctx = build_email_body_context(self.repo, pr, status, series, inline_logs)
12021216
body = furnish_ci_email_body(ctx)
12031217
await send_email(email, series, subject, body)
1218+
bump_email_status_counters(status)
12041219

12051220
def expire_branches(self) -> None:
12061221
for branch in self.branches:

0 commit comments

Comments
 (0)