Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions src/datadog/datadog_agent_config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Expected<DatadogAgentConfig> load_datadog_agent_env_config() {

if (auto raw_rc_poll_interval_value =
lookup(environment::DD_REMOTE_CONFIG_POLL_INTERVAL_SECONDS)) {
auto res = parse_int(*raw_rc_poll_interval_value, 10);
auto res = parse_double(*raw_rc_poll_interval_value);
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note to myself: a double is too big but I don't have time (don't want yet) to write (and test) a parse_float function.

if (auto error = res.if_error()) {
return error->with_prefix(
"DatadogAgent: Remote Configuration poll interval error ");
Expand Down Expand Up @@ -114,12 +114,13 @@ Expected<FinalizedDatadogAgentConfig> finalize_config(
"milliseconds."};
}

if (int rc_poll_interval_seconds =
if (double rc_poll_interval_seconds =
value_or(env_config->remote_configuration_poll_interval_seconds,
user_config.remote_configuration_poll_interval_seconds, 5);
rc_poll_interval_seconds > 0) {
user_config.remote_configuration_poll_interval_seconds, 5.0);
rc_poll_interval_seconds >= 0.0) {
result.remote_configuration_poll_interval =
std::chrono::seconds(rc_poll_interval_seconds);
std::chrono::duration_cast<std::chrono::milliseconds>(
std::chrono::duration<double>(rc_poll_interval_seconds));
} else {
return Error{Error::DATADOG_AGENT_INVALID_REMOTE_CONFIG_POLL_INTERVAL,
"DatadogAgent: Remote Configuration poll interval must be a "
Expand Down
2 changes: 1 addition & 1 deletion src/datadog/datadog_agent_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ struct DatadogAgentConfig {
Optional<bool> remote_configuration_enabled;
// How often, in seconds, to query the Datadog Agent for remote configuration
// updates.
Optional<int> remote_configuration_poll_interval_seconds;
Optional<double> remote_configuration_poll_interval_seconds;

static Expected<HTTPClient::URL> parse(StringView);
};
Expand Down
10 changes: 1 addition & 9 deletions test/test_tracer_config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -446,14 +446,6 @@ TEST_CASE("TracerConfig::agent") {
}

SECTION("remote configuration poll interval") {
SECTION("cannot be zero") {
config.agent.remote_configuration_poll_interval_seconds = 0;
auto finalized = finalize_config(config);
REQUIRE(!finalized);
REQUIRE(finalized.error().code ==
Error::DATADOG_AGENT_INVALID_REMOTE_CONFIG_POLL_INTERVAL);
}

SECTION("cannot be negative") {
config.agent.remote_configuration_poll_interval_seconds = -1337;
auto finalized = finalize_config(config);
Expand Down Expand Up @@ -491,7 +483,7 @@ TEST_CASE("TracerConfig::agent") {
"ddog"};
auto finalized = finalize_config(config);
REQUIRE(!finalized);
REQUIRE(finalized.error().code == Error::INVALID_INTEGER);
REQUIRE(finalized.error().code == Error::INVALID_DOUBLE);
}
}
}
Expand Down