Skip to content

Commit

Permalink
remove _FILE_ from environment variables
Browse files Browse the repository at this point in the history
  • Loading branch information
Mpdreamz committed Jun 4, 2024
1 parent fc63730 commit 617ccc5
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 27 deletions.
4 changes: 2 additions & 2 deletions docs/setup-auto-instrumentation.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ A semi-colon separated list of APM service names to exclude from auto-instrument
Values defined are checked against the value of <<config-service-name,`ELASTIC_APM_SERVICE_NAME`>>
environment variable.

`ELASTIC_OTEL_FILE_LOG_LEVEL` _(optional)_::
`ELASTIC_OTEL_LOG_LEVEL` _(optional)_::

The log level at which the profiler should log. Valid values are

Expand All @@ -413,7 +413,7 @@ _only_ for diagnostics purposes.
This takes precedence over the now deprecated `ELASTIC_APM_PROFILER_LOG`


`ELASTIC_OTEL_FILE_LOG_DIRECTORY` _(optional)_::
`ELASTIC_OTEL_LOG_DIRECTORY` _(optional)_::

The directory in which to write profiler log files. If unset, defaults to

Expand Down
4 changes: 2 additions & 2 deletions docs/troubleshooting.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ The easiest way to get debug information from the Agent, regardless of the way i

Specifying at least one of the following environment variables will ensure the agent logs to a file

`ELASTIC_OTEL_FILE_LOG_LEVEL` _(optional)_::
`ELASTIC_OTEL_LOG_LEVEL` _(optional)_::

The log level at which the profiler should log. Valid values are

Expand All @@ -56,7 +56,7 @@ The default value is `warn`. More verbose log levels like `trace` and `debug` ca
affect the runtime performance of profiler auto instrumentation, so are recommended
_only_ for diagnostics purposes.

`ELASTIC_OTEL_FILE_LOG_DIRECTORY` _(optional)_::
`ELASTIC_OTEL_LOG_DIRECTORY` _(optional)_::

The directory in which to write profiler log files. If unset, defaults to

Expand Down
14 changes: 7 additions & 7 deletions src/Elastic.Apm/Logging/GlobalLogConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -114,15 +114,15 @@ internal enum GlobalLogTarget
public static class LogEnvironmentVariables
{
// ReSharper disable once InconsistentNaming
public const string ELASTIC_OTEL_FILE_LOG_LEVEL = nameof(ELASTIC_OTEL_FILE_LOG_LEVEL);
public const string ELASTIC_OTEL_FILE_LOG_DIRECTORY = nameof(ELASTIC_OTEL_FILE_LOG_DIRECTORY);
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 ELASTIC_OTEL_LOG_TARGETS = nameof(ELASTIC_OTEL_LOG_TARGETS);

public const string ELASTIC_APM_LOG_LEVEL = nameof(ELASTIC_APM_LOG_LEVEL);
public const string ELASTIC_APM_LOG_DIRECTORY = nameof(ELASTIC_APM_LOG_DIRECTORY);


// profiler logs are deprecated in favor of ELASTIC_OTEL_FILE_*
// profiler logs are deprecated in favor of ELASTIC_OTEL_*
public const string ELASTIC_APM_PROFILER_LOG = nameof(ELASTIC_APM_PROFILER_LOG);
public const string ELASTIC_APM_PROFILER_LOG_DIR = nameof(ELASTIC_APM_PROFILER_LOG_DIR);
public const string ELASTIC_APM_PROFILER_LOG_TARGETS = nameof(ELASTIC_APM_PROFILER_LOG_TARGETS);
Expand Down Expand Up @@ -159,14 +159,14 @@ 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_FILE_LOG_LEVEL, ELASTIC_APM_PROFILER_LOG, ELASTIC_APM_LOG_LEVEL);
var logFileDirectory = config.GetLogFilePath(ELASTIC_OTEL_FILE_LOG_DIRECTORY, ELASTIC_APM_PROFILER_LOG_DIR, ELASTIC_APM_LOG_DIRECTORY);
var logLevel = config.GetLogLevel(ELASTIC_OTEL_LOG_LEVEL, ELASTIC_APM_PROFILER_LOG, ELASTIC_APM_LOG_LEVEL);
var logFileDirectory = config.GetLogFilePath(ELASTIC_OTEL_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);

