public Task <ActionResult> GetDump(int?pid, [FromQuery] DumpType type = DumpType.WithHeap) { return(InvokeService(async() => { int pidValue = _diagnosticServices.ResolveProcess(pid); Stream result = await _diagnosticServices.GetDump(pidValue, type); string dumpFileName = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? FormattableString.Invariant($"dump_{GetFileNameTimeStampUtcNow()}.dmp") : FormattableString.Invariant($"core_{GetFileNameTimeStampUtcNow()}"); //Compression is done automatically by the response //Chunking is done because the result has no content-length return File(result, "application/octet-stream", dumpFileName); })); }
public Task <ActionResult> GetDump(int?pid, [FromQuery] DumpType type = DumpType.WithHeap) { return(InvokeService(async() => { int pidValue = _diagnosticServices.ResolveProcess(pid); Stream result = await _diagnosticServices.GetDump(pidValue, type); FormattableString dumpFileName; if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { // This assumes that Windows does not have shared process spaces Process process = Process.GetProcessById(pidValue); dumpFileName = $"{process.ProcessName}.{pidValue}.dmp"; } else { dumpFileName = $"core_{pidValue}"; } //Compression is done automatically by the response //Chunking is done because the result has no content-length return File(result, "application/octet-stream", Invariant(dumpFileName)); })); }
protected override Task ExecuteAsync(CancellationToken stoppingToken) { return(Task.Run(async() => { while (!stoppingToken.IsCancellationRequested) { stoppingToken.ThrowIfCancellationRequested(); try { //TODO In multi-process scenarios, how do we decide which process to choose? //One possibility is to enable metrics after a request to begin polling for metrics int pid = _services.ResolveProcess(pid: null); await _pipeProcessor.Process(pid, Timeout.InfiniteTimeSpan, stoppingToken); } catch (Exception e) when(!(e is OperationCanceledException)) { //Most likely we failed to resolve the pid. Attempt to do this again. await Task.Delay(5000); } } }, stoppingToken)); }