-
Notifications
You must be signed in to change notification settings - Fork 201
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[gh-1322] Update App Insights to use connection strings (except Conta…
…iner Host)
- Loading branch information
Showing
54 changed files
with
908 additions
and
600 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
using System; | ||
|
||
namespace SharpLab.Server.Common; | ||
|
||
public static class EnvironmentHelper { | ||
public static string GetRequiredEnvironmentVariable(string name) { | ||
return Environment.GetEnvironmentVariable(name) | ||
?? throw new Exception($"Environment variable {name} was not found"); | ||
} | ||
} |
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,51 @@ | ||
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; | ||
|
||
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"); | ||
} | ||
|
||
public void TrackBranch() { | ||
_branchMonitor.Track(1); | ||
} | ||
|
||
public void TrackLanguage(string languageName) { | ||
if (_languageMetricMonitors.TryGetValue(languageName, out var metricMonitor)) | ||
metricMonitor.Track(1); | ||
} | ||
|
||
public void TrackTarget(string targetName) { | ||
if (_targetMetricMonitors.TryGetValue(targetName, out var metricMonitor)) | ||
metricMonitor.Track(1); | ||
} | ||
|
||
public void TrackOptimize(string? optimize) { | ||
var monitor = optimize switch { | ||
Optimize.Debug => _optimizeDebugMonitor, | ||
Optimize.Release => _optimizeReleaseMonitor, | ||
_ => null | ||
}; | ||
monitor?.Track(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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
namespace SharpLab.Server.Common; | ||
|
||
public interface IFeatureTracker { | ||
void TrackBranch(); | ||
void TrackLanguage(string languageName); | ||
void TrackTarget(string targetName); | ||
void TrackOptimize(string? optimize); | ||
} |
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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
namespace SharpLab.Server.Common; | ||
|
||
public interface ISecretsClient { | ||
string GetSecret(string key); | ||
} |
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,10 +1,15 @@ | ||
using System.Collections.Immutable; | ||
using CodeAnalysis = Microsoft.CodeAnalysis; | ||
|
||
namespace SharpLab.Server.Common { | ||
public class LanguageNames { | ||
public const string CSharp = CodeAnalysis.LanguageNames.CSharp; | ||
public const string VisualBasic = CodeAnalysis.LanguageNames.VisualBasic; | ||
public const string FSharp = CodeAnalysis.LanguageNames.FSharp; | ||
public const string IL = "IL"; | ||
} | ||
namespace SharpLab.Server.Common; | ||
|
||
public class LanguageNames { | ||
public const string CSharp = CodeAnalysis.LanguageNames.CSharp; | ||
public const string VisualBasic = CodeAnalysis.LanguageNames.VisualBasic; | ||
public const string FSharp = CodeAnalysis.LanguageNames.FSharp; | ||
public const string IL = "IL"; | ||
|
||
public static readonly ImmutableArray<string> All = ImmutableArray.Create( | ||
CSharp, VisualBasic, FSharp, IL | ||
); | ||
} |
Oops, something went wrong.