-
Notifications
You must be signed in to change notification settings - Fork 202
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[gh-1150] Update feature metrics to use dimensions
- Loading branch information
Showing
37 changed files
with
651 additions
and
747 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,51 +1,35 @@ | ||
using SharpLab.Server.Monitoring; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
|
||
namespace SharpLab.Server.Common; | ||
|
||
public class FeatureTracker : IFeatureTracker { | ||
private readonly IMetricMonitor _branchMonitor; | ||
private readonly IReadOnlyDictionary<string, IMetricMonitor> _languageMetricMonitors; | ||
private readonly IReadOnlyDictionary<string, IMetricMonitor> _targetMetricMonitors; | ||
private readonly IMetricMonitor _optimizeDebugMonitor; | ||
private readonly IMetricMonitor _optimizeReleaseMonitor; | ||
private readonly string _webAppName; | ||
private readonly IOneDimensionMetricMonitor _branchMetricMonitor; | ||
private readonly IOneDimensionMetricMonitor _languageMetricMonitor; | ||
private readonly IOneDimensionMetricMonitor _targetMetricMonitor; | ||
private readonly IOneDimensionMetricMonitor _optimizeMetricMonitor; | ||
|
||
public FeatureTracker(IMonitor monitor, string webAppName) { | ||
_branchMonitor = monitor.MetricSlow("feature", $"Branch: {webAppName}"); | ||
_languageMetricMonitors = LanguageNames.All.ToDictionary( | ||
name => name, | ||
name => monitor.MetricSlow("feature", $"Language: {name}") | ||
); | ||
_targetMetricMonitors = TargetNames.All.ToDictionary( | ||
name => name, | ||
name => monitor.MetricSlow("feature", $"Target: {name}") | ||
); | ||
|
||
_optimizeDebugMonitor = monitor.MetricSlow("feature", "Optimize: Debug"); | ||
_optimizeReleaseMonitor = monitor.MetricSlow("feature", "Optimize: Release"); | ||
_webAppName = webAppName; | ||
_branchMetricMonitor = monitor.MetricSlow("feature", "Branch", "Branch"); | ||
_languageMetricMonitor = monitor.MetricSlow("feature", "Language", "Language"); | ||
_targetMetricMonitor = monitor.MetricSlow("feature", "Target", "Target"); | ||
_optimizeMetricMonitor = monitor.MetricSlow("feature", "Optimize", "Optimize"); | ||
} | ||
|
||
public void TrackBranch() { | ||
_branchMonitor.Track(1); | ||
_branchMetricMonitor.Track(_webAppName, 1); | ||
} | ||
|
||
public void TrackLanguage(string languageName) { | ||
if (_languageMetricMonitors.TryGetValue(languageName, out var metricMonitor)) | ||
metricMonitor.Track(1); | ||
_languageMetricMonitor.Track(languageName, 1); | ||
} | ||
|
||
public void TrackTarget(string targetName) { | ||
if (_targetMetricMonitors.TryGetValue(targetName, out var metricMonitor)) | ||
metricMonitor.Track(1); | ||
_targetMetricMonitor.Track(targetName, 1); | ||
} | ||
|
||
public void TrackOptimize(string? optimize) { | ||
var monitor = optimize switch { | ||
Optimize.Debug => _optimizeDebugMonitor, | ||
Optimize.Release => _optimizeReleaseMonitor, | ||
_ => null | ||
}; | ||
monitor?.Track(1); | ||
public void TrackOptimize(string optimize) { | ||
_optimizeMetricMonitor.Track(optimize, 1); | ||
} | ||
} |
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
Oops, something went wrong.