From ffae14c17fd59a70890933da618050f7ffe2939c Mon Sep 17 00:00:00 2001 From: jeffgrunewald Date: Mon, 8 Aug 2022 16:01:01 -0400 Subject: [PATCH] updating latest core rebase changes --- include/metrics.hrl | 11 +++++++---- rebar.config | 2 +- rebar.lock | 2 +- src/handlers/miner_hbbft_handler.erl | 2 +- ...trics_reporter.erl => miner_metrics_exporter.erl} | 2 +- src/metrics/miner_metrics_server.erl | 12 +++++++++--- 6 files changed, 20 insertions(+), 11 deletions(-) rename src/metrics/{miner_metrics_reporter.erl => miner_metrics_exporter.erl} (92%) diff --git a/include/metrics.hrl b/include/metrics.hrl index 886b8e9f1..e9052c7f0 100644 --- a/include/metrics.hrl +++ b/include/metrics.hrl @@ -5,11 +5,12 @@ -define(METRICS_BLOCK_HEIGHT, "blockchain_block_height"). -define(METRICS_BLOCK_UNVAL_HEIGHT, "blockchain_block_unval_height"). -define(METRICS_TXN_ABSORB_DURATION, "blockchain_txn_absorb_duration"). +-define(METRICS_TXN_BLOCK_SPAN, "blockchain_txn_mgr_block_span"). +-define(METRICS_TXN_QUEUE, "blockchain_txn_mgr_queue"). -define(METRICS_TXN_SUBMIT_COUNT, "blockchain_txn_mgr_submited_count"). -define(METRICS_TXN_REJECT_COUNT, "blockchain_txn_mgr_rejected_count"). --define(METRICS_TXN_REJECT_SPAN, "blockchain_txn_mgr_rejected_span"). -define(METRICS_TXN_ACCEPT_COUNT, "blockchain_txn_mgr_accepted_count"). --define(METRICS_TXN_ACCEPT_SPAN, "blockchain_txn_mgr_accepted_span"). +-define(METRICS_TXN_UPDATE_COUNT, "blockchain_txn_mgr_updated_count"). -define(METRICS_TXN_PROCESS_DURATION, "blockchain_txn_mgr_process_duration"). -define(METRICS_TXN_CACHE_SIZE, "blockchain_txn_mgr_cache_size"). -define(METRICS_TXN_BLOCK_TIME, "blockchain_txn_mgr_block_time"). @@ -38,14 +39,16 @@ [blockchain, txn_mgr, submit], [blockchain, txn_mgr, reject], [blockchain, txn_mgr, accept], + [blockchain, txn_mgr, update], [blockchain, txn_mgr, process], [blockchain, txn_mgr, add_block] ], [ {?METRICS_TXN_ABSORB_DURATION, prometheus_histogram, [stage], "Txn absorb duration"}, + {?METRICS_TXN_BLOCK_SPAN, prometheus_gauge, [], "Block span of transactions"}, + {?METRICS_TXN_QUEUE, prometheus_gauge, [], "Txn manager submission queue length"}, {?METRICS_TXN_SUBMIT_COUNT, prometheus_counter, [type], "Count of submitted transactions"}, {?METRICS_TXN_REJECT_COUNT, prometheus_counter, [type], "Count of rejected transactions"}, - {?METRICS_TXN_REJECT_SPAN, prometheus_gauge, [type], "Block span of transactions on final rejection"}, {?METRICS_TXN_ACCEPT_COUNT, prometheus_counter, [type], "Count of accepted transactions"}, - {?METRICS_TXN_ACCEPT_SPAN, prometheus_gauge, [type], "Block span of transactions on acceptance"}, + {?METRICS_TXN_UPDATE_COUNT, prometheus_counter, [type], "Count of updated transactions"}, {?METRICS_TXN_PROCESS_DURATION, prometheus_histogram, [stage], "Transaction manager cache process duration"}, {?METRICS_TXN_CACHE_SIZE, prometheus_gauge, [height], "Transaction manager buffer size"}, {?METRICS_TXN_BLOCK_TIME, prometheus_gauge, [height], "Block time observed from the transaction mgr"}, diff --git a/rebar.config b/rebar.config index 484668333..a41d4fb1a 100644 --- a/rebar.config +++ b/rebar.config @@ -10,7 +10,7 @@ {deps, [ {blockchain, {git, "https://github.com/helium/blockchain-core.git", - {branch, "jg/txn_absorb_metrics"}}}, + {branch, "master"}}}, {sibyl, {git, "https://github.com/helium/sibyl.git", {branch, "master"}}}, {hbbft, {git, "https://github.com/helium/erlang-hbbft.git", diff --git a/rebar.lock b/rebar.lock index caf470f07..3784e6e5c 100644 --- a/rebar.lock +++ b/rebar.lock @@ -8,7 +8,7 @@ {<<"base64url">>,{pkg,<<"base64url">>,<<"1.0.1">>},1}, {<<"blockchain">>, {git,"https://github.com/helium/blockchain-core.git", - {ref,"0caf2295d0576c0ef803258e834bf6ec3b3e74bc"}}, + {ref,"bae8c3696747fdc24074c0e85ac64e745760d8aa"}}, 0}, {<<"certifi">>,{pkg,<<"certifi">>,<<"2.9.0">>},2}, {<<"chatterbox">>, diff --git a/src/handlers/miner_hbbft_handler.erl b/src/handlers/miner_hbbft_handler.erl index ba3b1ed06..01b83ab36 100644 --- a/src/handlers/miner_hbbft_handler.erl +++ b/src/handlers/miner_hbbft_handler.erl @@ -79,7 +79,7 @@ metadata(Version, Meta, Chain) -> Infos = blockchain_ledger_snapshot_v1:get_infos(Chain), case blockchain_ledger_snapshot_v1:snapshot(Ledger, Blocks, Infos) of {ok, Snapshot} -> - {ok, _SnapHeight, SnapHash, _SnapSize} = blockchain:add_snapshot(Snapshot, Chain), + {ok, {_SnapHeight, SnapHash, _SnapSize}} = blockchain:add_snapshot(Snapshot, Chain), lager:info("snapshot hash is ~p", [SnapHash]), maps:put(snapshot_hash, SnapHash, ChainMeta0); _Err -> diff --git a/src/metrics/miner_metrics_reporter.erl b/src/metrics/miner_metrics_exporter.erl similarity index 92% rename from src/metrics/miner_metrics_reporter.erl rename to src/metrics/miner_metrics_exporter.erl index 949161166..14ebb6fe3 100644 --- a/src/metrics/miner_metrics_reporter.erl +++ b/src/metrics/miner_metrics_exporter.erl @@ -1,4 +1,4 @@ --module(miner_metrics_reporter). +-module(miner_metrics_exporter). -behaviour(elli_handler). diff --git a/src/metrics/miner_metrics_server.erl b/src/metrics/miner_metrics_server.erl index c2f7e4487..c12011bad 100644 --- a/src/metrics/miner_metrics_server.erl +++ b/src/metrics/miner_metrics_server.erl @@ -145,11 +145,17 @@ handle_metric_event([blockchain, txn_mgr, submit], _Measurements, #{type := Type ok; handle_metric_event([blockchain, txn_mgr, reject], #{block_span := Span}, #{type := Type}) -> prometheus_counter:inc(?METRICS_TXN_REJECT_COUNT, [Type]), - prometheus_gauge:set(?METRICS_TXN_REJECT_SPAN, [Type], Span), + prometheus_gauge:set(?METRICS_TXN_BLOCK_SPAN, [], Span), ok; -handle_metric_event([blockchain, txn_mgr, accept], #{block_span := Span}, #{type := Type}) -> +handle_metric_event([blockchain, txn_mgr, accept], #{block_span := Span, queue_len := QLen}, #{type := Type}) -> prometheus_counter:inc(?METRICS_TXN_ACCEPT_COUNT, [Type]), - prometheus_gauge:set(?METRICS_TXN_ACCEPT_SPAN, [Type], Span), + prometheus_gauge:set(?METRICS_TXN_BLOCK_SPAN, [], Span), + prometheus_gauge:set(?METRICS_TXN_QUEUE, [], QLen), + ok; +handle_metric_event([blockchain, txn_mgr, update], #{block_span := Span, queue_len := QLen}, #{type := Type}) -> + prometheus_counter:inc(?METRICS_TXN_UPDATE_COUNT, [Type]), + prometheus_gauge:set(?METRICS_TXN_BLOCK_SPAN, [], Span), + prometheus_gauge:set(?METRICS_TXN_QUEUE, [], QLen), ok; handle_metric_event([blockchain, txn_mgr, process], #{duration := Duration}, #{stage := Stage}) -> prometheus_histogram:observe(?METRICS_TXN_PROCESS_DURATION, [Stage], Duration),