Skip to content

Commit

Permalink
Use count.try_into() as inc_by argument.
Browse files Browse the repository at this point in the history
The Counter type used by Prometheus is platform specific, e.g. for MIPS
it uses a u32 instead of u64. Using try_into() we can make the inc_by
argument platform agnostic.
  • Loading branch information
brocaar committed Oct 29, 2023
1 parent 34c6a44 commit d464745
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ pub fn incr_udp_sent_bytes(server: &str, typ: &str, count: usize) {
server: server.to_string(),
r#type: typ.to_string(),
})
.inc_by(count as u64);
.inc_by(count.try_into().unwrap());
}

pub fn incr_udp_received_count(server: &str, typ: &str) {
Expand All @@ -98,7 +98,7 @@ pub fn incr_udp_received_bytes(server: &str, typ: &str, count: usize) {
server: server.to_string(),
r#type: typ.to_string(),
})
.inc_by(count as u64);
.inc_by(count.try_into().unwrap());
}

fn handle_request(stream: TcpStream) {
Expand Down

0 comments on commit d464745

Please sign in to comment.