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

fix(headers): also populate headers from specified environment variables #99

Merged
merged 5 commits into from
Feb 6, 2024

Conversation

smoyer64
Copy link
Contributor

Headers can't be set via the environment variables specified in the OTEL SDK configuration documentation. Since headers are often used to affect authentication, using the provided options isn't always desirable or safe.

Which problem is this PR solving?

Short description of the changes

This PR adds the required field tags to the Config struct and documents the existing options as well as the affected environment variables.

How to verify that this has the expected result

Set headers via environment variables and verify that the headers are received by an OTEL collector.

@smoyer64 smoyer64 requested a review from a team as a code owner December 29, 2023 15:20
@smoyer64 smoyer64 changed the title Fix/empty headers fix(headers): also populate headers from specified environment variables Dec 29, 2023
@JamieDanielson JamieDanielson added the status: oncall Flagged for awareness from Honeycomb Telemetry Oncall label Jan 2, 2024
@JamieDanielson
Copy link
Contributor

Thanks for this @smoyer64 ! Great catch. Would you be willing to also update the tests to test for these environment variables, testing for both single- and multi- headers?

@JamieDanielson JamieDanielson added status: revision needed Waiting for response to changes requested. and removed status: oncall Flagged for awareness from Honeycomb Telemetry Oncall labels Jan 10, 2024
Copy link
Contributor

@JamieDanielson JamieDanielson left a comment

Choose a reason for hiding this comment

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

As per the comment, would you be open to updating the tests as well? Thanks!

@MikeGoldsmith MikeGoldsmith added the type: enhancement New feature or request label Feb 6, 2024
@MikeGoldsmith MikeGoldsmith self-assigned this Feb 6, 2024
@MikeGoldsmith MikeGoldsmith added version: bump minor A PR that adds behavior, but is backwards-compatible. and removed status: revision needed Waiting for response to changes requested. labels Feb 6, 2024
Copy link
Contributor

@MikeGoldsmith MikeGoldsmith left a comment

Choose a reason for hiding this comment

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

Taking this as is and will add tests separately.

@MikeGoldsmith MikeGoldsmith dismissed JamieDanielson’s stale review February 6, 2024 14:16

Will add tests separately

@MikeGoldsmith MikeGoldsmith merged commit 1cfcae8 into honeycombio:main Feb 6, 2024
4 of 5 checks passed
@smoyer64
Copy link
Contributor Author

smoyer64 commented Feb 6, 2024

Sorry about that ... was slammed at work throughout January!

MikeGoldsmith added a commit that referenced this pull request Mar 1, 2024
## Which problem is this PR solving?
When setting configuration values by code and environment variables,
environment variables should win. This is a design choice so that
operators of the library can change behaviour without requiring
rebuilding an application. This PR updates the sequence of applying
configuration options so that env vars are applied last and will replace
any code specificied options.

Tests are updated to reflect this, and includes adding additional tests
to verify expected behaviour of setting generic, trace and metrics
headers via env var which was added in the following P;
- Follow up to #99 

## Short description of the changes
- Updates all string config options to use the `overwrite` go-envconfig
option so env var values replace code-set options
- Remove unused ResourceAttributesFromEnv config option
- Move applying env var options to the config struct after applying code
options
- Update tests to reflect env vars have priority over code-provided
options, includes fixing a couple of tests where env vars were being
used by error

## How to verify that this has the expected result
Unit tests exercise expected behaviour and help prevent future
regressions.

---------

Co-authored-by: Steve Moyer <[email protected]>
Co-authored-by: Robb Kidd <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement New feature or request version: bump minor A PR that adds behavior, but is backwards-compatible.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Headers can't be set via environment variables
3 participants