Skip to content

Commit 02c4ee9

Browse files
committed
report long runtimes (120s) of Copr Start/End to sentry
this only accounts for the longer code paths Maja observed in our Grafana dashboards these can take up to 6 minutes which is truly weird when we only do a few network requests and some DB operations. On average, they shouldn't take more than 10 seconds. Thank you @majamassarini for consultation. Signed-off-by: Tomas Tomecek <[email protected]> Assisted-by: Cursor(Claude)
1 parent f7a6984 commit 02c4ee9

File tree

1 file changed

+15
-0
lines changed
  • packit_service/worker/handlers

1 file changed

+15
-0
lines changed

packit_service/worker/handlers/copr.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,15 @@ def get_checkers() -> tuple[type[Checker], ...]:
139139
return (AreOwnerAndProjectMatchingJob, IsPackageMatchingJobView)
140140

141141

142+
def report_long_runtime(method: str, length: int, start_time: datetime):
143+
end_time = datetime.now(timezone.utc)
144+
run_time = elapsed_seconds(start_time, end_time)
145+
if run_time > length:
146+
m = f"{method} run time takes {run_time} seconds."
147+
logger.info(m)
148+
sentry_integration.send_to_sentry(RuntimeWarning(m))
149+
150+
142151
@configured_as(job_type=JobType.copr_build)
143152
@reacts_to(event=copr.Start)
144153
class CoprBuildStartHandler(AbstractCoprBuildReportHandler):
@@ -165,6 +174,7 @@ def set_logs_url(self):
165174
self.build.set_build_logs_url(copr_build_logs)
166175

167176
def run(self):
177+
run_start_time = datetime.now(timezone.utc)
168178
if not self.build:
169179
model = "SRPMBuildDB" if self.copr_event.chroot == COPR_SRPM_CHROOT else "CoprBuildDB"
170180
msg = f"Copr build {self.copr_event.build_id} not in {model}."
@@ -201,6 +211,7 @@ def run(self):
201211
)
202212
msg = "SRPM build in Copr has started..."
203213
self.set_start_time()
214+
report_long_runtime("SRPM build start", 120, run_start_time)
204215
return TaskResults(success=True, details={"msg": msg})
205216

206217
self.pushgateway.copr_builds_started.inc()
@@ -220,6 +231,7 @@ def run(self):
220231
)
221232
msg = f"Build on {self.copr_event.chroot} in copr has started..."
222233
self.set_start_time()
234+
report_long_runtime("Copr build start", 120, run_start_time)
223235
return TaskResults(success=True, details={"msg": msg})
224236

225237

@@ -285,6 +297,7 @@ def set_built_packages(self):
285297
self.build.set_built_packages(built_packages)
286298

287299
def run(self):
300+
run_start_time = datetime.now(timezone.utc)
288301
if not self.build:
289302
# TODO: how could this happen?
290303
model = "SRPMBuildDB" if self.copr_event.chroot == COPR_SRPM_CHROOT else "CoprBuildDB"
@@ -338,6 +351,7 @@ def run(self):
338351
logs_url=self.build.build_logs_url,
339352
)
340353
self.build.set_status(BuildStatus.failure)
354+
report_long_runtime("Copr build failed end", 120, run_start_time)
341355
return TaskResults(success=False, details={"msg": failed_msg})
342356

343357
self.report_successful_build()
@@ -365,6 +379,7 @@ def run(self):
365379
f"as this is only experimental functionality for now.",
366380
)
367381

382+
report_long_runtime("Copr build end", 120, run_start_time)
368383
return TaskResults(success=True, details={})
369384

370385
def report_successful_build(self):

0 commit comments

Comments
 (0)