Skip to content

Commit

Permalink
do not set sys.time.estimatedError when time is unsynchronized (#131)
Browse files Browse the repository at this point in the history
We are trying to gather some data on the accuracy of clock time across the
fleet, and the `sys.time.estimatedError` was reporting a number of 16s values.

These values occur when the kernel has not synchonized the clock yet. This
fact is tracked with the `sys.time.unsynchronized` metric. The `estimatedError`
metric should only have valid results from `ntp_adjtime`.
  • Loading branch information
copperlight authored May 29, 2024
1 parent b127928 commit d40b66a
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion bin/atlas-agent.cc
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ int main(int argc, char* const argv[]) {
nvidia_lib = std::make_unique<Nvml>();
logger->info("Will attempt to collect GPU metrics");
} catch (atlasagent::NvmlException& e) {
logger->info("Will not collect GPU metrics: %s", e.what());
logger->info("Will not collect GPU metrics: {}", e.what());
}

atlasagent::HttpClient<>::GlobalInit();
Expand Down
4 changes: 3 additions & 1 deletion lib/ntp.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@ class Ntp {
}

unsynchronized_->Set(err == TIME_ERROR);
estimatedError_->Set(time->esterror / 1e6);
if (err != TIME_ERROR) {
estimatedError_->Set(time->esterror / 1e6);
}
}

void chrony_stats(const std::string& tracking, const std::vector<std::string>& sources) noexcept {
Expand Down
3 changes: 1 addition & 2 deletions lib/ntp_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,7 @@ TEST(Ntp, adjtime_err) {

auto ms = registry.Measurements();
auto map = measurements_to_map(ms, "");
std::unordered_map<std::string, double> expected = {{"sys.time.unsynchronized|gauge", 1},
{"sys.time.estimatedError|gauge", 0.2}};
std::unordered_map<std::string, double> expected = {{"sys.time.unsynchronized|gauge", 1}};
EXPECT_EQ(map, expected);
}
} // namespace
4 changes: 2 additions & 2 deletions setup-venv.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ MAYBE_PYTHON=$(find /apps -maxdepth 1 -type l -name "python*")

if [[ -n "$MAYBE_PYTHON" ]]; then
PYTHON3="$MAYBE_PYTHON/bin/python3"
echo "using $MAYBE_PYTHON/bin/python3 ($(PYTHON3 -V))"
echo "using $PYTHON3 ($($PYTHON3 -V))"
else
PYTHON3="python3"
echo "using $(which python3) ($(PYTHON3 -V))"
echo "using $(which $PYTHON3) ($($PYTHON3 -V))"
fi

# create and activate virtualenv
Expand Down

0 comments on commit d40b66a

Please sign in to comment.