habitat-sh / habitat

Modern applications with built-in automation
https://www.habitat.sh
Apache License 2.0
2.6k stars 314 forks source link

Cache EnvConfig-mediated values #6061

Open christophermaier opened 5 years ago

christophermaier commented 5 years ago

Any configuration variables controlled by our EnvConfig abstraction emit log messages whenever they are overridden by their "undocumented" environment variables. This is very useful to provide visibility whenever something is changed from its default state. However, for values that may be used frequently (such as the recently-added HAB_RUMOR_SHARE_LIMIT in #6032), we emit the log message repeatedly. Depending on how frequently the variable value in question is accessed, this could generate very noisy logs.

Exhibit A:

[2019-01-16T00:02:57Z WARN  habitat_common::types::env_config] Found 'HAB_RUMOR_SHARE_LIMIT' in environment; using value '1'
[2019-01-16T00:02:57Z WARN  habitat_common::types::env_config] Found 'HAB_RUMOR_SHARE_LIMIT' in environment; using value '1'
[2019-01-16T00:02:57Z WARN  habitat_common::types::env_config] Found 'HAB_RUMOR_SHARE_LIMIT' in environment; using value '1'
[2019-01-16T00:02:57Z WARN  habitat_common::types::env_config] Found 'HAB_RUMOR_SHARE_LIMIT' in environment; using value '1'
[2019-01-16T00:02:57Z WARN  habitat_common::types::env_config] Found 'HAB_RUMOR_SHARE_LIMIT' in environment; using value '1'
[2019-01-16T00:02:57Z WARN  habitat_common::types::env_config] Found 'HAB_RUMOR_SHARE_LIMIT' in environment; using value '1'
[2019-01-16T00:02:57Z WARN  habitat_common::types::env_config] Found 'HAB_RUMOR_SHARE_LIMIT' in environment; using value '1'
[2019-01-16T00:02:57Z WARN  habitat_common::types::env_config] Found 'HAB_RUMOR_SHARE_LIMIT' in environment; using value '1'
[2019-01-16T00:02:57Z WARN  habitat_common::types::env_config] Found 'HAB_RUMOR_SHARE_LIMIT' in environment; using value '1'
[2019-01-16T00:02:57Z WARN  habitat_common::types::env_config] Found 'HAB_RUMOR_SHARE_LIMIT' in environment; using value '1'
[2019-01-16T00:02:57Z WARN  habitat_common::types::env_config] Found 'HAB_RUMOR_SHARE_LIMIT' in environment; using value '1'
[2019-01-16T00:02:57Z WARN  habitat_common::types::env_config] Found 'HAB_RUMOR_SHARE_LIMIT' in environment; using value '1'
[2019-01-16T00:02:57Z WARN  habitat_common::types::env_config] Found 'HAB_RUMOR_SHARE_LIMIT' in environment; using value '1'
[2019-01-16T00:02:57Z WARN  habitat_common::types::env_config] Found 'HAB_RUMOR_SHARE_LIMIT' in environment; using value '1'
[2019-01-16T00:02:57Z WARN  habitat_common::types::env_config] Found 'HAB_RUMOR_SHARE_LIMIT' in environment; using value '1'
[2019-01-16T00:02:57Z WARN  habitat_common::types::env_config] Found 'HAB_RUMOR_SHARE_LIMIT' in environment; using value '1'

Since environment variables don't change, it would be useful to perform the variable check once, and use that value thereafter. We could implement this specifically for our HAB_RUMOR_SHARE_LIMIT, but it would be nice to have a more generic implementation, since I'm sure we'll add other variables in the future that are accessed at least as frequently.

stale[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. We value your input and contribution. Please leave a comment if this issue still affects you.

stale[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. We value your input and contribution. Please leave a comment if this issue still affects you.