From 2bbe04bf720914e2cba1cc2d63e82bad6d3d8117 Mon Sep 17 00:00:00 2001 From: Nassim Boutekedjiret Date: Mon, 2 Dec 2024 18:59:58 +0100 Subject: [PATCH] [exporter/datadog] Add configurable `reporter_period` for host metadata * Minimum reporter_period 5-minutes as suggested by @jade-guiton-dd --- pkg/datadog/config/config.go | 4 ++-- pkg/datadog/config/config_test.go | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/pkg/datadog/config/config.go b/pkg/datadog/config/config.go index a1e6597312c6..c1b40bd7cef0 100644 --- a/pkg/datadog/config/config.go +++ b/pkg/datadog/config/config.go @@ -133,8 +133,8 @@ func (c *Config) Validate() error { return err } - if c.HostMetadata.ReporterPeriod <= 0 { - return errors.New("reporter_period must be a positive duration") + if c.HostMetadata.ReporterPeriod < 5*time.Minute { + return errors.New("reporter_period must be 5 minutes or higher") } return nil diff --git a/pkg/datadog/config/config_test.go b/pkg/datadog/config/config_test.go index 2d7cde743c54..a76b2b5a5b9b 100644 --- a/pkg/datadog/config/config_test.go +++ b/pkg/datadog/config/config_test.go @@ -190,9 +190,9 @@ func TestValidate(t *testing.T) { name: "Invalid reporter_period", cfg: &Config{ API: APIConfig{Key: "notnull"}, - HostMetadata: HostMetadataConfig{Enabled: true, ReporterPeriod: 0}, + HostMetadata: HostMetadataConfig{Enabled: true, ReporterPeriod: 4 * time.Minute}, }, - err: "reporter_period must be a positive duration", + err: "reporter_period must be 5 minutes or higher", }, } for _, testInstance := range tests {