Skip to content

Commit

Permalink
Emit metrics for tasks run in parallel
Browse files Browse the repository at this point in the history
  • Loading branch information
Swatinem committed Oct 9, 2024
1 parent cb3ce37 commit f0b32f3
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
13 changes: 13 additions & 0 deletions helpers/parallel.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,17 @@

from enum import Enum

import sentry_sdk
from shared.metrics import Counter

from rollouts import PARALLEL_UPLOAD_PROCESSING_BY_REPO

PARALLEL_TASK_RUNS = Counter(
"worker_parallel_task_runs",
"Number of tasks run using different parallel processing configurations.",
["task", "parallel_mode"],
)

"""
This encapsulates Parallel Upload Processing logic
Expand Down Expand Up @@ -89,3 +98,7 @@ def from_task_args(
if is_final:
return ParallelProcessing.EXPERIMENT_SERIAL
return ParallelProcessing.SERIAL

def emit_metrics(self, task: str):
sentry_sdk.set_tag("parallel_mode", self.value)
PARALLEL_TASK_RUNS.labels(task=task, parallel_mode=self.value).inc()
1 change: 1 addition & 0 deletions tasks/upload_finisher.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ def run_impl(
repository = commit.repository

parallel_processing = ParallelProcessing.from_task_args(**kwargs)
parallel_processing.emit_metrics("upload_finisher")

if parallel_processing.is_parallel:
# need to transform processing_results produced by chord to get it into the
Expand Down
1 change: 1 addition & 0 deletions tasks/upload_processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ def process_upload(
report_service = ReportService(UserYaml(commit_yaml))

in_parallel = parallel_processing.is_parallel
parallel_processing.emit_metrics("upload_processor")

if in_parallel:
log.info(
Expand Down

0 comments on commit f0b32f3

Please sign in to comment.