diff --git a/src/Elastic.Apm/Logging/GlobalLogConfiguration.cs b/src/Elastic.Apm/Logging/GlobalLogConfiguration.cs index 4ffcda2fb..d5f81f135 100644 --- a/src/Elastic.Apm/Logging/GlobalLogConfiguration.cs +++ b/src/Elastic.Apm/Logging/GlobalLogConfiguration.cs @@ -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); @@ -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); diff --git a/test/Elastic.Apm.Tests/Config/GlobalLogConfigurationPrecedenceTests.cs b/test/Elastic.Apm.Tests/Config/GlobalLogConfigurationPrecedenceTests.cs index 96121d8da..75c0db47d 100644 --- a/test/Elastic.Apm.Tests/Config/GlobalLogConfigurationPrecedenceTests.cs +++ b/test/Elastic.Apm.Tests/Config/GlobalLogConfigurationPrecedenceTests.cs @@ -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"), ]); @@ -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)), diff --git a/test/Elastic.Apm.Tests/Config/GlobalLogConfigurationTests.cs b/test/Elastic.Apm.Tests/Config/GlobalLogConfigurationTests.cs index 2c6495a1c..7b9b34222 100644 --- a/test/Elastic.Apm.Tests/Config/GlobalLogConfigurationTests.cs +++ b/test/Elastic.Apm.Tests/Config/GlobalLogConfigurationTests.cs @@ -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")] @@ -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")] @@ -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(); @@ -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) @@ -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) @@ -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) @@ -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) diff --git a/test/profiler/Elastic.Apm.Profiler.Managed.Tests/ProfiledApplication.cs b/test/profiler/Elastic.Apm.Profiler.Managed.Tests/ProfiledApplication.cs index aa1194c8a..d4b98a126 100644 --- a/test/profiler/Elastic.Apm.Profiler.Managed.Tests/ProfiledApplication.cs +++ b/test/profiler/Elastic.Apm.Profiler.Managed.Tests/ProfiledApplication.cs @@ -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";