Skip to content

Commit

Permalink
Transfers: add average transfer wait time metric rucio#5012
Browse files Browse the repository at this point in the history
We keep track of the wait time and transfer time for each completed
transfer sent to update_transfer_state. This metric aims to measure the
effectiveness of load distribution from different source node selection
strategies. Lower average wait time and transfer time generally
signifies a more effective strategy.
  • Loading branch information
davidcheng02 authored and bari12 committed Jan 12, 2024
1 parent e1d408b commit 52057a8
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
17 changes: 17 additions & 0 deletions lib/rucio/core/request.py
Original file line number Diff line number Diff line change
Expand Up @@ -1371,6 +1371,9 @@ def observe(
state: RequestState,
file_size: int,
*,
submitted_at: Optional[datetime.datetime] = None,
started_at: Optional[datetime.datetime] = None,
transferred_at: Optional[datetime.datetime] = None,
session: "Optional[Session]" = None
) -> None:
"""
Expand All @@ -1390,6 +1393,20 @@ def observe(
if state == RequestState.DONE:
record.files_done += 1
record.bytes_done += file_size

transfer_time_buckets = (
10, 30, 60, 5 * 60, 10 * 60, 20 * 60, 40 * 60, 60 * 60, 1.5 * 60 * 60, 3 * 60 * 60, 6 * 60 * 60,
12 * 60 * 60, 24 * 60 * 60, 3 * 24 * 60 * 60, 4 * 24 * 60 * 60, 5 * 24 * 60 * 60,
6 * 24 * 60 * 60, 7 * 24 * 60 * 60, 10 * 24 * 60 * 60, 14 * 24 * 60 * 60, 30 * 24 * 60 * 60,
float('inf')
)
if submitted_at is not None:
if started_at is not None:
wait_time = (started_at - submitted_at).total_seconds()
METRICS.timer(name='wait_time', buckets=transfer_time_buckets).observe(wait_time)
if transferred_at is not None:
transfer_time = (transferred_at - submitted_at).total_seconds()
METRICS.timer(name='transfer_time', buckets=transfer_time_buckets).observe(transfer_time)
else:
record.files_failed += 1
if save_samples:
Expand Down
3 changes: 3 additions & 0 deletions lib/rucio/core/transfer.py
Original file line number Diff line number Diff line change
Expand Up @@ -566,6 +566,9 @@ def update_transfer_state(
activity=request['activity'],
state=tt_status_report.state,
file_size=request['bytes'],
submitted_at=request.get('submitted_at', None),
started_at=request.get('started_at', None),
transferred_at=request.get('transferred_at', None),
session=session,
)
request_core.add_monitor_message(
Expand Down

0 comments on commit 52057a8

Please sign in to comment.