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

Config bools that default to true require more work #970

Closed
1 of 3 tasks
fchikwekwe opened this issue Jan 19, 2024 · 2 comments · Fixed by #998
Closed
1 of 3 tasks

Config bools that default to true require more work #970

fchikwekwe opened this issue Jan 19, 2024 · 2 comments · Fixed by #998
Assignees
Labels
type: discussion Requests for comments, discussions about possible enhancements.
Milestone

Comments

@fchikwekwe
Copy link
Contributor

fchikwekwe commented Jan 19, 2024

In #954, we discovered that booleans that default to true were being overridden when applying default values. When boolean values are processed by the defaults library, there is not way to distinguish between a false that was intentionally set and a zero boolean value. This results in the default boolean value being used (true in this case) making it not possible for a boolean that defaults to true to be set to false.

We fixed this by setting a pointer to a boolean value so that there are three possible states for a boolean: true, false and nil. If we send a nil boolean to the defaults library it is properly interpreted as unset and can be updated to false.

There is some technical debt leftover from this fix:

  • add a getter function for HoneycombLoggerConfig.SamplerEnabled
  • add a default-true type in order to avoid hardcoding true values in getter functions for related fields.
  • use something (reflect?) to do struct tag lookups to find default values in the getter functions instead of declaring defaults in multiple places
@fchikwekwe fchikwekwe added the type: discussion Requests for comments, discussions about possible enhancements. label Jan 19, 2024
@fchikwekwe fchikwekwe added this to the v2.5 milestone Jan 19, 2024
@fchikwekwe
Copy link
Contributor Author

@robbkidd Already added the GetSamplerEnabled getter function in #969. I suggested in that PR that perhaps getter functions for the other fields on HoneycombLoggerConfig should be added as well.

@fchikwekwe
Copy link
Contributor Author

So, I did the work of trying to look up struct tags values using reflect in #996, but the consensus is that its wasteful to look up struct tags when we can instead put effort towards creating a defaultTrue type. I will try and work on adding that type.

@fchikwekwe fchikwekwe self-assigned this Feb 16, 2024
fchikwekwe added a commit that referenced this issue Feb 21, 2024
## Which problem is this PR solving?

- Closes #970 

## Short description of the changes

- adds a `DefaultTrue` type to use when specifying values with a default
of boolean `true` this improves some getter functions by abstracting
away the `*bool` behavior and allows boolean `true` be a true default
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: discussion Requests for comments, discussions about possible enhancements.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant