Skip to content

Commit

Permalink
start rename to OTEL_* variables
Browse files Browse the repository at this point in the history
  • Loading branch information
Mpdreamz committed Jul 16, 2024
1 parent 2cc27fa commit 05bd107
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 17 deletions.
8 changes: 4 additions & 4 deletions src/Elastic.Apm/Logging/GlobalLogConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,8 @@ internal enum GlobalLogTarget
public static class LogEnvironmentVariables
{
// ReSharper disable once InconsistentNaming
public const string ELASTIC_OTEL_LOG_LEVEL = nameof(ELASTIC_OTEL_LOG_LEVEL);
public const string ELASTIC_OTEL_LOG_DIRECTORY = nameof(ELASTIC_OTEL_LOG_DIRECTORY);
public const string OTEL_LOG_LEVEL = nameof(OTEL_LOG_LEVEL);
public const string OTEL_DOTNET_AUTO_LOG_DIRECTORY = nameof(OTEL_DOTNET_AUTO_LOG_DIRECTORY);
public const string ELASTIC_OTEL_LOG_TARGETS = nameof(ELASTIC_OTEL_LOG_TARGETS);

public const string ELASTIC_APM_LOG_LEVEL = nameof(ELASTIC_APM_LOG_LEVEL);
Expand Down Expand Up @@ -159,8 +159,8 @@ private GlobalLogConfiguration(bool isActive, LogLevel logLevel, GlobalLogTarget
internal static GlobalLogConfiguration FromEnvironment(IDictionary environmentVariables = null)
{
var config = new EnvironmentLoggingConfiguration(environmentVariables);
var logLevel = config.GetLogLevel(ELASTIC_OTEL_LOG_LEVEL, ELASTIC_APM_PROFILER_LOG, ELASTIC_APM_LOG_LEVEL);
var logFileDirectory = config.GetLogDirectory(ELASTIC_OTEL_LOG_DIRECTORY, ELASTIC_APM_PROFILER_LOG_DIR, ELASTIC_APM_LOG_DIRECTORY);
var logLevel = config.GetLogLevel(OTEL_LOG_LEVEL, ELASTIC_APM_PROFILER_LOG, ELASTIC_APM_LOG_LEVEL);
var logFileDirectory = config.GetLogDirectory(OTEL_DOTNET_AUTO_LOG_DIRECTORY, ELASTIC_APM_PROFILER_LOG_DIR, ELASTIC_APM_LOG_DIRECTORY);
var logFilePrefix = GetLogFilePrefix();
var logTarget = config.ParseLogTargets(ELASTIC_OTEL_LOG_TARGETS, ELASTIC_APM_PROFILER_LOG_TARGETS);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public class GlobalLogConfigurationPrecedenceTests
public void CheckLogLevelPrecedence()
{
var config = CreateConfig([
(ELASTIC_OTEL_LOG_LEVEL, "trace"),
(OTEL_LOG_LEVEL, "trace"),
(ELASTIC_APM_PROFILER_LOG, "info"),
(ELASTIC_APM_LOG_LEVEL, "error"),
]);
Expand All @@ -38,11 +38,11 @@ public void CheckLogLevelPrecedence()
public void CheckLogDirPrecedence()
{
var config = CreateConfig([
(ELASTIC_OTEL_LOG_DIRECTORY, nameof(ELASTIC_OTEL_LOG_DIRECTORY)),
(OTEL_DOTNET_AUTO_LOG_DIRECTORY, nameof(OTEL_DOTNET_AUTO_LOG_DIRECTORY)),
(ELASTIC_APM_PROFILER_LOG_DIR, nameof(ELASTIC_APM_PROFILER_LOG_DIR)),
(ELASTIC_APM_LOG_DIRECTORY, nameof(ELASTIC_APM_LOG_DIRECTORY)),
]);
config.LogFileDirectory.Should().Be(nameof(ELASTIC_OTEL_LOG_DIRECTORY));
config.LogFileDirectory.Should().Be(nameof(OTEL_DOTNET_AUTO_LOG_DIRECTORY));

config = CreateConfig([
(ELASTIC_APM_PROFILER_LOG_DIR, nameof(ELASTIC_APM_PROFILER_LOG_DIR)),
Expand Down
16 changes: 8 additions & 8 deletions test/Elastic.Apm.Tests/Config/GlobalLogConfigurationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ public void Check_Defaults()

//
[Theory]
[InlineData(ELASTIC_OTEL_LOG_LEVEL, "Info")]
[InlineData(OTEL_LOG_LEVEL, "Info")]
[InlineData(ELASTIC_APM_PROFILER_LOG, "Info")]

[InlineData(ELASTIC_OTEL_LOG_DIRECTORY, "1")]
[InlineData(OTEL_DOTNET_AUTO_LOG_DIRECTORY, "1")]
[InlineData(ELASTIC_APM_LOG_DIRECTORY, "1")]
[InlineData(ELASTIC_APM_PROFILER_LOG_DIR, "1")]
[InlineData(ELASTIC_APM_STARTUP_HOOKS_LOGGING, "1")]
Expand All @@ -47,7 +47,7 @@ public void CheckActivation(string environmentVariable, string value)

//
[Theory]
[InlineData(ELASTIC_OTEL_LOG_LEVEL, "none")]
[InlineData(OTEL_LOG_LEVEL, "none")]
[InlineData(ELASTIC_APM_PROFILER_LOG, "None")]
//only if explicitly specified to 'none' should we not default to file logging.
[InlineData(ELASTIC_OTEL_LOG_TARGETS, "none")]
Expand All @@ -56,7 +56,7 @@ public void CheckDeactivation(string environmentVariable, string value)
{
var config = GlobalLogConfiguration.FromEnvironment(new Hashtable
{
{ ELASTIC_OTEL_LOG_DIRECTORY, "" },
{ OTEL_DOTNET_AUTO_LOG_DIRECTORY, "" },
{ environmentVariable, value }
});
config.IsActive.Should().BeFalse();
Expand All @@ -70,7 +70,7 @@ public void CheckDeactivation(string environmentVariable, string value)
[InlineData(ELASTIC_OTEL_LOG_TARGETS, "None")]
[InlineData(ELASTIC_APM_PROFILER_LOG_TARGETS, "None")]
//setting file log level to none will result in no global trace logging
[InlineData(ELASTIC_OTEL_LOG_LEVEL, "None")]
[InlineData(OTEL_LOG_LEVEL, "None")]
//setting profiler log level to none will result in no global trace logging
[InlineData(ELASTIC_APM_PROFILER_LOG, "None")]
public void CheckNonActivation(string environmentVariable, string value)
Expand All @@ -92,7 +92,7 @@ public void Check_LogLevelValues_AreMappedCorrectly(string envVarValue, LogLevel
{
Check(ELASTIC_APM_PROFILER_LOG, envVarValue, logLevel);
Check(ELASTIC_APM_LOG_LEVEL, envVarValue, logLevel);
Check(ELASTIC_OTEL_LOG_LEVEL, envVarValue, logLevel);
Check(OTEL_LOG_LEVEL, envVarValue, logLevel);
return;

static void Check(string key, string envVarValue, LogLevel level)
Expand All @@ -111,7 +111,7 @@ public void Check_InvalidLogLevelValues_AreMappedToDefaultWarn(string envVarValu
{
Check(ELASTIC_APM_PROFILER_LOG, envVarValue);
Check(ELASTIC_APM_LOG_LEVEL, envVarValue);
Check(ELASTIC_OTEL_LOG_LEVEL, envVarValue);
Check(OTEL_LOG_LEVEL, envVarValue);
return;

static void Check(string key, string envVarValue)
Expand All @@ -126,7 +126,7 @@ public void Check_LogDir_IsEvaluatedCorrectly()
{
Check(ELASTIC_APM_PROFILER_LOG_DIR, "/foo/bar");
Check(ELASTIC_APM_LOG_DIRECTORY, "/foo/bar");
Check(ELASTIC_OTEL_LOG_DIRECTORY, "/foo/bar");
Check(OTEL_DOTNET_AUTO_LOG_DIRECTORY, "/foo/bar");
return;

static void Check(string key, string envVarValue)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,9 @@ public void Start(
environmentVariables["ELASTIC_APM_PROFILER_INTEGRATIONS"] =
Path.Combine(SolutionPaths.Root, "src", "profiler", "Elastic.Apm.Profiler.Managed", "integrations.yml");

environmentVariables[ELASTIC_OTEL_LOG_LEVEL] = "trace";
environmentVariables[OTEL_LOG_LEVEL] = "trace";
// log to relative logs directory for managed loader
environmentVariables[ELASTIC_OTEL_LOG_DIRECTORY] = Path.Combine(SolutionPaths.Root, "logs");
environmentVariables[OTEL_DOTNET_AUTO_LOG_DIRECTORY] = Path.Combine(SolutionPaths.Root, "logs");

environmentVariables[ELASTIC_OTEL_LOG_TARGETS] = "file;stdout";
//environmentVariables["ELASTIC_APM_PROFILER_LOG_IL"] = "true";
Expand Down

0 comments on commit 05bd107

Please sign in to comment.