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 telemetry publish from JobServerQueue. #2919

Merged
merged 1 commit into from
Oct 10, 2023
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
19 changes: 10 additions & 9 deletions src/Runner.Worker/JobRunner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,12 @@ private async Task<TaskResult> CompleteJobAsync(IJobServer jobServer, IExecution

try
{
await ShutdownQueue(throwOnFailure: true);
var jobQueueTelemetry = await ShutdownQueue(throwOnFailure: true);
// include any job telemetry from the background upload process.
if (jobQueueTelemetry.Count > 0)
{
jobContext.Global.JobTelemetry.AddRange(jobQueueTelemetry);
}
}
catch (Exception ex)
{
Expand All @@ -412,13 +417,6 @@ private async Task<TaskResult> CompleteJobAsync(IJobServer jobServer, IExecution
result = TaskResultUtil.MergeTaskResults(result, TaskResult.Failed);
}

// include any job telemetry from the background upload process.
if (_jobServerQueue != null &&
_jobServerQueue.JobTelemetries.Count > 0)
{
jobContext.Global.JobTelemetry.AddRange(_jobServerQueue.JobTelemetries);
}

// Clean TEMP after finish process jobserverqueue, since there might be a pending fileupload still use the TEMP dir.
_tempDirectoryManager?.CleanupTempDirectory();

Expand Down Expand Up @@ -511,14 +509,15 @@ private void LoadFromTelemetryFile(List<JobTelemetry> jobTelemetry)
}
}

private async Task ShutdownQueue(bool throwOnFailure)
private async Task<IList<JobTelemetry>> ShutdownQueue(bool throwOnFailure)
{
if (_jobServerQueue != null)
{
try
{
Trace.Info("Shutting down the job server queue.");
await _jobServerQueue.ShutdownAsync();
return _jobServerQueue.JobTelemetries;
}
catch (Exception ex) when (!throwOnFailure)
{
Expand All @@ -530,6 +529,8 @@ private async Task ShutdownQueue(bool throwOnFailure)
_jobServerQueue = null; // Prevent multiple attempts.
}
}

return Array.Empty<JobTelemetry>();
}
}
}