Пример #1
0
        public Task <ActionResult> GetDump(
            ProcessFilter?processFilter,
            [FromQuery] DumpType type         = DumpType.WithHeap,
            [FromQuery] string egressProvider = null)
        {
            return(InvokeForProcess(async processInfo =>
            {
                string dumpFileName = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ?
                                      FormattableString.Invariant($"dump_{GetFileNameTimeStampUtcNow()}.dmp") :
                                      FormattableString.Invariant($"core_{GetFileNameTimeStampUtcNow()}");

                if (string.IsNullOrEmpty(egressProvider))
                {
                    Stream dumpStream = await _diagnosticServices.GetDump(processInfo, type, HttpContext.RequestAborted);

                    //Compression is done automatically by the response
                    //Chunking is done because the result has no content-length
                    return File(dumpStream, ContentTypes.ApplicationOctectStream, dumpFileName);
                }
                else
                {
                    KeyValueLogScope scope = new KeyValueLogScope();
                    scope.AddArtifactType(ArtifactType_Dump);
                    scope.AddEndpointInfo(processInfo.EndpointInfo);

                    return new EgressStreamResult(
                        token => _diagnosticServices.GetDump(processInfo, type, token),
                        egressProvider,
                        dumpFileName,
                        processInfo.EndpointInfo,
                        ContentTypes.ApplicationOctectStream,
                        scope);
                }
            }, processFilter, ArtifactType_Dump));
        }
Пример #2
0
        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);
            }));
        }
Пример #3
0
        public Task <ActionResult> GetDump(
            ProcessFilter?processFilter,
            [FromQuery] DumpType type = DumpType.WithHeap)
        {
            return(this.InvokeService(async() =>
            {
                IProcessInfo processInfo = await _diagnosticServices.GetProcessAsync(processFilter, HttpContext.RequestAborted);
                Stream result = await _diagnosticServices.GetDump(processInfo, type, HttpContext.RequestAborted);

                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);
            }));
        }
Пример #4
0
        public Task <ActionResult> GetDump(int pid, [FromQuery] int?dumpType = 1)
        {
            if (!Enum.IsDefined(typeof(DumpType), dumpType))
            {
                return(Task.FromResult <ActionResult>(BadRequest(new ProblemDetails {
                    Detail = "Invalid dump type", Status = 400
                })));
            }

            return(InvokeService(async() =>
            {
                Stream dump = await _diagnosticServices.GetDump(pid, (DumpType)dumpType);

                //Compression is done automatically by the response
                //Chunking is done because the result has no content-length
                return File(dump, "application/octet-stream", fileDownloadName: FormattableString.Invariant($"coredump_{pid}"));
            }));
        }
Пример #5
0
        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));
            }));
        }