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

feat: Chain & explorer Prometheus metrics #10063

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

vbaranov
Copy link
Member

@vbaranov vbaranov commented May 14, 2024

Resolves #10064

Motivation

Add chain & explorer metrics to /metrics endpoint.

Changelog

New metrics exposed at /metrics endpoint:

# TYPE weekly_new_wallet_addresses_number gauge
# HELP weekly_new_wallet_addresses_number Number of new wallet addresses in the last 7 days
weekly_new_wallet_addresses_number 65210
# TYPE weekly_new_tokens_number gauge
# HELP weekly_new_tokens_number Number of new tokens detected in the last 7 days
weekly_new_tokens_number 1551
# TYPE weekly_active_addresses_number gauge
# HELP weekly_active_addresses_number Number of active EOA addresses (participated in transactions in to/from) in the last 7 days
weekly_active_addresses_number 49046
# TYPE weekly_deployed_smart_contracts_number gauge
# HELP weekly_deployed_smart_contracts_number Number of deployed smart-contracts in the last 7 days
weekly_deployed_smart_contracts_number 5734
# TYPE weekly_new_token_transfers_number gauge
# HELP weekly_new_token_transfers_number Number of new token transfers detected in the last 7 days
weekly_new_token_transfers_number 138388
# TYPE weekly_verified_smart_contracts_number gauge
# HELP weekly_verified_smart_contracts_number Number of verified smart-contracts in the last 7 days
weekly_verified_smart_contracts_number 0
# TYPE weekly_success_transactions_number gauge
# HELP weekly_success_transactions_number Number of successful transactions in the last 7 days
weekly_success_transactions_number 190598

Checklist for your Pull Request (PR)

@vbaranov vbaranov force-pushed the vb-chain-and-explorer-metrics branch from 10ef1f2 to 8336f10 Compare May 14, 2024 09:31
@vbaranov vbaranov changed the title Chain & Explorer metrics feat: Chain & explorer Prometheus metrics May 14, 2024
@vbaranov vbaranov self-assigned this May 14, 2024
@vbaranov vbaranov force-pushed the vb-chain-and-explorer-metrics branch from 8336f10 to a19d490 Compare May 14, 2024 09:37
@vbaranov vbaranov marked this pull request as ready for review May 14, 2024 10:15
@k1rill-fedoseev
Copy link
Collaborator

Was an example from the PR description fetched from a live instance? How it's possible that weekly_new_wallet_addresses_number is larger than weekly_active_addresses_number?

end

defp set_metrics do
set_handler_metric(:weekly_success_transactions_number)
Copy link
Collaborator

Choose a reason for hiding this comment

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

It's going to be executed synchronously right, each metric one by one? Can we realistically hit a 1 hour duration for all queries in total, so that it will impact interval duration? Does it make sense to run them concurrently?

Copy link
Member Author

Choose a reason for hiding this comment

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

Good point, I wrapped all metrics to asynchronous task in c400611.

Comment on lines 28 to 29
set_metrics()
schedule_next_run()
Copy link
Collaborator

Choose a reason for hiding this comment

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

If set_metrics() is synchronous and blocking, then intervals between calls to set_metrics will be greater than 1 hour and can become uneven. I think it might make sense to either make set_metrics asynchronous or switch the order of this 2 statements.

Copy link
Member Author

@vbaranov vbaranov May 23, 2024

Choose a reason for hiding this comment

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

I've put schedule_next_run before running setting metrics task. c400611

apps/explorer/lib/explorer/chain/metrics/queries.ex Outdated Show resolved Hide resolved
apps/explorer/lib/explorer/chain/metrics.ex Show resolved Hide resolved
@vbaranov vbaranov force-pushed the vb-chain-and-explorer-metrics branch from 6721a54 to 0f662e6 Compare May 21, 2024 16:37
@vbaranov vbaranov force-pushed the vb-chain-and-explorer-metrics branch from fc729d4 to 2b128a2 Compare May 23, 2024 15:27
@vbaranov
Copy link
Member Author

Was an example from the PR description fetched from a live instance? How it's possible that weekly_new_wallet_addresses_number is larger than weekly_active_addresses_number?

That was a local run - so it might happen because of accounts participated in token transfers, internal transactions etc, and current version of active accounts query takes into account only transactions. I extended the query for active accounts with join of extracting active users from token transfers and internal transactions - though this will increase query execution time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add chain & explorer Prometheus metrics
2 participants