var isActive = config.AnyConfigured(
ELASTIC_OTEL_FILE_LOG_LEVEL,
ELASTIC_OTEL_FILE_LOG_DIRECTORY,
ELASTIC_OTEL_LOG_LEVEL,
ELASTIC_OTEL_LOG_DIRECTORY,
ELASTIC_OTEL_LOG_TARGETS,
ELASTIC_APM_LOG_DIRECTORY,
ELASTIC_APM_PROFILER_LOG,
Expand Down
8 changes: 4 additions & 4 deletions src/profiler/elastic_apm_profiler/src/profiler/env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ const ELASTIC_OTEL_LOG_TARGETS_ENV_VAR: &str = "ELASTIC_OTEL_LOG_TARGETS";
const ELASTIC_APM_PROFILER_LOG_DIR_ENV_VAR: &str = "ELASTIC_APM_PROFILER_LOG_DIR";
const ELASTIC_APM_PROFILER_LOG_ENV_VAR: &str = "ELASTIC_APM_PROFILER_LOG";

const ELASTIC_OTEL_FILE_LOG_LEVEL_ENV_VAR: &str = "ELASTIC_OTEL_FILE_LOG_LEVEL";
const ELASTIC_OTEL_FILE_LOG_DIRECTORY_ENV_VAR: &str = "ELASTIC_OTEL_FILE_LOG_DIRECTORY";
const ELASTIC_OTEL_LOG_LEVEL_ENV_VAR: &str = "ELASTIC_OTEL_LOG_LEVEL";
const ELASTIC_OTEL_LOG_DIRECTORY_ENV_VAR: &str = "ELASTIC_OTEL_LOG_DIRECTORY";

const ELASTIC_APM_LOG_LEVEL_ENV_VAR: &str = "ELASTIC_APM_LOG_LEVEL";
const ELASTIC_APM_LOG_DIRECTORY_ENV_VAR: &str = "ELASTIC_APM_LOG_DIRECTORY";
Expand Down Expand Up @@ -207,7 +207,7 @@ fn read_log_targets_from_env_var() -> HashSet<String> {

pub fn read_log_level_from_env_var(default: LevelFilter) -> LevelFilter {
match (
std::env::var(ELASTIC_OTEL_FILE_LOG_LEVEL_ENV_VAR),
std::env::var(ELASTIC_OTEL_LOG_LEVEL_ENV_VAR),
std::env::var(ELASTIC_APM_PROFILER_LOG_ENV_VAR),
std::env::var(ELASTIC_APM_LOG_DIRECTORY_ENV_VAR)
) {
Expand Down Expand Up @@ -311,7 +311,7 @@ fn get_home_log_dir() -> PathBuf {

fn get_log_dir() -> PathBuf {
match (
std::env::var(ELASTIC_OTEL_FILE_LOG_DIRECTORY_ENV_VAR),
std::env::var(ELASTIC_OTEL_LOG_DIRECTORY_ENV_VAR),
std::env::var(ELASTIC_APM_PROFILER_LOG_DIR_ENV_VAR),
std::env::var(ELASTIC_APM_LOG_DIRECTORY_ENV_VAR),
) {
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_FILE_LOG_LEVEL, "trace"),
(ELASTIC_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_FILE_LOG_DIRECTORY, nameof(ELASTIC_OTEL_FILE_LOG_DIRECTORY)),
(ELASTIC_OTEL_LOG_DIRECTORY, nameof(ELASTIC_OTEL_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_FILE_LOG_DIRECTORY));
config.LogFileDirectory.Should().Be(nameof(ELASTIC_OTEL_LOG_DIRECTORY));

config = CreateConfig([
(ELASTIC_APM_PROFILER_LOG_DIR, nameof(ELASTIC_APM_PROFILER_LOG_DIR)),
Expand Down
14 changes: 7 additions & 7 deletions test/Elastic.Apm.Tests/Config/GlobalLogConfigurationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ public void Check_Defaults()
}
//
[Theory]
[InlineData(ELASTIC_OTEL_FILE_LOG_LEVEL, "Info")]
[InlineData(ELASTIC_OTEL_LOG_LEVEL, "Info")]
[InlineData(ELASTIC_APM_PROFILER_LOG, "Info")]
//only if explicitly specified to 'none' should we not default to file logging.
[InlineData(ELASTIC_OTEL_FILE_LOG_LEVEL, "BadEnumValue")]
[InlineData(ELASTIC_OTEL_LOG_LEVEL, "BadEnumValue")]
[InlineData(ELASTIC_APM_PROFILER_LOG, "BadEnumValue")]

[InlineData(ELASTIC_OTEL_FILE_LOG_DIRECTORY, "1")]
[InlineData(ELASTIC_OTEL_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 @@ -53,7 +53,7 @@ public void CheckActivation(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_FILE_LOG_LEVEL, "None")]
[InlineData(ELASTIC_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 @@ -75,7 +75,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_FILE_LOG_LEVEL, envVarValue, logLevel);
Check(ELASTIC_OTEL_LOG_LEVEL, envVarValue, logLevel);
return;

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

static void Check(string key, string envVarValue)
Expand All @@ -109,7 +109,7 @@ public void Check_LogDir_IsEvaluatedCorrectly()
{
Check(ELASTIC_APM_PROFILER_LOG_DIR, "/foo/bar");
Check(ELASTIC_APM_LOG_DIRECTORY, "/foo/bar");
Check(ELASTIC_OTEL_FILE_LOG_DIRECTORY, "/foo/bar");
Check(ELASTIC_OTEL_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_FILE_LOG_LEVEL] = "trace";
environmentVariables[ELASTIC_OTEL_LOG_LEVEL] = "trace";
// log to relative logs directory for managed loader
environmentVariables[ELASTIC_OTEL_FILE_LOG_DIRECTORY] = Path.Combine(SolutionPaths.Root, "logs");
environmentVariables[ELASTIC_OTEL_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 617ccc5

Please sign in to comment.