Skip to content

Commit

Permalink
metrics: add full duration metric
Browse files Browse the repository at this point in the history
  • Loading branch information
Avram Tudor committed Oct 16, 2024
1 parent 62ccf07 commit a2abf14
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
8 changes: 8 additions & 0 deletions skynet/modules/monitoring.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,14 @@
buckets=[5**n for n in range(4)],
)

SUMMARY_FULL_DURATION_METRIC = Histogram(
'summary_full_duration_seconds',
documentation='Measures the duration of the summary / action items since they were submitted until they are done in seconds',
namespace=PROMETHEUS_NAMESPACE,
subsystem=PROMETHEUS_SUMMARIES_SUBSYSTEM,
buckets=[5**n for n in range(4)],
)

SUMMARY_TIME_IN_QUEUE_METRIC = Histogram(
'summary_queue_time_seconds',
documentation='Measures the time spent in the queue in seconds',
Expand Down
3 changes: 3 additions & 0 deletions skynet/modules/ttt/summaries/jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
OPENAI_API_RESTART_COUNTER,
SUMMARY_DURATION_METRIC,
SUMMARY_ERROR_COUNTER,
SUMMARY_FULL_DURATION_METRIC,
SUMMARY_INPUT_LENGTH_METRIC,
SUMMARY_QUEUE_SIZE_METRIC,
SUMMARY_TIME_IN_QUEUE_METRIC,
Expand Down Expand Up @@ -163,9 +164,11 @@ async def update_done_job(job: Job, result: str, processor: Processors, has_fail

if updated_job.status != JobStatus.SKIPPED:
SUMMARY_DURATION_METRIC.observe(updated_job.computed_duration)
SUMMARY_FULL_DURATION_METRIC.observe(updated_job.computed_full_duration)
SUMMARY_INPUT_LENGTH_METRIC.observe(len(updated_job.payload.text))

log.info(f"Job {updated_job.id} duration: {updated_job.computed_duration} seconds")
log.info(f"Job {updated_job.id} full duration: {updated_job.computed_full_duration} seconds")


async def _run_job(job: Job) -> None:
Expand Down
8 changes: 8 additions & 0 deletions skynet/modules/ttt/summaries/v1/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,14 @@ def computed_duration(self) -> float:

return 0.0

@computed_field
@property
def computed_full_duration(self) -> float:
if self.end:
return round(self.end - self.created, 3)

return 0.0


class JobId(BaseModel):
id: str

0 comments on commit a2abf14

Please sign in to comment.