-
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.
Micro-batching for logs sending, restricted access to internal classe…
…s, no op registrar implementation
- Loading branch information
1 parent
2961933
commit 51478a1
Showing
34 changed files
with
424 additions
and
142 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
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
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,42 +1,54 @@ | ||
using System.Collections.Generic; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using ZafiraIntegration.Config.Provider; | ||
|
||
namespace ZafiraIntegration.Config | ||
{ | ||
public static class Configuration | ||
internal static class Configuration | ||
{ | ||
private static readonly List<IConfigurationProvider> ConfigurationProviders = new List<IConfigurationProvider> | ||
{ | ||
new EnvironmentVariablesConfigurationProvider() | ||
}; | ||
|
||
public static bool IsReportingEnabled() | ||
internal static bool IsReportingEnabled() | ||
{ | ||
return ConfigurationProviders | ||
.Select(provider => provider.IsReportingEnabled()) | ||
.First(isReportingEnabled => isReportingEnabled); | ||
.FirstOrDefault(isReportingEnabled => isReportingEnabled); | ||
} | ||
|
||
public static string GetServerHost() | ||
internal static string GetServerHost() | ||
{ | ||
return ConfigurationProviders | ||
.Select(provider => provider.GetServerHost()) | ||
.First(serverHost => serverHost != null && serverHost.Trim().Length != 0); | ||
return GetStringProperty(provider => provider.GetServerHost()); | ||
} | ||
|
||
public static string GetAccessToken() | ||
internal static string GetAccessToken() | ||
{ | ||
return ConfigurationProviders | ||
.Select(provider => provider.GetAccessToken()) | ||
.First(accessToken => accessToken != null && accessToken.Trim().Length != 0); | ||
return GetStringProperty(provider => provider.GetAccessToken()); | ||
} | ||
|
||
internal static string GetProjectKey() | ||
{ | ||
return GetStringProperty(provider => provider.GetProjectKey()); | ||
} | ||
|
||
internal static string GetEnvironment() | ||
{ | ||
return GetStringProperty(provider => provider.GetEnvironment()); | ||
} | ||
|
||
internal static string GetBuild() | ||
{ | ||
return GetStringProperty(provider => provider.GetBuild()); | ||
} | ||
|
||
public static string GetProjectKey() | ||
private static string GetStringProperty(Func<IConfigurationProvider, string> propertyResolver) | ||
{ | ||
return ConfigurationProviders | ||
.Select(provider => provider.GetProjectKey()) | ||
.First(projectKey => projectKey != null && projectKey.Trim().Length != 0); | ||
.Select(propertyResolver) | ||
.FirstOrDefault(property => property != null && property.Trim().Length != 0); | ||
} | ||
} | ||
} |
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
56 changes: 56 additions & 0 deletions
56
Config/Provider/EnvironmentVariablesConfigurationProvider.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,56 @@ | ||
using System; | ||
|
||
namespace ZafiraIntegration.Config.Provider | ||
{ | ||
internal class EnvironmentVariablesConfigurationProvider : IConfigurationProvider | ||
{ | ||
private const string ReportingEnabledLegacyEnvironmentVariable = "zafira_enabled"; | ||
private const string ReportingEnabledEnvironmentVariable = "REPORTING_ENABLED"; | ||
private const string ServerHostLegacyEnvironmentVariable = "zafira_service_url"; | ||
private const string ServerHostEnvironmentVariable = "REPORTING_SERVER_HOSTNAME"; | ||
private const string AccessTokenLegacyEnvironmentVariable = "zafira_access_token"; | ||
private const string AccessTokenEnvironmentVariable = "REPORTING_SERVER_ACCESS_TOKEN"; | ||
private const string ProjectKeyLegacyEnvironmentVariable = "zafira_project"; | ||
private const string ProjectKeyEnvironmentVariable = "REPORTING_PROJECT_KEY"; | ||
private const string EnvironmentEnvironmentVariable = "REPORTING_RUN_ENVIRONMENT"; | ||
private const string BuildEnvironmentVariable = "REPORTING_RUN_BUILD"; | ||
|
||
private const string DefaultProjectKey = "UNKNOWN"; | ||
|
||
public bool IsReportingEnabled() | ||
{ | ||
var reportingEnabled = Environment.GetEnvironmentVariable(ReportingEnabledLegacyEnvironmentVariable) | ||
?? Environment.GetEnvironmentVariable(ReportingEnabledEnvironmentVariable); | ||
return string.Compare("true", reportingEnabled, StringComparison.OrdinalIgnoreCase) == 0; | ||
} | ||
|
||
public string GetServerHost() | ||
{ | ||
return Environment.GetEnvironmentVariable(ServerHostLegacyEnvironmentVariable) | ||
?? Environment.GetEnvironmentVariable(ServerHostEnvironmentVariable); | ||
} | ||
|
||
public string GetAccessToken() | ||
{ | ||
return Environment.GetEnvironmentVariable(AccessTokenLegacyEnvironmentVariable) | ||
?? Environment.GetEnvironmentVariable(AccessTokenEnvironmentVariable); | ||
} | ||
|
||
public string GetProjectKey() | ||
{ | ||
return Environment.GetEnvironmentVariable(ProjectKeyLegacyEnvironmentVariable) | ||
?? Environment.GetEnvironmentVariable(ProjectKeyEnvironmentVariable) | ||
?? DefaultProjectKey; | ||
} | ||
|
||
public string GetEnvironment() | ||
{ | ||
return Environment.GetEnvironmentVariable(EnvironmentEnvironmentVariable); | ||
} | ||
|
||
public string GetBuild() | ||
{ | ||
return Environment.GetEnvironmentVariable(BuildEnvironmentVariable); | ||
} | ||
} | ||
} |
36 changes: 0 additions & 36 deletions
36
Config/provider/EnvironmentVariablesConfigurationProvider.cs
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.