3using System.Threading.Tasks;
5using Microsoft.Diagnostics.NETCore.Client;
6using Microsoft.Extensions.Logging;
19 readonly ILogger<DotnetDumpService>
logger;
26 ILogger<DotnetDumpService>
logger)
28 this.logger =
logger ??
throw new ArgumentNullException(nameof(
logger));
32 public async ValueTask
Dump(
IProcess process,
string outputFile,
bool minidump, CancellationToken cancellationToken)
35 using var cts = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken);
37 const int TimeoutMinutes = 5;
38 cts.CancelAfter(TimeSpan.FromMinutes(TimeoutMinutes));
39 cts.Token.Register(() =>
41 if (!cancellationToken.IsCancellationRequested)
42 logger.LogError(
"dotnet-dump timed out after {minutes} minutes!", TimeoutMinutes);
46 logger.LogDebug(
"dotnet-dump requested for PID {pid}...", pid);
47 var client =
new DiagnosticsClient(pid);
50 await client.WriteDumpAsync(
Operation exceptions thrown from the context of a Models.Job.
async ValueTask Dump(IProcess process, string outputFile, bool minidump, CancellationToken cancellationToken)
Attempt to dump a given process .A ValueTask representing the running operation.
DotnetDumpService(ILogger< DotnetDumpService > logger)
Initializes a new instance of the DotnetDumpService class.
readonly ILogger< DotnetDumpService > logger
The ILogger for the DotnetDumpService.
Service for managing the dotnet-dump installation.
Abstraction over a global::System.Diagnostics.Process.
ErrorCode
Types of Response.ErrorMessageResponses that the API may return.