Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,17 @@ public DiagController(ILogger<DiagController> logger,
{
defaultProcessInfo = await _diagnosticServices.GetProcessAsync(null, HttpContext.RequestAborted);
}
catch (Exception)
catch (ArgumentException)
{
// Unable to locate a default process; no action required
}
catch (InvalidOperationException)
{
}
catch (Exception ex) when (!(ex is OperationCanceledException))
{
_logger.DefaultProcessUnexpectedFailure(ex);
}

IList<Models.ProcessIdentifier> processesIdentifiers = new List<Models.ProcessIdentifier>();
foreach (IProcessInfo p in await _diagnosticServices.GetProcessesAsync(processFilter: null, HttpContext.RequestAborted))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@ internal static class LoggingExtensions
logLevel: LogLevel.Warning,
formatString: Strings.LogFormatString_ThrottledEndpoint);

private static readonly Action<ILogger, Exception> _defaultProcessUnexpectedFailure =
LoggerMessage.Define(
eventId: new EventId(7, "DefaultProcessUnexpectedFailure"),
logLevel: LogLevel.Warning,
formatString: Strings.LogFormatString_DefaultProcessUnexpectedFailure);

public static void RequestFailed(this ILogger logger, Exception ex)
{
_requestFailed(logger, ex);
Expand Down Expand Up @@ -74,5 +80,10 @@ public static void WrittenToHttpStream(this ILogger logger)
{
_writtenToHttpStream(logger, null);
}

public static void DefaultProcessUnexpectedFailure(this ILogger logger, Exception ex)
{
_defaultProcessUnexpectedFailure(logger, ex);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,10 @@ public static async Task<IProcessInfo> FromEndpointInfoAsync(IEndpointInfo endpo

commandLine = await commandLineSource.Task;
}
catch
catch (PipelineException)
{
}
catch (OperationCanceledException)
{
}
finally
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions src/Microsoft.Diagnostics.Monitoring.WebApi/Strings.resx
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,11 @@
<value>Value must be of type string.</value>
<comment>Gets a string similar to "Value must be of type string.".</comment>
</data>
<data name="LogFormatString_DefaultProcessUnexpectedFailure" xml:space="preserve">
<value>Failed to determine the default process.</value>
<comment>Gets the format string that is printed in the 7:DefaultProcessUnexpectedFailure event.
0 Format Parameters</comment>
</data>
<data name="LogFormatString_EgressedArtifact" xml:space="preserve">
<value>Egressed artifact to {location}</value>
<comment>Gets the format string that is printed in the 4:EgressedArtifact event.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,12 @@ namespace Microsoft.Diagnostics.Tools.Monitor.Egress.FileSystem
internal class FileSystemEgressProvider :
EgressProvider<FileSystemEgressProviderOptions>
{
ILogger<FileSystemEgressProvider> _logger;

public FileSystemEgressProvider(ILogger<FileSystemEgressProvider> logger)
: base(logger)
{
_logger = logger;
}

public override async Task<string> EgressAsync(
Expand Down Expand Up @@ -75,8 +78,9 @@ public override async Task<string> EgressAsync(
File.Delete(intermediateFilePath);
}
}
catch (Exception)
catch (Exception ex)
{
_logger.IntermediateFileDeletionFailed(intermediateFilePath, ex);
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/Tools/dotnet-monitor/FilteredEndpointInfoSource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,9 @@ public FilteredEndpointInfoSource(
_runtimeInstanceCookieToFilterOut = runtimeInstanceCookie;
}
}
catch (Exception)
catch (Exception ex)
{
clientSourceLogger.RuntimeInstanceCookieFailedToFilterSelf(ex);
}

// If connecting to runtime instances, filter self out. In listening mode, it's likely
Expand Down
5 changes: 4 additions & 1 deletion src/Tools/dotnet-monitor/LoggingEventIds.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,10 @@ internal enum LoggingEventIds
QueueOptionsPartiallySet = 58,
WritingMessageToQueueFailed = 59,
ExperienceSurvey = 60,
DiagnosticPortNotInListenModeForCollectionRules = 61
DiagnosticPortNotInListenModeForCollectionRules = 61,
RuntimeInstanceCookieFailedToFilterSelf = 62,
ParsingUrlFailed = 63,
IntermediateFileDeletionFailed = 64
}

internal static class LoggingEventIdsExtensions
Expand Down
33 changes: 33 additions & 0 deletions src/Tools/dotnet-monitor/LoggingExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,24 @@ internal static class LoggingExtensions
logLevel: LogLevel.Warning,
formatString: Strings.LogFormatString_DiagnosticPortNotInListenModeForCollectionRules);

private static readonly Action<ILogger, Exception> _runtimeInstanceCookieFailedToFilterSelf =
LoggerMessage.Define(
eventId: LoggingEventIds.RuntimeInstanceCookieFailedToFilterSelf.EventId(),
logLevel: LogLevel.Debug,
formatString: Strings.LogFormatString_RuntimeInstanceCookieFailedToFilterSelf);

private static readonly Action<ILogger, string, Exception> _parsingUrlFailed =
LoggerMessage.Define<string>(
eventId: LoggingEventIds.ParsingUrlFailed.EventId(),
logLevel: LogLevel.Warning,
formatString: Strings.LogFormatString_ParsingUrlFailed);

private static readonly Action<ILogger, string, Exception> _intermediateFileDeletionFailed =
LoggerMessage.Define<string>(
eventId: LoggingEventIds.IntermediateFileDeletionFailed.EventId(),
logLevel: LogLevel.Debug,
formatString: Strings.LogFormatString_IntermediateFileDeletionFailed);

public static void EgressProviderInvalidOptions(this ILogger logger, string providerName)
{
_egressProviderInvalidOptions(logger, providerName, null);
Expand Down Expand Up @@ -623,5 +641,20 @@ public static void DiagnosticPortNotInListenModeForCollectionRules(this ILogger
{
_diagnosticPortNotInListenModeForCollectionRules(logger, null);
}

public static void RuntimeInstanceCookieFailedToFilterSelf(this ILogger logger, Exception ex)
{
_runtimeInstanceCookieFailedToFilterSelf(logger, ex);
}

public static void ParsingUrlFailed(this ILogger logger, string url, Exception ex)
{
_parsingUrlFailed(logger, url, ex);
}

public static void IntermediateFileDeletionFailed(this ILogger logger, string intermediateFilePath, Exception ex)
{
_intermediateFileDeletionFailed(logger, intermediateFilePath, ex);
}
}
}
3 changes: 2 additions & 1 deletion src/Tools/dotnet-monitor/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,9 @@ public void Configure(
{
address = BindingAddress.Parse(url);
}
catch (Exception)
catch (FormatException ex)
{
logger.ParsingUrlFailed(url, ex);
continue;
}

Expand Down
27 changes: 27 additions & 0 deletions src/Tools/dotnet-monitor/Strings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions src/Tools/dotnet-monitor/Strings.resx
Original file line number Diff line number Diff line change
Expand Up @@ -565,6 +565,9 @@
<comment>Gets the format string that is printed in the 14:InsecureAutheticationConfiguration event.
0 Format Parameters</comment>
</data>
<data name="LogFormatString_IntermediateFileDeletionFailed" xml:space="preserve">
<value>The intermediate file at the following path could not be deleted: {path}</value>
</data>
<data name="LogFormatString_InvalidActionReference" xml:space="preserve">
<value>Invalid action reference '{actionReference}'.</value>
</data>
Expand Down Expand Up @@ -605,6 +608,9 @@
1 Format Parameter:
1. failure: The failure message from validation</comment>
</data>
<data name="LogFormatString_ParsingUrlFailed" xml:space="preserve">
<value>The provided url could not be parsed: {url}</value>
</data>
<data name="LogFormatString_QueueDoesNotExist" xml:space="preserve">
<value>The queue {0} does not exist; ensure that the {queueName} and {queueAccountUri} fields are set correctly.</value>
<comment>Gets the format string that is printed in the 57:QueueDoesNotExist event.
Expand All @@ -625,6 +631,9 @@
<comment>Gets the format string that is printed in the 19:RunningElevated event.
0 Format Parameters</comment>
</data>
<data name="LogFormatString_RuntimeInstanceCookieFailedToFilterSelf" xml:space="preserve">
<value>Unable to get the runtime instance cookie of the current process.</value>
</data>
<data name="LogFormatString_SetEnvironmentVariable" xml:space="preserve">
<value>Setting the environment variable {variableName} in process {processId}.</value>
<comment>Gets the format string that is printed in the 54:SetEnvironmentVariable event.
Expand Down