Skip to content

Commit abe0a0a

Browse files
authored
Merge pull request #4715 from stacks-network/chore/master-to-2.5.0.0.0
Merge master into release/2.5.0.0.0
2 parents 52d425d + c2dcdde commit abe0a0a

39 files changed

+277
-37
lines changed

stackslib/src/monitoring/mod.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ use stacks_common::util::uint::{Uint256, Uint512};
2929
use crate::burnchains::{BurnchainSigner, Txid};
3030
use crate::core::MemPoolDB;
3131
use crate::net::httpcore::{StacksHttpRequest, StacksHttpResponse};
32+
use crate::net::rpc::ConversationHttp;
3233
use crate::net::Error as net_error;
3334
use crate::util_lib::db::{sqlite_open, tx_busy_handler, DBConn, Error as DatabaseError};
3435

@@ -46,19 +47,20 @@ pub fn increment_rpc_calls_counter() {
4647
}
4748

4849
pub fn instrument_http_request_handler<F, R>(
49-
req: StacksHttpRequest,
50+
conv_http: &mut ConversationHttp,
51+
mut req: StacksHttpRequest,
5052
handler: F,
5153
) -> Result<R, net_error>
5254
where
53-
F: FnOnce(StacksHttpRequest) -> Result<R, net_error>,
55+
F: FnOnce(&mut ConversationHttp, StacksHttpRequest) -> Result<R, net_error>,
5456
{
5557
#[cfg(feature = "monitoring_prom")]
5658
increment_rpc_calls_counter();
5759

5860
#[cfg(feature = "monitoring_prom")]
59-
let timer = prometheus::new_rpc_call_timer(req.request_path());
61+
let timer = prometheus::new_rpc_call_timer(conv_http.metrics_identifier(&mut req));
6062

61-
let res = handler(req);
63+
let res = handler(conv_http, req);
6264

6365
#[cfg(feature = "monitoring_prom")]
6466
timer.stop_and_record();

stackslib/src/net/api/callreadonly.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,10 @@ impl HttpRequest for RPCCallReadOnlyRequestHandler {
116116
.unwrap()
117117
}
118118

119+
fn metrics_identifier(&self) -> &str {
120+
"/v2/contracts/call-read/:principal/:contract_name/:func_name"
121+
}
122+
119123
/// Try to decode this request.
120124
fn try_parse_request(
121125
&mut self,

stackslib/src/net/api/getaccount.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,10 @@ impl HttpRequest for RPCGetAccountRequestHandler {
8484
.unwrap()
8585
}
8686

87+
fn metrics_identifier(&self) -> &str {
88+
"/v2/accounts/:principal"
89+
}
90+
8791
/// Try to decode this request.
8892
/// There's nothing to load here, so just make sure the request is well-formed.
8993
fn try_parse_request(

stackslib/src/net/api/getattachment.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,10 @@ impl HttpRequest for RPCGetAttachmentRequestHandler {
5959
Regex::new(r#"^/v2/attachments/(?P<attachment_hash>[0-9a-f]{40})$"#).unwrap()
6060
}
6161

62+
fn metrics_identifier(&self) -> &str {
63+
"/v2/attachments/:hash"
64+
}
65+
6266
/// Try to decode this request.
6367
/// There's nothing to load here, so just make sure the request is well-formed.
6468
fn try_parse_request(

stackslib/src/net/api/getattachmentsinv.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,10 @@ impl HttpRequest for RPCGetAttachmentsInvRequestHandler {
6161
Regex::new("^/v2/attachments/inv$").unwrap()
6262
}
6363

64+
fn metrics_identifier(&self) -> &str {
65+
"/v2/attachments/inv"
66+
}
67+
6468
/// Try to decode this request.
6569
/// There's nothing to load here, so just make sure the request is well-formed.
6670
fn try_parse_request(

stackslib/src/net/api/getblock.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,10 @@ impl HttpRequest for RPCBlocksRequestHandler {
9090
Regex::new(r#"^/v2/blocks/(?P<block_id>[0-9a-f]{64})$"#).unwrap()
9191
}
9292

93+
fn metrics_identifier(&self) -> &str {
94+
"/v2/blocks/:block_id"
95+
}
96+
9397
/// Try to decode this request.
9498
/// There's nothing to load here, so just make sure the request is well-formed.
9599
fn try_parse_request(

stackslib/src/net/api/getblock_v3.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,10 @@ impl HttpRequest for RPCNakamotoBlockRequestHandler {
126126
Regex::new(r#"^/v3/blocks/(?P<block_id>[0-9a-f]{64})$"#).unwrap()
127127
}
128128

129+
fn metrics_identifier(&self) -> &str {
130+
"/v3/blocks/:block_id"
131+
}
132+
129133
/// Try to decode this request.
130134
/// There's nothing to load here, so just make sure the request is well-formed.
131135
fn try_parse_request(

stackslib/src/net/api/getconstantval.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,10 @@ impl HttpRequest for RPCGetConstantValRequestHandler {
8383
.unwrap()
8484
}
8585

86+
fn metrics_identifier(&self) -> &str {
87+
"/v2/constant_val/:principal/:contract_name/:const_name"
88+
}
89+
8690
/// Try to decode this request.
8791
/// There's nothing to load here, so just make sure the request is well-formed.
8892
fn try_parse_request(

stackslib/src/net/api/getcontractabi.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,10 @@ impl HttpRequest for RPCGetContractAbiRequestHandler {
7878
.unwrap()
7979
}
8080

81+
fn metrics_identifier(&self) -> &str {
82+
"/v2/contracts/interface/:principal/:contract_name"
83+
}
84+
8185
/// Try to decode this request.
8286
/// There's nothing to load here, so just make sure the request is well-formed.
8387
fn try_parse_request(

stackslib/src/net/api/getcontractsrc.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,10 @@ impl HttpRequest for RPCGetContractSrcRequestHandler {
8686
.unwrap()
8787
}
8888

89+
fn metrics_identifier(&self) -> &str {
90+
"/v2/contracts/source/:principal/:contract_name"
91+
}
92+
8993
/// Try to decode this request.
9094
/// There's nothing to load here, so just make sure the request is well-formed.
9195
fn try_parse_request(

0 commit comments

Comments
 (0)