From 88c71cd3b4f412ec5163859e61c0796a7b09d7b8 Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Fri, 1 May 2020 18:05:41 -0700 Subject: [PATCH] Add more information in our NFW description to help the backend bucket it better --- .../Implementation/Watson/WatsonReporter.cs | 35 ++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/src/VisualStudio/Core/Def/Implementation/Watson/WatsonReporter.cs b/src/VisualStudio/Core/Def/Implementation/Watson/WatsonReporter.cs index a8b9b680214..db04b0166a9 100644 --- a/src/VisualStudio/Core/Def/Implementation/Watson/WatsonReporter.cs +++ b/src/VisualStudio/Core/Def/Implementation/Watson/WatsonReporter.cs @@ -88,7 +88,7 @@ public static void ReportNonFatal(Exception exception) var faultEvent = new FaultEvent( eventName: FunctionId.NonFatalWatson.GetEventName(), - description: "Roslyn NonFatal Watson", + description: GetDescription(), FaultSeverity.Diagnostic, exceptionObject: exception, gatherEventDetails: faultUtility => @@ -114,6 +114,39 @@ public static void ReportNonFatal(Exception exception) session.PostEvent(faultEvent); } + private static string GetDescription() + { + const string OurNamespace = nameof(Microsoft) + "." + nameof(CodeAnalysis) + "." + nameof(ErrorReporting); + + // Be resilient to failing here. If we can't get a suitable name, just fallback to the standard name we + // used to report. + try + { + // walk up the stack looking for the first call from a type that isn't in the ErrorReporting namespace. + foreach (var frame in new StackTrace().GetFrames()) + { + var method = frame.GetMethod(); + var methodName = method?.Name; + if (methodName == null) + continue; + + var declaringTypeName = method?.DeclaringType?.FullName; + if (declaringTypeName == null) + continue; + + if (declaringTypeName.StartsWith(OurNamespace)) + continue; + + return declaringTypeName + "." + methodName; + } + } + catch + { + } + + return "Roslyn NonFatal Watson"; + } + private static List CollectServiceHubLogFilePaths() { var paths = new List(); -- GitLab