-
Notifications
You must be signed in to change notification settings - Fork 92
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: allow config bools to default to true #969
Changes from all commits
e1b3ccd
107265e
b62be6d
c33b520
888f668
dc44554
35f4f89
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -89,10 +89,10 @@ type AccessKeyConfig struct { | |
} | ||
|
||
type RefineryTelemetryConfig struct { | ||
AddRuleReasonToTrace bool `yaml:"AddRuleReasonToTrace"` | ||
AddSpanCountToRoot bool `yaml:"AddSpanCountToRoot" default:"true"` | ||
AddCountsToRoot bool `yaml:"AddCountsToRoot"` | ||
AddHostMetadataToTrace bool `yaml:"AddHostMetadataToTrace" default:"true"` | ||
AddRuleReasonToTrace bool `yaml:"AddRuleReasonToTrace"` | ||
AddSpanCountToRoot *bool `yaml:"AddSpanCountToRoot" default:"true"` // Avoid pointer woe on access, use GetAddSpanCountToRoot() instead. | ||
AddCountsToRoot bool `yaml:"AddCountsToRoot"` | ||
AddHostMetadataToTrace *bool `yaml:"AddHostMetadataToTrace" default:"true"` // Avoid pointer woe on access, use GetAddHostMetadataToTrace() instead. | ||
} | ||
|
||
type TracesConfig struct { | ||
|
@@ -119,10 +119,21 @@ type HoneycombLoggerConfig struct { | |
APIHost string `yaml:"APIHost" default:"https://api.honeycomb.io"` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not in scope for this PR, but accessor functions for all fields on There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I struggle with this; every accessor adds one form of tech debt to save another form of tech debt. In particular, when I broke up the config into subsections, I deliberately did not add accessors for everything. I don't feel strongly against it, I just wish there was a better way (JS/java properties would be nice but Go doesn't give us those). |
||
APIKey string `yaml:"APIKey" cmdenv:"HoneycombLoggerAPIKey,HoneycombAPIKey"` | ||
Dataset string `yaml:"Dataset" default:"Refinery Logs"` | ||
SamplerEnabled bool `yaml:"SamplerEnabled" default:"true"` | ||
SamplerEnabled *bool `yaml:"SamplerEnabled" default:"true"` // Avoid pointer woe on access, use GetSamplerEnabled() instead. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I tossed this comment on the field so that it would be shown by IDEs that do the hover box thing. Like a 🤔 ... which I suppose is a comment that could be added to all the new There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add this comment to all the |
||
SamplerThroughput int `yaml:"SamplerThroughput" default:"10"` | ||
} | ||
|
||
// GetSamplerEnabled returns whether configuration has enabled sampling of | ||
// Refinery's own logs destined for Honeycomb. | ||
func (c *HoneycombLoggerConfig) GetSamplerEnabled() (enabled bool) { | ||
if c.SamplerEnabled == nil { | ||
enabled = true | ||
} else { | ||
enabled = *c.SamplerEnabled | ||
} | ||
return enabled | ||
} | ||
|
||
type StdoutLoggerConfig struct { | ||
Structured bool `yaml:"Structured" default:"false"` | ||
SamplerEnabled bool `yaml:"SamplerEnabled" ` | ||
|
@@ -217,7 +228,7 @@ type BufferSizeConfig struct { | |
|
||
type SpecializedConfig struct { | ||
EnvironmentCacheTTL Duration `yaml:"EnvironmentCacheTTL" default:"1h"` | ||
CompressPeerCommunication bool `yaml:"CompressPeerCommunication" default:"true"` | ||
CompressPeerCommunication *bool `yaml:"CompressPeerCommunication" default:"true"` // Avoid pointer woe on access, use GetCompressPeerCommunication() instead. | ||
AdditionalAttributes map[string]string `yaml:"AdditionalAttributes" default:"{}"` | ||
} | ||
|
||
|
@@ -230,7 +241,7 @@ type IDFieldsConfig struct { | |
// by refinery's own GRPC server: | ||
// https://pkg.go.dev/google.golang.org/grpc/keepalive#ServerParameters | ||
type GRPCServerParameters struct { | ||
Enabled bool `yaml:"Enabled" default:"true"` | ||
Enabled *bool `yaml:"Enabled" default:"true"` // Avoid pointer woe on access, use GetGRPCEnabled() instead. | ||
ListenAddr string `yaml:"ListenAddr" cmdenv:"GRPCListenAddr"` | ||
MaxConnectionIdle Duration `yaml:"MaxConnectionIdle" default:"1m"` | ||
MaxConnectionAge Duration `yaml:"MaxConnectionAge" default:"3m"` | ||
|
@@ -477,13 +488,28 @@ func (f *fileConfig) GetCompressPeerCommunication() bool { | |
f.mux.RLock() | ||
defer f.mux.RUnlock() | ||
|
||
return f.mainConfig.Specialized.CompressPeerCommunication | ||
var compressPeerCommunication bool | ||
if f.mainConfig.Specialized.CompressPeerCommunication == nil { | ||
compressPeerCommunication = true | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These true values are hardcoded, but we should try and lookup these values from the struct tag. That will require us to use the reflect package mimicking some behavior from the defaults package. Is this something that we want in the scope of this fix? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure I'm happy with the hardcoded There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @robbkidd suggested that we either add some code to the validate function to check for struct tag type and value. Or perhaps there is a test that we can add later on to validate any changes to struct tags. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Instead of reading the tags, we talked about something like:
That would give us the hook to do some more useful linting or other work to make sure that we keep the contract for those types. |
||
} else { | ||
compressPeerCommunication = *f.mainConfig.Specialized.CompressPeerCommunication | ||
} | ||
|
||
return compressPeerCommunication | ||
} | ||
|
||
func (f *fileConfig) GetGRPCEnabled() bool { | ||
f.mux.RLock() | ||
defer f.mux.RUnlock() | ||
return f.mainConfig.GRPCServerParameters.Enabled | ||
|
||
var enabled bool | ||
if f.mainConfig.GRPCServerParameters.Enabled == nil { | ||
enabled = true | ||
} else { | ||
enabled = *f.mainConfig.GRPCServerParameters.Enabled | ||
} | ||
|
||
return enabled | ||
} | ||
|
||
func (f *fileConfig) GetGRPCListenAddr() (string, error) { | ||
|
@@ -785,7 +811,15 @@ func (f *fileConfig) GetAddHostMetadataToTrace() bool { | |
f.mux.RLock() | ||
defer f.mux.RUnlock() | ||
|
||
return f.mainConfig.Telemetry.AddHostMetadataToTrace | ||
var addHostMetadataToTrace bool | ||
|
||
if f.mainConfig.Telemetry.AddHostMetadataToTrace == nil { | ||
addHostMetadataToTrace = true // TODO: the default, but maybe look that up on the struct? | ||
} else { | ||
addHostMetadataToTrace = *f.mainConfig.Telemetry.AddHostMetadataToTrace | ||
} | ||
|
||
return addHostMetadataToTrace | ||
} | ||
|
||
func (f *fileConfig) GetAddRuleReasonToTrace() bool { | ||
|
@@ -834,7 +868,15 @@ func (f *fileConfig) GetAddSpanCountToRoot() bool { | |
f.mux.RLock() | ||
defer f.mux.RUnlock() | ||
|
||
return f.mainConfig.Telemetry.AddSpanCountToRoot | ||
var addSpanCountToRoot bool | ||
|
||
if f.mainConfig.Telemetry.AddSpanCountToRoot == nil { | ||
addSpanCountToRoot = true // TODO: lookup default from struct | ||
} else { | ||
addSpanCountToRoot = *f.mainConfig.Telemetry.AddSpanCountToRoot | ||
} | ||
|
||
return addSpanCountToRoot | ||
} | ||
|
||
func (f *fileConfig) GetAddCountsToRoot() bool { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"RulesVersion":2,"Samplers":{"__default__":{"DeterministicSampler":{"SampleRate":1}},"TheNewWorld":{"EMADynamicSampler":{"GoalSampleRate":6,"AdjustmentInterval":"2s","Weight":0.5,"AgeOutValue":0.5,"BurstMultiple":200,"BurstDetectionDelay":30,"FieldList":["error","url","status"],"UseTraceLength":false,"MaxKeys":2000}}}} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added in the first commit of this PR, demonstrate the 5 bools that default to true don't. Not sure if we keep this test long-term.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's just add a comment to this explaining why it exists.