diff --git a/config/config.go b/config/config.go index 4c32853..84126cf 100644 --- a/config/config.go +++ b/config/config.go @@ -38,6 +38,8 @@ type Configuration struct { } func ConfigurationFromEnvironment() *Configuration { + nrEnabledStr, nrEnabledOverride := os.LookupEnv("NEW_RELIC_ENABLED") + nrEnabledRubyStr, nrEnabledRubyOverride := os.LookupEnv("NEW_RELIC_AGENT_ENABLED") enabledStr, extensionEnabledOverride := os.LookupEnv("NEW_RELIC_LAMBDA_EXTENSION_ENABLED") licenseKey, lkOverride := os.LookupEnv("NEW_RELIC_LICENSE_KEY") licenseKeySecretId, lkSecretOverride := os.LookupEnv("NEW_RELIC_LICENSE_KEY_SECRET") @@ -55,6 +57,12 @@ func ConfigurationFromEnvironment() *Configuration { collectTraceIDStr, collectTraceIDOverride := os.LookupEnv("NEW_RELIC_COLLECT_TRACE_ID") extensionEnabled := true + if nrEnabledOverride && strings.ToLower(nrEnabledStr) == "false" { + extensionEnabled = false + } + if nrEnabledRubyOverride && strings.ToLower(nrEnabledRubyStr) == "false" { + extensionEnabled = false + } if extensionEnabledOverride && strings.ToLower(enabledStr) == "false" { extensionEnabled = false } diff --git a/config/config_test.go b/config/config_test.go index 728edbf..63f6f51 100644 --- a/config/config_test.go +++ b/config/config_test.go @@ -75,6 +75,22 @@ func TestConfigurationFromEnvironment(t *testing.T) { assert.Equal(t, false, conf.LogsEnabled) } +func TestConfigurationFromEnvironmentNREnabled(t *testing.T) { + os.Setenv("NEW_RELIC_ENABLED", "false") + defer os.Unsetenv("NEW_RELIC_ENABLED") + + conf := ConfigurationFromEnvironment() + assert.Equal(t, conf.ExtensionEnabled, false) +} + +func TestConfigurationFromEnvironmentNRAgentEnabled(t *testing.T) { + os.Setenv("NEW_RELIC_AGENT_ENABLED", "false") + defer os.Unsetenv("NEW_RELIC_AGENT_ENABLED") + + conf := ConfigurationFromEnvironment() + assert.Equal(t, conf.ExtensionEnabled, false) +} + func TestConfigurationFromEnvironmentSecretId(t *testing.T) { os.Setenv("NEW_RELIC_LICENSE_KEY_SECRET", "secretId") defer os.Unsetenv("NEW_RELIC_LICENSE_KEY_SECRET")