-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add option to do an extra run on IService demand (#56)
- Loading branch information
1 parent
12b910d
commit a76cefc
Showing
14 changed files
with
570 additions
and
352 deletions.
There are no files selected for viewing
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
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
52 changes: 52 additions & 0 deletions
52
src/TimeItSharp.Common/Services/DatadogProfilerConfiguration.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,52 @@ | ||
using System.Text.Json; | ||
|
||
namespace TimeItSharp.Common.Services; | ||
|
||
public sealed class DatadogProfilerConfiguration | ||
{ | ||
internal Dictionary<string, bool>? EnabledScenarios { get; private set; } | ||
internal bool UseExtraRun { get; private set; } | ||
internal int ExtraRunCount { get; private set; } | ||
|
||
public DatadogProfilerConfiguration(Dictionary<string, JsonElement?>? options = null) | ||
{ | ||
if (options is not null) | ||
{ | ||
if (options.TryGetValue("useExtraRun", out var useExtraRunJsonElement) && | ||
useExtraRunJsonElement is not null) | ||
{ | ||
UseExtraRun = useExtraRunJsonElement.Value.GetBoolean(); | ||
} | ||
|
||
if (options.TryGetValue("extraRunCount", out var extraRunCountJsonElement) && | ||
extraRunCountJsonElement is not null) | ||
{ | ||
ExtraRunCount = extraRunCountJsonElement.Value.GetInt32(); | ||
} | ||
|
||
if (options.TryGetValue("scenarios", out var scenariosJsonElement) && | ||
scenariosJsonElement is not null) | ||
{ | ||
EnabledScenarios = new Dictionary<string, bool>(); | ||
foreach (var scenarioItem in scenariosJsonElement.Value.EnumerateArray()) | ||
{ | ||
EnabledScenarios[scenarioItem.GetString() ?? string.Empty] = true; | ||
} | ||
} | ||
} | ||
} | ||
|
||
public DatadogProfilerConfiguration WithScenario(string scenario, bool enabled) | ||
{ | ||
EnabledScenarios ??= new(); | ||
EnabledScenarios[scenario] = enabled; | ||
return this; | ||
} | ||
|
||
public DatadogProfilerConfiguration WithExtraRun(int count = 0) | ||
{ | ||
UseExtraRun = true; | ||
ExtraRunCount = count; | ||
return this; | ||
} | ||
} |
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
Oops, something went wrong.