Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix bug in update job metrics #636

Merged
merged 1 commit into from
Nov 5, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions src/ClusterManager/job_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,19 +121,23 @@ def update_job_state_latency(job_id, state, event_time=None):
event_time = datetime.datetime.utcnow()

if state == "created":
job_time_recorder[job_id].create_time = event_time
if job_time_recorder[job_id].create_time is None:
job_time_recorder[job_id].create_time = event_time
elif state == "approved":
job_time_recorder[job_id].approve_time = event_time
if job_time_recorder[job_id].approve_time is None:
job_time_recorder[job_id].approve_time = event_time
if job_time_recorder[job_id].create_time is not None:
elapsed = (event_time - job_time_recorder[job_id].create_time).seconds
job_state_change_histogram.labels(state).observe(elapsed)
elif state == "scheduling":
job_time_recorder[job_id].submit_time = event_time
if job_time_recorder[job_id].submit_time is None:
job_time_recorder[job_id].submit_time = event_time
if job_time_recorder[job_id].approve_time is not None:
elapsed = (event_time - job_time_recorder[job_id].approve_time).seconds
job_state_change_histogram.labels(state).observe(elapsed)
elif state == "running":
job_time_recorder[job_id].running_time = event_time
if job_time_recorder[job_id].running_time is None:
job_time_recorder[job_id].running_time = event_time
if job_time_recorder[job_id].submit_time is not None:
elapsed = (event_time - job_time_recorder[job_id].submit_time).seconds
job_state_change_histogram.labels(state).observe(elapsed)
Expand Down