-
Notifications
You must be signed in to change notification settings - Fork 236
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
Optionally disable tag parsing #325
Conversation
Signed-off-by: glightfoot <[email protected]>
Signed-off-by: glightfoot <[email protected]>
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.
Thank you (and sorry for the delay in review, work has been busy)! I am uneasy about globals that change behavior. What do you think about a "parser" struct with these that we can then use? Something like
import "github.com/prometheus/statsd_exporter/pkg/line"
p := line.NewParser(*dogstatsdTagsEnabled,*influxdbTagsEnabled,*libratoTagsEnabled,*signalFXTagsEnabled)
…
event := p.Parse(line)
Or, to avoid the "hmm which order do the booleans go" ambiguity, a builder pattern?
p := line.NewParser()
if !*dogstatsdTagsEnabled {
p.DisableDogstatsdTags()
}
or
p := line.NewParser()
p.EnableDogstatsdTags(*dogstatsdTagsEnabled)
I don't know for sure what the best "Go style" is.
Signed-off-by: glightfoot <[email protected]>
Yeah I had a feeling, but was lazy :-) I've changed it to use a struct for line parsing with option functions to enable tag parsing |
Signed-off-by: glightfoot <[email protected]>
Benchstat:
|
Signed-off-by: glightfoot <[email protected]>
8b8d054
to
c162b34
Compare
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.
This looks great, thank you very much and sorry for the delay in reviewing!
with changelog entries for #325 and #329. Signed-off-by: Matthias Rampke <[email protected]>
No worries! thanks for the help again |
This adds globals to the line package to allow disabling of individual tag parsing formats and unit tests for the line package. I don't love using package globals for this, but it does maintain backwards compatibility with the package, and is cleaner than adding four more parameters to the lineToEvents function. Open to other suggestions. Fixes #324
Before:
After:
Benchstat: