Skip to content

Commit 9fedff2

Browse files
authored
fix: remote config polling parsing (#123)
According to the Remote Configuration specification, `DD_REMOTE_CONFIG_POLL_INTERVAL_SECONDS` support floating point input and can be set to `0`.
1 parent e3c8a55 commit 9fedff2

File tree

3 files changed

+8
-15
lines changed

3 files changed

+8
-15
lines changed

src/datadog/datadog_agent_config.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ Expected<DatadogAgentConfig> load_datadog_agent_env_config() {
2121

2222
if (auto raw_rc_poll_interval_value =
2323
lookup(environment::DD_REMOTE_CONFIG_POLL_INTERVAL_SECONDS)) {
24-
auto res = parse_int(*raw_rc_poll_interval_value, 10);
24+
auto res = parse_double(*raw_rc_poll_interval_value);
2525
if (auto error = res.if_error()) {
2626
return error->with_prefix(
2727
"DatadogAgent: Remote Configuration poll interval error ");
@@ -114,12 +114,13 @@ Expected<FinalizedDatadogAgentConfig> finalize_config(
114114
"milliseconds."};
115115
}
116116

117-
if (int rc_poll_interval_seconds =
117+
if (double rc_poll_interval_seconds =
118118
value_or(env_config->remote_configuration_poll_interval_seconds,
119-
user_config.remote_configuration_poll_interval_seconds, 5);
120-
rc_poll_interval_seconds > 0) {
119+
user_config.remote_configuration_poll_interval_seconds, 5.0);
120+
rc_poll_interval_seconds >= 0.0) {
121121
result.remote_configuration_poll_interval =
122-
std::chrono::seconds(rc_poll_interval_seconds);
122+
std::chrono::duration_cast<std::chrono::milliseconds>(
123+
std::chrono::duration<double>(rc_poll_interval_seconds));
123124
} else {
124125
return Error{Error::DATADOG_AGENT_INVALID_REMOTE_CONFIG_POLL_INTERVAL,
125126
"DatadogAgent: Remote Configuration poll interval must be a "

src/datadog/datadog_agent_config.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ struct DatadogAgentConfig {
6161
Optional<bool> remote_configuration_enabled;
6262
// How often, in seconds, to query the Datadog Agent for remote configuration
6363
// updates.
64-
Optional<int> remote_configuration_poll_interval_seconds;
64+
Optional<double> remote_configuration_poll_interval_seconds;
6565

6666
static Expected<HTTPClient::URL> parse(StringView);
6767
};

test/test_tracer_config.cpp

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -446,14 +446,6 @@ TEST_CASE("TracerConfig::agent") {
446446
}
447447

448448
SECTION("remote configuration poll interval") {
449-
SECTION("cannot be zero") {
450-
config.agent.remote_configuration_poll_interval_seconds = 0;
451-
auto finalized = finalize_config(config);
452-
REQUIRE(!finalized);
453-
REQUIRE(finalized.error().code ==
454-
Error::DATADOG_AGENT_INVALID_REMOTE_CONFIG_POLL_INTERVAL);
455-
}
456-
457449
SECTION("cannot be negative") {
458450
config.agent.remote_configuration_poll_interval_seconds = -1337;
459451
auto finalized = finalize_config(config);
@@ -491,7 +483,7 @@ TEST_CASE("TracerConfig::agent") {
491483
"ddog"};
492484
auto finalized = finalize_config(config);
493485
REQUIRE(!finalized);
494-
REQUIRE(finalized.error().code == Error::INVALID_INTEGER);
486+
REQUIRE(finalized.error().code == Error::INVALID_DOUBLE);
495487
}
496488
}
497489
}

0 commit comments

Comments
 (0)