• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

tari-project / tari / 16123384529

07 Jul 2025 05:11PM UTC coverage: 64.327% (-7.6%) from 71.89%
16123384529

push

github

web-flow
chore: new release v4.9.0-pre.0 (#7289)

Description
---
new release esmeralda

77151 of 119935 relevant lines covered (64.33%)

227108.34 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

8.0
/base_layer/core/src/base_node/metrics.rs
1
//  Copyright 2022, The Tari Project
2
//
3
//  Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
4
//  following conditions are met:
5
//
6
//  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following
7
//  disclaimer.
8
//
9
//  2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the
10
//  following disclaimer in the documentation and/or other materials provided with the distribution.
11
//
12
//  3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote
13
//  products derived from this software without specific prior written permission.
14
//
15
//  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
16
//  INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
17
//  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
18
//  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
19
//  SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
20
//  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
21
//  USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
22

23
use once_cell::sync::Lazy;
24
use tari_common_types::types::FixedHash;
25
use tari_metrics::{IntCounter, IntCounterVec, IntGauge, IntGaugeVec};
26
use tari_utilities::hex::Hex;
27

28
pub fn tip_height() -> &'static IntGauge {
×
29
    static METER: Lazy<IntGauge> = Lazy::new(|| {
×
30
        tari_metrics::register_int_gauge("base_node::blockchain::tip_height", "The current tip height").unwrap()
×
31
    });
×
32

33
    &METER
×
34
}
×
35

36
pub fn target_difficulty_sha() -> &'static IntGauge {
×
37
    static METER: Lazy<IntGauge> = Lazy::new(|| {
×
38
        tari_metrics::register_int_gauge(
×
39
            "base_node::blockchain::target_difficulty_sha",
×
40
            "The current miner target difficulty for the sha3 PoW algo",
×
41
        )
×
42
        .unwrap()
×
43
    });
×
44

45
    &METER
×
46
}
×
47

48
pub fn target_difficulty_monero_randomx() -> &'static IntGauge {
×
49
    static METER: Lazy<IntGauge> = Lazy::new(|| {
×
50
        tari_metrics::register_int_gauge(
×
51
            "base_node::blockchain::target_difficulty_monero",
×
52
            "The current miner target difficulty for the monero PoW algo",
×
53
        )
×
54
        .unwrap()
×
55
    });
×
56

57
    &METER
×
58
}
×
59
pub fn target_difficulty_tari_randomx() -> &'static IntGauge {
×
60
    static METER: Lazy<IntGauge> = Lazy::new(|| {
×
61
        tari_metrics::register_int_gauge(
×
62
            "base_node::blockchain::target_difficulty_tari_rx",
×
63
            "The current miner target difficulty for the tari rx PoW algo",
×
64
        )
×
65
        .unwrap()
×
66
    });
×
67

68
    &METER
×
69
}
×
70

71
pub fn reorg(fork_height: u64, num_added: usize, num_removed: usize) -> IntGauge {
×
72
    static METER: Lazy<IntGaugeVec> = Lazy::new(|| {
×
73
        tari_metrics::register_int_gauge_vec("base_node::blockchain::reorgs", "Reorg stats", &[
×
74
            "fork_height",
×
75
            "num_added",
×
76
            "num_removed",
×
77
        ])
×
78
        .unwrap()
×
79
    });
×
80

81
    METER.with_label_values(&[
×
82
        &fork_height.to_string(),
×
83
        &num_added.to_string(),
×
84
        &num_removed.to_string(),
×
85
    ])
×
86
}
×
87

88
pub fn compact_block_tx_misses(height: u64) -> IntGauge {
×
89
    static METER: Lazy<IntGaugeVec> = Lazy::new(|| {
×
90
        tari_metrics::register_int_gauge_vec(
×
91
            "base_node::blockchain::compact_block_unknown_transactions",
×
92
            "Number of unknown transactions from the incoming compact block",
×
93
            &["height"],
×
94
        )
×
95
        .unwrap()
×
96
    });
×
97

98
    METER.with_label_values(&[&height.to_string()])
×
99
}
×
100

101
pub fn compact_block_full_misses(height: u64) -> IntCounter {
×
102
    static METER: Lazy<IntCounterVec> = Lazy::new(|| {
×
103
        tari_metrics::register_int_counter_vec(
×
104
            "base_node::blockchain::compact_block_miss",
×
105
            "Number of full blocks that had to be requested",
×
106
            &["height"],
×
107
        )
×
108
        .unwrap()
×
109
    });
×
110

111
    METER.with_label_values(&[&height.to_string()])
×
112
}
×
113

114
pub fn compact_block_mmr_mismatch(height: u64) -> IntCounter {
×
115
    static METER: Lazy<IntCounterVec> = Lazy::new(|| {
×
116
        tari_metrics::register_int_counter_vec(
×
117
            "base_node::blockchain::compact_block_mmr_mismatch",
×
118
            "Number of full blocks that had to be requested because of MMR mismatch",
×
119
            &["height"],
×
120
        )
×
121
        .unwrap()
×
122
    });
×
123

124
    METER.with_label_values(&[&height.to_string()])
×
125
}
×
126

127
pub fn orphaned_blocks() -> IntCounter {
×
128
    static METER: Lazy<IntCounter> = Lazy::new(|| {
×
129
        tari_metrics::register_int_counter(
×
130
            "base_node::blockchain::orphaned_blocks",
×
131
            "Number of valid orphan blocks accepted by the base node",
×
132
        )
×
133
        .unwrap()
×
134
    });
×
135

136
    METER.clone()
×
137
}
×
138

139
pub fn rejected_blocks(height: u64, hash: &FixedHash) -> IntCounter {
×
140
    static METER: Lazy<IntCounterVec> = Lazy::new(|| {
×
141
        tari_metrics::register_int_counter_vec(
×
142
            "base_node::blockchain::rejected_blocks",
×
143
            "Number of block rejected by the base node",
×
144
            &["height", "block_hash"],
×
145
        )
×
146
        .unwrap()
×
147
    });
×
148

149
    METER.with_label_values(&[&height.to_string(), &hash.to_hex()])
×
150
}
×
151

152
pub fn active_sync_peers() -> &'static IntGauge {
4✔
153
    static METER: Lazy<IntGauge> = Lazy::new(|| {
1✔
154
        tari_metrics::register_int_gauge(
1✔
155
            "base_node::sync::active_peers",
1✔
156
            "Number of active peers syncing from this node",
1✔
157
        )
1✔
158
        .unwrap()
1✔
159
    });
1✔
160

161
    &METER
4✔
162
}
4✔
163

164
pub fn utxo_set_size() -> &'static IntGauge {
×
165
    static METER: Lazy<IntGauge> = Lazy::new(|| {
×
166
        tari_metrics::register_int_gauge(
×
167
            "base_node::blockchain::utxo_set_size",
×
168
            "The number of UTXOs in the current UTXO set",
×
169
        )
×
170
        .unwrap()
×
171
    });
×
172

173
    &METER
×
174
}
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc