Skip to content

Commit

Permalink
Merge pull request #42609 from dotnet/merges/release/dev16.6-preview2…
Browse files Browse the repository at this point in the history
…-to-release/dev16.6-preview2-vs-deps

Merge release/dev16.6-preview2 to release/dev16.6-preview2-vs-deps
  • Loading branch information
msftbot[bot] authored Mar 20, 2020
2 parents 2ab0897 + 8b0bb11 commit 2242fa4
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 28 deletions.
50 changes: 34 additions & 16 deletions src/VisualStudio/Core/Def/Implementation/Watson/WatsonReporter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
using System.IO;
using System.Reflection;
using Microsoft.CodeAnalysis.Internal.Log;
using Microsoft.CodeAnalysis.Remote;
using Microsoft.VisualStudio.LanguageServices.Telemetry;
using Microsoft.VisualStudio.Telemetry;

Expand Down Expand Up @@ -57,7 +58,15 @@ public static void InitializeLogger(TraceSource logger)

public static void ReportFatal(Exception exception)
{
_ = CaptureLogFiles();
try
{
CaptureFilesInMemory(CollectServiceHubLogFilePaths());
}
catch
{
// ignore any exceptions (e.g. OOM)
}

FailFast.OnFatalException(exception);
}

Expand Down Expand Up @@ -89,8 +98,6 @@ public static void ReportNonFatal(Exception exception)
return;
}

var logFilePaths = CaptureLogFiles();

var faultEvent = new FaultEvent(
eventName: FunctionId.NonFatalWatson.GetEventName(),
description: "Roslyn NonFatal Watson",
Expand All @@ -102,7 +109,7 @@ public static void ReportNonFatal(Exception exception)
faultUtility.AddProcessDump(currentProcess.Id);

// add ServiceHub log files:
foreach (var path in logFilePaths)
foreach (var path in CollectServiceHubLogFilePaths())
{
faultUtility.AddFile(path);
}
Expand All @@ -119,39 +126,48 @@ public static void ReportNonFatal(Exception exception)
session.PostEvent(faultEvent);
}

private static List<string> CaptureLogFiles()
private static List<string> CollectServiceHubLogFilePaths()
{
var result = new List<string>();
CollectServiceHubLogFiles(result);
CaptureFilesInMemory(result);
return result;
}
var paths = new List<string>();

private static void CollectServiceHubLogFiles(List<string> paths)
{
try
{
var logPath = Path.Combine(Path.GetTempPath(), "servicehub", "logs");
if (!Directory.Exists(logPath))
{
return;
return paths;
}

// attach all log files that are modified less than 1 day before.
var now = DateTime.UtcNow;
var oneDay = TimeSpan.FromDays(1);

foreach (var file in Directory.EnumerateFiles(logPath, "*.log"))
foreach (var path in Directory.EnumerateFiles(logPath, "*.log"))
{
try
{
var lastWrite = File.GetLastWriteTimeUtc(file);
var name = Path.GetFileNameWithoutExtension(path);

// TODO: https://github.com/dotnet/roslyn/issues/42582
// name our services more consistently to simplify filtering

// filter logs that are not relevant to Roslyn investigation
if (!name.Contains("-" + WellKnownServiceHubServices.NamePrefix) &&
!name.Contains("-CodeLens") &&
!name.Contains("-pythia") &&
!name.Contains("-ManagedLanguage.IDE.RemoteHostClient") &&
!name.Contains("-hub"))
{
continue;
}

var lastWrite = File.GetLastWriteTimeUtc(path);
if (now - lastWrite > oneDay)
{
continue;
}

paths.Add(file);
paths.Add(path);
}
catch
{
Expand All @@ -163,6 +179,8 @@ private static void CollectServiceHubLogFiles(List<string> paths)
{
// ignore failures
}

return paths;
}

private static void CaptureFilesInMemory(IEnumerable<string> paths)
Expand Down
26 changes: 14 additions & 12 deletions src/Workspaces/Core/Portable/Remote/WellKnownServiceHubServices.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,26 @@ namespace Microsoft.CodeAnalysis.Remote
{
internal static class WellKnownServiceHubServices
{
public const string NamePrefix = "roslyn";

public static void Set64bit(bool x64)
{
var bit = x64 ? "64" : "";

SnapshotService = "roslynSnapshot" + bit;
CodeAnalysisService = "roslynCodeAnalysis" + bit;
RemoteDesignerAttributeService = "roslynRemoteDesignerAttributeService" + bit;
RemoteProjectTelemetryService = "roslynRemoteProjectTelemetryService" + bit;
RemoteSymbolSearchUpdateEngine = "roslynRemoteSymbolSearchUpdateEngine" + bit;
LanguageServer = "roslynLanguageServer" + bit;
SnapshotService = NamePrefix + "Snapshot" + bit;
CodeAnalysisService = NamePrefix + "CodeAnalysis" + bit;
RemoteDesignerAttributeService = NamePrefix + "RemoteDesignerAttributeService" + bit;
RemoteProjectTelemetryService = NamePrefix + "RemoteProjectTelemetryService" + bit;
RemoteSymbolSearchUpdateEngine = NamePrefix + "RemoteSymbolSearchUpdateEngine" + bit;
LanguageServer = NamePrefix + "LanguageServer" + bit;
}

public static string SnapshotService { get; private set; } = "roslynSnapshot";
public static string CodeAnalysisService { get; private set; } = "roslynCodeAnalysis";
public static string RemoteSymbolSearchUpdateEngine { get; private set; } = "roslynRemoteSymbolSearchUpdateEngine";
public static string RemoteDesignerAttributeService { get; private set; } = "roslynRemoteDesignerAttributeService";
public static string RemoteProjectTelemetryService { get; private set; } = "roslynRemoteProjectTelemetryService";
public static string LanguageServer { get; private set; } = "roslynLanguageServer";
public static string SnapshotService { get; private set; } = NamePrefix + "Snapshot";
public static string CodeAnalysisService { get; private set; } = NamePrefix + "CodeAnalysis";
public static string RemoteSymbolSearchUpdateEngine { get; private set; } = NamePrefix + "RemoteSymbolSearchUpdateEngine";
public static string RemoteDesignerAttributeService { get; private set; } = NamePrefix + "RemoteDesignerAttributeService";
public static string RemoteProjectTelemetryService { get; private set; } = NamePrefix + "RemoteProjectTelemetryService";
public static string LanguageServer { get; private set; } = NamePrefix + "LanguageServer";

// these are OOP implementation itself should care. not features that consume OOP care
public const string ServiceHubServiceBase_Initialize = "Initialize";
Expand Down

0 comments on commit 2242fa4

Please sign in to comment.