public Task <ActionResult> CaptureDump( [FromQuery] int?pid = null, [FromQuery] Guid?uid = null, [FromQuery] string name = null, [FromQuery] Models.DumpType type = Models.DumpType.WithHeap, [FromQuery] string egressProvider = null) { ProcessKey?processKey = GetProcessKey(pid, uid, name); return(InvokeForProcess(async processInfo => { string dumpFileName = DumpUtilities.GenerateDumpFileName(); if (string.IsNullOrEmpty(egressProvider)) { Stream dumpStream = await _dumpService.DumpAsync(processInfo.EndpointInfo, type, HttpContext.RequestAborted); _logger.WrittenToHttpStream(); //Compression is done automatically by the response //Chunking is done because the result has no content-length return File(dumpStream, ContentTypes.ApplicationOctetStream, dumpFileName); } else { KeyValueLogScope scope = Utilities.CreateArtifactScope(Utilities.ArtifactType_Dump, processInfo.EndpointInfo); return await SendToEgress(new EgressOperation( token => _dumpService.DumpAsync(processInfo.EndpointInfo, type, token), egressProvider, dumpFileName, processInfo.EndpointInfo, ContentTypes.ApplicationOctetStream, scope), limitKey: Utilities.ArtifactType_Dump); } }, processKey, Utilities.ArtifactType_Dump)); }
protected override async Task <CollectionRuleActionResult> ExecuteCoreAsync( TaskCompletionSource <object> startCompletionSource, CancellationToken token) { DumpType dumpType = Options.Type.GetValueOrDefault(CollectDumpOptionsDefaults.Type); string egressProvider = Options.Egress; string dumpFileName = DumpUtilities.GenerateDumpFileName(); string dumpFilePath = string.Empty; KeyValueLogScope scope = Utils.CreateArtifactScope(Utils.ArtifactType_Dump, EndpointInfo); try { EgressOperation egressOperation = new EgressOperation( token => { startCompletionSource.TrySetResult(null); return(_dumpService.DumpAsync(EndpointInfo, dumpType, token)); }, egressProvider, dumpFileName, EndpointInfo, ContentTypes.ApplicationOctetStream, scope); ExecutionResult <EgressResult> result = await egressOperation.ExecuteAsync(_serviceProvider, token); dumpFilePath = result.Result.Value; } catch (Exception ex) { throw new CollectionRuleActionException(ex); } return(new CollectionRuleActionResult() { OutputValues = new Dictionary <string, string>(StringComparer.Ordinal) { { CollectionRuleActionConstants.EgressPathOutputValueName, dumpFilePath } } }); }