-
Notifications
You must be signed in to change notification settings - Fork 115
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Some refactoring, fixed broken test and added coverage
- Loading branch information
1 parent
b98e3f6
commit b934d90
Showing
11 changed files
with
162 additions
and
68 deletions.
There are no files selected for viewing
29 changes: 8 additions & 21 deletions
29
src/Microsoft.Diagnostics.Monitoring.Options/MonitorCapability.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,24 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
using System.ComponentModel.DataAnnotations; | ||
using System.Text.Json.Serialization; | ||
|
||
namespace Microsoft.Diagnostics.Monitoring.Options | ||
{ | ||
public class MonitorCapability : IMonitorCapability | ||
public class MonitorCapability | ||
{ | ||
public const string Exceptions = "exceptions"; | ||
public const string ParameterCapturing = "parameters"; | ||
public const string CallStacks = "callstacks"; | ||
public const string Metrics = "metrics"; | ||
public const string HttpEgress = "http_egress"; | ||
|
||
public string Name { get; } | ||
[Required] | ||
[JsonPropertyName("name")] | ||
public string Name { get; set; } = string.Empty; | ||
|
||
[JsonPropertyName("enabled")] | ||
public bool Enabled { get; set; } | ||
public MonitorCapability(string name) | ||
{ | ||
Name = name; | ||
} | ||
|
||
public MonitorCapability(string name, bool enabled) | ||
{ | ||
Name = name; | ||
Enabled = enabled; | ||
} | ||
} | ||
|
||
public interface IMonitorCapability | ||
{ | ||
string Name { get; } | ||
bool Enabled | ||
{ | ||
get; set; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
src/Tools/dotnet-monitor/CallStacksCapabilityPostConfigureOptions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
using Microsoft.Diagnostics.Monitoring.Options; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
|
||
namespace Microsoft.Diagnostics.Monitoring | ||
{ | ||
public class CallStacksCapabilityPostConfigureOptions : CapabilityPostConfigureOptions<CallStacksOptions> | ||
{ | ||
public CallStacksCapabilityPostConfigureOptions(IEnumerable<MonitorCapability> capabilities) | ||
: base(capabilities.First(c => c.Name == MonitorCapability.CallStacks)) | ||
{ | ||
} | ||
|
||
public override void PostConfigure(string? _, CallStacksOptions options) | ||
{ | ||
PostConfigure(options.Enabled ?? false); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
src/Tools/dotnet-monitor/ExceptionsCapabilityPostConfigureOptions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
using Microsoft.Diagnostics.Monitoring.Options; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
|
||
namespace Microsoft.Diagnostics.Monitoring | ||
{ | ||
public class ExceptionsCapabilityPostConfigureOptions : CapabilityPostConfigureOptions<ExceptionsOptions> | ||
{ | ||
public ExceptionsCapabilityPostConfigureOptions(IEnumerable<MonitorCapability> capabilities) | ||
: base(capabilities.First(c => c.Name == MonitorCapability.Exceptions)) | ||
{ | ||
} | ||
|
||
public override void PostConfigure(string? _, ExceptionsOptions options) | ||
{ | ||
PostConfigure(options.Enabled ?? false); | ||
} | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
src/Tools/dotnet-monitor/MetricsCapabilityPostConfigureOptions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
using Microsoft.Diagnostics.Monitoring.Options; | ||
using Microsoft.Diagnostics.Monitoring.WebApi; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
|
||
namespace Microsoft.Diagnostics.Monitoring | ||
{ | ||
public class MetricsCapabilityPostConfigureOptions : CapabilityPostConfigureOptions<MetricsOptions> | ||
{ | ||
public MetricsCapabilityPostConfigureOptions(IEnumerable<MonitorCapability> capabilities) | ||
: base(capabilities.First(c => c.Name == MonitorCapability.Metrics)) | ||
{ | ||
} | ||
|
||
public override void PostConfigure(string? _, MetricsOptions options) | ||
{ | ||
PostConfigure(options.Enabled ?? false); | ||
} | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
src/Tools/dotnet-monitor/ParametersCapabilityPostConfigureOptions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
using Microsoft.Diagnostics.Monitoring.Options; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
|
||
namespace Microsoft.Diagnostics.Monitoring | ||
{ | ||
public class ParametersCapabilityPostConfigureOptions : CapabilityPostConfigureOptions<ParameterCapturingOptions> | ||
{ | ||
public ParametersCapabilityPostConfigureOptions(IEnumerable<MonitorCapability> capabilities) | ||
: base(capabilities.First(c => c.Name == MonitorCapability.ParameterCapturing)) | ||
{ | ||
} | ||
|
||
public override void PostConfigure(string? _, ParameterCapturingOptions options) | ||
{ | ||
PostConfigure(options.Enabled ?? false); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters