-
Notifications
You must be signed in to change notification settings - Fork 103
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Support for Dump File Name Templates #6675
base: main
Are you sure you want to change the base?
Conversation
I have not yet added tests. I thought I'd first put out a first draft to gauge interest and assess the overall design. I'm no expert on this tool nor this project, so please provide any and all feedback. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some design considerations:
- We may want to have some uniformity around token substitutions. I.e. doing $(Process.ProcessId) in one context but %p in another can be confusing.
- Having a one-off configuration for dumps works, but we'll need to consider if this should be more generic and apply to other artifacts
- Should the setting be possible to provide at an api level? Or strictly configuration.
Thank you for the thoughts!
|
This class would likely require some refactoring to support scalar string values instead of properties
I think we could do this piece wise. Start with just configuration and consider an api level override later. |
I've changed the pattern. Let me know what you think. I'm uncertain about two things:
|
@@ -159,7 +160,9 @@ public object SubstituteOptionValues(IDictionary<string, CollectionRuleActionRes | |||
RuntimeId = _ruleContext.EndpointInfo?.RuntimeInstanceCookie ?? Guid.Empty, | |||
ProcessId = _ruleContext.EndpointInfo?.ProcessId ?? 0, | |||
CommandLine = commandLine, | |||
ProcessName = _ruleContext.ProcessInfo?.ProcessName ?? string.Empty | |||
ProcessName = _ruleContext.ProcessInfo?.ProcessName ?? string.Empty, | |||
Hostname = Dns.GetHostName(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Would it be better to use Environment.MachineName?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As you pointed out, this would be dotnet-monitor's machine name, which is not what we are looking for. We can get the target process environment variables, that should be enough for the host name in aks and Windows scenarios. Not sure about Linux though.
|
||
public static readonly string RuntimeIdReference = CreateTokenReference(ProcessInfoReference, RuntimeId); | ||
public static readonly string ProcessIdReference = CreateTokenReference(ProcessInfoReference, ProcessId); | ||
public static readonly string ProcessNameReference = CreateTokenReference(ProcessInfoReference, ProcessName); | ||
public static readonly string CommandLineReference = CreateTokenReference(ProcessInfoReference, CommandLine); | ||
public static readonly string HostnameReference = CreateTokenReference(ProcessInfoReference, Hostname); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As it is, this variable (Process.Hostname
) is semantically referring to the hostname of the target process. But the callers are collecting the hostname information of the host that .NET Monitor is running on. While these might be the same in many cases, I think this should be either:
- properly classified with a new prefix (e.g.
Monitor.Hostname
) if using the hostname on which .NET Monitor is running - or, get the environment block from the target process and resolve the host name from that. See https://github.com/dotnet/dotnet-monitor/blob/main/src/Microsoft.Diagnostics.Monitoring.WebApi/Controllers/DiagController.cs#L178 as an example of how to get the environment block of the target process.
|
||
public static readonly string RuntimeIdReference = CreateTokenReference(ProcessInfoReference, RuntimeId); | ||
public static readonly string ProcessIdReference = CreateTokenReference(ProcessInfoReference, ProcessId); | ||
public static readonly string ProcessNameReference = CreateTokenReference(ProcessInfoReference, ProcessName); | ||
public static readonly string CommandLineReference = CreateTokenReference(ProcessInfoReference, CommandLine); | ||
public static readonly string HostnameReference = CreateTokenReference(ProcessInfoReference, Hostname); | ||
public static readonly string UnixTimeReference = CreateTokenReference(ActionReference, UnixTime); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should use a different category for Timestamp than Action. These typically refer to other actions in a chain.
[Display( | ||
ResourceType = typeof(OptionsDisplayStrings), | ||
Description = nameof(OptionsDisplayStrings.DisplayAttributeDescription_CollectArtifactOptions_ArtifactName))] | ||
public string ArtifactName { get; set; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm ok with this level of configuration, but I think long term we'll want a higher tier of configuration on a per artifact type rather than per egress type. We can add that later though.
Summary
Enable users to configure the name of artifacts for the following actions:
CollectDump
CollectExceptions
CollectGCDump
CollectLiveMetrics
CollectLogs
CollectStacks
CollectTrace
Furthermore, the following placeholders have been added to bring parity with the placeholders used by the environment variable
DOTNET_DbgMiniDumpName
/COMPlus_DbgMiniDumpName
as detailed here.$(Process.Hostname)
gethostname()
$(Action.UnixTime)
Resolve #3917
Release Notes Entry
$(Process.Hostname)
and$(Action.UnixTime)