-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
[corechecks] Support custom tags in every corechecks #2723
Conversation
This is mainly used to attach tags read in checks configuration to an instanciated sender. Those custom tags will be appended to each send (event, metric, service).
Some checks were already appending their custom tags to the metrics, events and services check sent. This commit removes this as it's now done by the `checkSender`.
…nting a new core check.
…) and kube apiserver unit tests.
Codecov Report
@@ Coverage Diff @@
## master #2723 +/- ##
==========================================
+ Coverage 57.4% 57.44% +0.03%
==========================================
Files 392 393 +1
Lines 25616 25765 +149
==========================================
+ Hits 14705 14800 +95
- Misses 9943 9988 +45
- Partials 968 977 +9
|
@@ -42,7 +42,7 @@ type DockerConfig struct { | |||
CollectImageSize bool `yaml:"collect_image_size"` | |||
CollectDiskStats bool `yaml:"collect_disk_stats"` | |||
CollectVolumeCount bool `yaml:"collect_volume_count"` | |||
Tags []string `yaml:"tags"` | |||
Tags []string `yaml:"tags"` // Used only by the configuration converter v5 → v6 |
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.
Keeping this attribute only because it's used by the legacy converter is not great. But for now, I've no good solution except this comment to avoid somebody to use this field.
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.
If you want to be bullet-proof, you can use anonymous embedding to create a new type extending DockerConfig, in the legacy package:
type fullDockerConfig struct {
containers.DockerConfig
Tags []string `yaml:"tags"`
}
But your approach is OK
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.
👍
@@ -42,7 +42,7 @@ type DockerConfig struct { | |||
CollectImageSize bool `yaml:"collect_image_size"` | |||
CollectDiskStats bool `yaml:"collect_disk_stats"` | |||
CollectVolumeCount bool `yaml:"collect_volume_count"` | |||
Tags []string `yaml:"tags"` | |||
Tags []string `yaml:"tags"` // Used only by the configuration converter v5 → v6 |
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.
If you want to be bullet-proof, you can use anonymous embedding to create a new type extending DockerConfig, in the legacy package:
type fullDockerConfig struct {
containers.DockerConfig
Tags []string `yaml:"tags"`
}
But your approach is OK
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.
LGTM, please get a review from croissant too
What does this PR do?
This PR unify the use of custom tags in corechecks configuration files.
Some corechecks were correctly using the
tags
field of their configuration file, but they did it manually, some others corechecks were completely ignoring it.Motivation
Be consistent with the work done by agent-integrations which made sure that the
tags
configuration field is correctly used.Additional Notes
While a check is running
CheckBase.CommonConfigure(...)
, if thetags
configuration field is set, those tags are stored into the sender used by the current check, copying the behavior of the fieldsmin_collection_interval
andempty_default_hostname
.Thus, when the sender is used to send a metric, an event or a service check, it appends the custom tags to the message.
I've chosen this solution mainly for those pros:
CheckBase
won't need to manually deal with thetags
configuration fieldBut it has cons:
checkSender
is responsible for storing the custom tags, which is ok, but not ideal.Some design choices: