-
Notifications
You must be signed in to change notification settings - Fork 795
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Introduce `nano::elapse ()` helper * Move stats test to a dedicated file * Missing override & smaller improvements * nano::stats::dump * Move implementation to .cpp file * Index stats by a dedicated struct * Remove stat observers * Overhaul * Config * Use dedicated thread * Separate stat sinks * Samples writer * Fix for max size * Simple sampler key * Expected min max * Fix tests * Cleanup * Test for samples rpc * Implement sampling for node components * TODO * Remove special semantics of `stat::detail::all` * Guard against invalid values * Thread loop interval * More tests * Flag to aggregate `stat::detail::all` --------- Co-authored-by: Colin LeMahieu <[email protected]>
- Loading branch information
1 parent
161f418
commit 04de36c
Showing
28 changed files
with
805 additions
and
857 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
#include <nano/test_common/system.hpp> | ||
#include <nano/test_common/testutil.hpp> | ||
|
||
#include <gtest/gtest.h> | ||
|
||
#include <ostream> | ||
|
||
// Test stat counting at both type and detail levels | ||
TEST (stats, counters) | ||
{ | ||
nano::test::system system; | ||
auto & node = *system.add_node (); | ||
|
||
node.stats.add (nano::stat::type::ledger, nano::stat::detail::test, nano::stat::dir::in, 1); | ||
node.stats.add (nano::stat::type::ledger, nano::stat::detail::test, nano::stat::dir::in, 5); | ||
node.stats.inc (nano::stat::type::ledger, nano::stat::detail::test, nano::stat::dir::in); | ||
node.stats.inc (nano::stat::type::ledger, nano::stat::detail::send, nano::stat::dir::in); | ||
node.stats.inc (nano::stat::type::ledger, nano::stat::detail::send, nano::stat::dir::in); | ||
node.stats.inc (nano::stat::type::ledger, nano::stat::detail::receive, nano::stat::dir::in); | ||
|
||
ASSERT_EQ (10, node.stats.count (nano::stat::type::ledger, nano::stat::dir::in)); | ||
ASSERT_EQ (2, node.stats.count (nano::stat::type::ledger, nano::stat::detail::send, nano::stat::dir::in)); | ||
ASSERT_EQ (1, node.stats.count (nano::stat::type::ledger, nano::stat::detail::receive, nano::stat::dir::in)); | ||
|
||
node.stats.add (nano::stat::type::ledger, nano::stat::detail::test, nano::stat::dir::in, 0); | ||
|
||
ASSERT_EQ (10, node.stats.count (nano::stat::type::ledger, nano::stat::dir::in)); | ||
} | ||
|
||
TEST (stats, counters_aggregate_all) | ||
{ | ||
nano::test::system system; | ||
auto & node = *system.add_node (); | ||
|
||
node.stats.add (nano::stat::type::ledger, nano::stat::detail::test, nano::stat::dir::in, 1, true); | ||
|
||
ASSERT_EQ (1, node.stats.count (nano::stat::type::ledger, nano::stat::dir::in)); | ||
ASSERT_EQ (1, node.stats.count (nano::stat::type::ledger, nano::stat::detail::all, nano::stat::dir::in)); | ||
ASSERT_EQ (1, node.stats.count (nano::stat::type::ledger, nano::stat::detail::test, nano::stat::dir::in)); | ||
|
||
node.stats.add (nano::stat::type::ledger, nano::stat::detail::activate, nano::stat::dir::in, 5, true); | ||
|
||
ASSERT_EQ (6, node.stats.count (nano::stat::type::ledger, nano::stat::dir::in)); | ||
ASSERT_EQ (6, node.stats.count (nano::stat::type::ledger, nano::stat::detail::all, nano::stat::dir::in)); | ||
ASSERT_EQ (1, node.stats.count (nano::stat::type::ledger, nano::stat::detail::test, nano::stat::dir::in)); | ||
} | ||
|
||
TEST (stats, samples) | ||
{ | ||
nano::test::system system; | ||
auto & node = *system.add_node (); | ||
|
||
node.stats.sample (nano::stat::sample::active_election_duration, { 1, 10 }, 5); | ||
node.stats.sample (nano::stat::sample::active_election_duration, { 1, 10 }, 5); | ||
node.stats.sample (nano::stat::sample::active_election_duration, { 1, 10 }, 11); | ||
node.stats.sample (nano::stat::sample::active_election_duration, { 1, 10 }, 37); | ||
|
||
node.stats.sample (nano::stat::sample::bootstrap_tag_duration, { 1, 10 }, 2137); | ||
|
||
auto samples1 = node.stats.samples (nano::stat::sample::active_election_duration); | ||
ASSERT_EQ (4, samples1.size ()); | ||
ASSERT_EQ (5, samples1[0]); | ||
ASSERT_EQ (5, samples1[1]); | ||
ASSERT_EQ (11, samples1[2]); | ||
ASSERT_EQ (37, samples1[3]); | ||
|
||
auto samples2 = node.stats.samples (nano::stat::sample::active_election_duration); | ||
ASSERT_EQ (0, samples2.size ()); | ||
|
||
node.stats.sample (nano::stat::sample::active_election_duration, { 1, 10 }, 3); | ||
|
||
auto samples3 = node.stats.samples (nano::stat::sample::active_election_duration); | ||
ASSERT_EQ (1, samples3.size ()); | ||
ASSERT_EQ (3, samples3[0]); | ||
|
||
auto samples4 = node.stats.samples (nano::stat::sample::bootstrap_tag_duration); | ||
ASSERT_EQ (1, samples4.size ()); | ||
ASSERT_EQ (2137, samples4[0]); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.