Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for metrics api key env var #535

Merged
merged 1 commit into from
Oct 4, 2022

Conversation

TylerHelmuth
Copy link
Contributor

Which problem is this PR solving?

Allows setting HoneycombMetrics.MetricsAPIKey with a specific environment variable.

Short description of the changes

  • Utilizes viper's BindEnv() function to handle env var precedence for HoneycombMetrics.MetricsAPIKey.
  • If REFINERY_HONEYCOMB_METRICS_API_KEY is set then it will be used. Otherwise REFINERY_HONEYCOMB_API_KEY will be used. As a result existing customer configs will not be affected.
  • Added new unit tests for this scenario.

@TylerHelmuth TylerHelmuth requested review from a team, JamieDanielson and kentquirk October 3, 2022 21:44
Copy link
Contributor

@kentquirk kentquirk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I love the thorough test cases.

@@ -119,7 +119,7 @@ func NewConfig(config, rules string, errorCallback func(error)) (Config, error)
c.BindEnv("PeerManagement.RedisUsername", "REFINERY_REDIS_USERNAME")
c.BindEnv("PeerManagement.RedisPassword", "REFINERY_REDIS_PASSWORD")
c.BindEnv("HoneycombLogger.LoggerAPIKey", "REFINERY_HONEYCOMB_API_KEY")
c.BindEnv("HoneycombMetrics.MetricsAPIKey", "REFINERY_HONEYCOMB_API_KEY")
c.BindEnv("HoneycombMetrics.MetricsAPIKey", "REFINERY_HONEYCOMB_METRICS_API_KEY", "REFINERY_HONEYCOMB_API_KEY")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dang, today I learned that BindEnv takes multiple arguments. Now I need to go look at other uses.

@TylerHelmuth TylerHelmuth merged commit dd34d72 into main Oct 4, 2022
@TylerHelmuth TylerHelmuth deleted the tyler/configure-metrics-key branch October 4, 2022 14:56
@TylerHelmuth TylerHelmuth added the version: bump patch A PR with release-worthy changes and is backwards-compatible. label Oct 4, 2022
ghost pushed a commit to opsramp/tracing-proxy that referenced this pull request Jul 5, 2024
## Which problem is this PR solving?

Allows setting `HoneycombMetrics.MetricsAPIKey` with a specific
environment variable.

- Fixes honeycombio#520

## Short description of the changes

- Utilizes viper's BindEnv() function to handle env var precedence for
`HoneycombMetrics.MetricsAPIKey`.
- If `REFINERY_HONEYCOMB_METRICS_API_KEY` is set then it will be used.
Otherwise `REFINERY_HONEYCOMB_API_KEY` will be used. As a result
existing customer configs will not be affected.
- Added new unit tests for this scenario.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
version: bump patch A PR with release-worthy changes and is backwards-compatible.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow configuration of metrics api key via environment variable
2 participants