Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Send blocks telemetry immediately or in 1 sec intervals #1822

Merged
merged 2 commits into from
Oct 3, 2023
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
2 changes: 2 additions & 0 deletions core/blockchain/impl/block_tree_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -904,6 +904,7 @@ namespace kagome::blockchain {

log_->info("Finalized block {}", block);
telemetry_->notifyBlockFinalized(block);
telemetry_->pushBlockStats();
metric_finalized_block_height_->set(node->depth);

} else if (node->block_hash == last_finalized_block_info.hash) {
Expand Down Expand Up @@ -1589,6 +1590,7 @@ namespace kagome::blockchain {
metric_known_chain_leaves_->set(leaves_size);
metric_best_block_height_->set(block_info.number);
telemetry_->notifyBlockFinalized(block_info);
telemetry_->pushBlockStats();
metric_finalized_block_height_->set(block_info.number);
}

Expand Down
1 change: 1 addition & 0 deletions core/consensus/babe/impl/babe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -544,6 +544,7 @@ namespace kagome::consensus::babe {
block_info.hash, storage_sub_engine_, chain_sub_engine_);

telemetry_->notifyBlockImported(block_info, telemetry::BlockOrigin::kOwn);
telemetry_->pushBlockStats();

// observe digest of block
// (must be done strictly after block will be added)
Expand Down
1 change: 1 addition & 0 deletions core/consensus/timeline/impl/block_executor_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,7 @@ namespace kagome::consensus {
auto current_best_block = self->block_tree_->bestBlock();
self->telemetry_->notifyBlockImported(
current_best_block, telemetry::BlockOrigin::kNetworkInitialSync);
self->telemetry_->pushBlockStats();

// Create new offchain worker for block if it is best only
if (current_best_block.number > previous_best_block_number) {
Expand Down
4 changes: 4 additions & 0 deletions core/telemetry/impl/service_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,10 @@ namespace kagome::telemetry {
}
}

void TelemetryServiceImpl::pushBlockStats() {
frequentNotificationsRoutine();
}

std::string TelemetryServiceImpl::blockNotification(
const primitives::BlockInfo &info, std::optional<BlockOrigin> origin) {
std::string event_name =
Expand Down
2 changes: 2 additions & 0 deletions core/telemetry/impl/service_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ namespace kagome::telemetry {

void notifyBlockFinalized(const primitives::BlockInfo &info) override;

void pushBlockStats() override;

void setGenesisBlockHash(const primitives::BlockHash &hash) override;

void notifyWasSynchronized() override;
Expand Down
5 changes: 5 additions & 0 deletions core/telemetry/service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ namespace kagome::telemetry {
service_->notifyBlockFinalized(info);
}
}
void pushBlockStats() override {
if (service_) {
service_->pushBlockStats();
}
}
void notifyWasSynchronized() override {
if (service_) {
service_->notifyWasSynchronized();
Expand Down
5 changes: 5 additions & 0 deletions core/telemetry/service.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,11 @@ namespace kagome::telemetry {
*/
virtual void notifyBlockFinalized(const primitives::BlockInfo &info) = 0;

/**
* Send imported+finalized blocks info immediately and reset periodic timer
*/
virtual void pushBlockStats() = 0;

/**
* Telemetry service status
* @return true - when application configured to broadcast telemetry
Expand Down
5 changes: 5 additions & 0 deletions test/mock/core/telemetry/telemetry_service_mock.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ namespace kagome::telemetry {
(const primitives::BlockInfo &),
(override));

MOCK_METHOD(void,
pushBlockStats,
(),
(override));

MOCK_METHOD(void, notifyWasSynchronized, (), (override));

MOCK_METHOD(bool, isEnabled, (), (const override));
Expand Down
Loading