Пример #1
0
        public static SDClrException ToSDModel(this ClrException clrException)
        {
            var model = new SDClrException();

            if (clrException != null)
            {
                model.Address = clrException.Address;
                model.Type    = clrException.Type.Name;
                //this.HResult = clrException.HResult;

                if (model.InnerException != null)
                {
                    model.InnerException = clrException.Inner.ToSDModel();
                }

                model.Message = clrException.GetExceptionMessageSafe();

                var frames = new List <SDCombinedStackFrame>();
                foreach (ClrStackFrame clrFrame in clrException.StackTrace)
                {
                    model.StackTrace.Add(clrFrame.ToSDModel());
                }
                model.StackTrace = new SDCombinedStackTrace(frames);
            }
            return(model);
        }
Пример #2
0
        public async Task <string> GetMessage(DumpMetainfo dumpInfo)
        {
            var model = new SlackMessageViewModel();

            var res = dumpRepo.GetResult(dumpInfo.BundleId, dumpInfo.DumpId, out string error);

            var engine = new EngineFactory().ForEmbeddedResources(typeof(SlackMessageViewModel));

            model.TopProperties.Add(dumpInfo.DumpType == DumpType.WindowsDump ? "Windows" : "Linux");
            model.DumpFilename = Path.GetFileName(dumpInfo.DumpFileName);
            model.Url          = $"{superDumpUrl}/Home/Report?bundleId={dumpInfo.BundleId}&dumpId={dumpInfo.DumpId}";
            if (res != null)
            {
                model.TopProperties.Add(res.SystemContext.ProcessArchitecture);

                if (res.IsManagedProcess)
                {
                    model.TopProperties.Add(".NET");
                }
                if (res.SystemContext.Modules.Any(x => x.FileName.Contains("jvm.dll")))
                {
                    model.TopProperties.Add("Java");
                }
                if (res.SystemContext.Modules.Any(x => x.FileName.Contains("jvm.so")))
                {
                    model.TopProperties.Add("Java");
                }
                if (res.SystemContext.Modules.Any(x => x.FileName.Contains("iiscore.dll")))
                {
                    model.TopProperties.Add("IIS");
                }
                if (res.SystemContext.Modules.Any(x => x.FileName.Contains("nginx.so")))
                {
                    model.TopProperties.Add("NGINX");
                }
                if (res.SystemContext.Modules.Any(x => x.FileName.Contains("httpd/modules")))
                {
                    model.TopProperties.Add("Apache");
                }
                if (res.SystemContext.Modules.Any(x => x.FileName.Contains("node.exe")))
                {
                    model.TopProperties.Add("Node.js");
                }

                var agentModules = res.SystemContext.Modules.Where(x => x.Tags.Any(t => t.Equals(SDTag.DynatraceAgentTag))).Select(m => m.ToString());
                model.AgentModules = agentModules.ToList();

                model.NumManagedExceptions = res.ThreadInformation.Count(x => x.Value.Tags.Any(t => t.Equals(SDTag.ManagedExceptionTag)));
                model.NumNativeExceptions  = res.ThreadInformation.Count(x => x.Value.Tags.Any(t => t.Equals(SDTag.NativeExceptionTag)));
                model.NumAssertErrors      = res.ThreadInformation.Count(x => x.Value.Tags.Any(t => t.Equals(SDTag.AssertionErrorTag)));

                SDThread       managedExceptionThread = res.ThreadInformation.Values.FirstOrDefault(x => x.Tags.Any(t => t.Equals(SDTag.ManagedExceptionTag)));
                SDClrException clrException           = managedExceptionThread?.LastException;
                if (clrException != null)
                {
                    model.TopException = clrException.Type;
                    model.Stacktrace   = clrException.StackTrace.ToString();
                }

                if (res.LastEvent != null && !res.LastEvent.Description.Contains("Break instruction"))                   // break instruction events are useless
                {
                    model.LastEvent = $"{res.LastEvent.Type}: {res.LastEvent.Description}";
                }
            }

            return(await engine.CompileRenderAsync("SlackMessage", model));
        }