-
Notifications
You must be signed in to change notification settings - Fork 910
Enhanced worker crash handling with integrated crash telemetry #5412
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
Open
raujaiswal
wants to merge
24
commits into
master
Choose a base branch
from
users/raujaiswal/worker-crash
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+223
−42
Open
Changes from 10 commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
40302fe
Implement enhanced worker crash handling in JobDispatcher
7a5bb52
agentknob changes for worker crash
c05c057
Merge branch 'master' into users/raujaiswal/worker-crash
raujaiswal f2f4138
enhanced worker crash reporting for listner and added telemetry
95aedec
Merge branch 'users/raujaiswal/worker-crash' of https://github.com/mi…
f0a3af4
Merge branch 'master' into users/raujaiswal/worker-crash
raujaiswal e18c663
removed feature flag telemetry
425e29b
Merge branch 'users/raujaiswal/worker-crash' of https://github.com/mi…
af10a40
cleanup the code
1d3c339
Merge branch 'master' into users/raujaiswal/worker-crash
raujaiswal 1944d29
refactored the chnages
eedd2e4
Merge branch 'users/raujaiswal/worker-crash' of https://github.com/mi…
ea914c3
refactored the changes
50fe7d7
refactored the changes
8e617cf
refactored the changes
f2699ce
refactored the changes
e67f638
refactored the changes
0448035
added retry mechanism
b56bfc8
Merge branch 'master' into users/raujaiswal/worker-crash
raujaiswal 3a093df
Merge branch 'master' into users/raujaiswal/worker-crash
raujaiswal 7342cee
added try-catch
be0f03a
Merge branch 'master' into users/raujaiswal/worker-crash
raujaiswal 3c5cd62
Merge branch 'users/raujaiswal/worker-crash' of https://github.com/mi…
641d8a0
added tracepoint in telemetry
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
src/Agent.Listener/Telemetry/WorkerCrashTelemetryPublisher.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| // Copyright (c) Microsoft Corporation. | ||
| // Licensed under the MIT License. | ||
|
|
||
| using System; | ||
| using System.Collections.Generic; | ||
| using System.Threading.Tasks; | ||
| using Microsoft.VisualStudio.Services.Agent.Util; | ||
| using Microsoft.TeamFoundation.DistributedTask.WebApi; | ||
| using Newtonsoft.Json; | ||
|
|
||
| namespace Microsoft.VisualStudio.Services.Agent.Listener.Telemetry | ||
| { | ||
| [ServiceLocator(Default = typeof(WorkerCrashTelemetryPublisher))] | ||
| public interface IWorkerCrashTelemetryPublisher : IAgentService | ||
| { | ||
| Task PublishWorkerCrashTelemetryAsync(IHostContext hostContext, Guid jobId, Guid? taskInstanceId, int exitCode); | ||
| } | ||
|
|
||
| public sealed class WorkerCrashTelemetryPublisher : AgentService, IWorkerCrashTelemetryPublisher | ||
| { | ||
| public async Task PublishWorkerCrashTelemetryAsync(IHostContext hostContext, Guid jobId, Guid? taskInstanceId, int exitCode) | ||
| { | ||
| try | ||
| { | ||
| var telemetryPublisher = hostContext.GetService<IAgenetListenerTelemetryPublisher>(); | ||
|
|
||
| var telemetryData = new Dictionary<string, object> | ||
| { | ||
| ["JobId"] = jobId.ToString(), | ||
| ["TaskInstanceId"] = taskInstanceId?.ToString() ?? "N/A", | ||
| ["ExitCode"] = exitCode.ToString() | ||
| }; | ||
|
|
||
| var command = new Command("telemetry", "publish") | ||
| { | ||
| Data = JsonConvert.SerializeObject(telemetryData) | ||
| }; | ||
| command.Properties.Add("area", "AzurePipelinesAgent"); | ||
| command.Properties.Add("feature", "WorkerCrash"); | ||
|
|
||
| await telemetryPublisher.PublishEvent(hostContext, command); | ||
| Trace.Info($"Published worker crash telemetry for job {jobId} with exit code {exitCode}"); | ||
| } | ||
| catch (Exception ex) | ||
| { | ||
| Trace.Warning($"Failed to publish worker crash telemetry: {ex.Message}"); | ||
| } | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shouldn't we have sendEvent to server method here as well, as here only we are logging if worker is terminated due to unhandled exception
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Initially I did not do that because the completion reporting where after the below code and I kept it as it is.
I asked from copilot regarding can we keep reporting after we are sending telemetry and it is saying that current order is correct and given the below reason, not sure whether it will be correct to keep before or not.
Reason: