Skip to content

Commit

Permalink
[Metrics] fix build after rebase, debugging transactions count
Browse files Browse the repository at this point in the history
Signed-off-by: kuvaldini <[email protected]>
  • Loading branch information
kuvaldini committed Jun 9, 2021
1 parent 2273993 commit 872284f
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 0 deletions.
13 changes: 13 additions & 0 deletions irohad/ametsuchi/impl/rocksdb_wsv_query.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -186,4 +186,17 @@ namespace iroha::ametsuchi {
}
}

iroha::expected::Result<size_t, std::string> RocksDBWsvQuery::countPeers(){
return iroha::expected::makeError("unimplemented yet");
}

iroha::expected::Result<size_t, std::string> RocksDBWsvQuery::countDomains(){
return iroha::expected::makeError("unimplemented yet");
}

iroha::expected::Result<size_t, std::string>
RocksDBWsvQuery::countTransactions() {
return iroha::expected::makeError("unimplemented yet");
}

} // namespace iroha::ametsuchi
4 changes: 4 additions & 0 deletions irohad/ametsuchi/impl/rocksdb_wsv_query.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ namespace iroha {
iroha::expected::Result<iroha::TopBlockInfo, std::string>
getTopBlockInfo() const override;

iroha::expected::Result<size_t, std::string> countPeers() override;
iroha::expected::Result<size_t, std::string> countDomains() override;
iroha::expected::Result<size_t, std::string> countTransactions() override;

private:
std::shared_ptr<RocksDBPort> db_port_;
std::shared_ptr<RocksDBContext> db_context_;
Expand Down
3 changes: 3 additions & 0 deletions irohad/ametsuchi/impl/storage_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,7 @@ namespace iroha {
std::shared_ptr<const shared_model::interface::Block> block_ptr =
std::move(maybe_block.get());
notifier_.get_subscriber().on_next(block_ptr);
log_->info("StorageImpl::commit() notify(EventTypes::kOnBlock)");
getSubscription()->notify(EventTypes::kOnBlock, block_ptr);
}
return expected::makeValue(std::move(commit_result.ledger_state));
Expand Down Expand Up @@ -360,6 +361,7 @@ namespace iroha {
throw std::runtime_error(e.value());
}

log_->info("StorageImpl::commitPrepared() notify(EventTypes::kOnBlock)");
notifier_.get_subscriber().on_next(block);
getSubscription()->notify(
EventTypes::kOnBlock,
Expand Down Expand Up @@ -462,6 +464,7 @@ namespace iroha {
std::shared_ptr<const shared_model::interface::Block> block) {
if (block_store_->insert(block)) {
notifier_.get_subscriber().on_next(block);
log_->info("StorageImpl::storeBlock() notify(EventTypes::kOnBlock)");
getSubscription()->notify(
EventTypes::kOnBlock,
std::shared_ptr<const shared_model::interface::Block>(block));
Expand Down
1 change: 1 addition & 0 deletions irohad/main/subscription_fwd.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ namespace iroha {
kYac = 0,
kRequestProposal,
kVoteProcess,
kMetrics,
//---------------
kTotalCount
};
Expand Down
16 changes: 16 additions & 0 deletions irohad/maintenance/metrics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,16 @@ Metrics::Metrics(std::string const &listen_addr,
total_number_of_transactions.Set(
storage_->getWsvQuery()->countTransactions().assumeValue());

auto &total_number_of_transactions_from_db_gauge =
BuildGauge()
.Name("total_number_of_transactions_from_db")
.Help("Total number of transactions in blockchain taken from DB")
.Register(*registry_);
auto &total_number_of_transactions_from_db =
total_number_of_transactions_from_db_gauge.Add({});
total_number_of_transactions_from_db.Set(
storage_->getWsvQuery()->countTransactions().assumeValue());

auto &number_of_signatures_in_last_block_gauge =
BuildGauge()
.Name("number_of_signatures_in_last_block")
Expand Down Expand Up @@ -121,6 +131,12 @@ Metrics::Metrics(std::string const &listen_addr,
boost::size(pblock->signatures()));
total_number_of_transactions.Increment(
boost::size(pblock->transactions()));
total_number_of_transactions_from_db.Set(
storage_->getWsvQuery()->countTransactions().assumeValue());
logger_->info("total_number_of_transactions {}",
total_number_of_transactions.Value());
logger_->info("total_number_of_transactions_from_db {}",
total_number_of_transactions_from_db.Value());
int domains_diff = 0, peers_diff = 0;
using namespace shared_model::interface;
for (Transaction const &trx : pblock->transactions()) {
Expand Down
2 changes: 2 additions & 0 deletions test/module/irohad/ametsuchi/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,15 @@ target_link_libraries(rdb_wsv_query_command_test
test_logger
ametsuchi_fixture
ametsuchi_rocksdb
sync_subscription
)

addtest(rdb_wsv_query_test rdb_wsv_query_test.cpp)
target_link_libraries(rdb_wsv_query_test
test_logger
ametsuchi_fixture
ametsuchi_rocksdb
sync_subscription
)

addtest(rocksdb_indexer_test rocksdb_indexer_test.cpp)
Expand Down

0 comments on commit 872284f

Please sign in to comment.