summaryrefslogtreecommitdiff
path: root/exes/rest
diff options
context:
space:
mode:
authorMatthieu Pignolet <matthieu@matthieu-dev.xyz>2024-07-07 01:30:15 +0400
committerMatthieu Pignolet <matthieu@matthieu-dev.xyz>2024-07-07 01:30:15 +0400
commit91e622c59e2778073d94515e22b383b5c61624f9 (patch)
tree8ffa76e5700429ad7fe0cc67b1f6948c7d0c76fd /exes/rest
parentc0863b93c3dc463de4abffc2b5ab2412f294967a (diff)
fix some things
Diffstat (limited to 'exes/rest')
-rw-r--r--exes/rest/src/handler.rs23
-rw-r--r--exes/rest/src/lib.rs3
2 files changed, 12 insertions, 14 deletions
diff --git a/exes/rest/src/handler.rs b/exes/rest/src/handler.rs
index a74c7c8..364ca3c 100644
--- a/exes/rest/src/handler.rs
+++ b/exes/rest/src/handler.rs
@@ -33,37 +33,37 @@ lazy_static! {
.init()
};
static ref UPSTREAM_CALLS: Counter<u64> = {
- global::meter(&METER_NAME)
+ global::meter(**&METER_NAME)
.u64_counter("rest.upstream_http_requests_total")
.with_description("Amount of requests sent to discord")
.init()
};
static ref TICKET_CALLS: Counter<u64> = {
- global::meter(&METER_NAME)
+ global::meter(**&METER_NAME)
.u64_counter("rest.ticket_http_requests_total")
.with_description("Amount of requests sent to the ratelimiter")
.init()
};
static ref HEADERS_SUBMIT_CALLS: Counter<u64> = {
- global::meter(&METER_NAME)
+ global::meter(**&METER_NAME)
.u64_counter("rest.header_submit_http_requests_total")
.with_description("Amount of requests sent to the ratelimiter")
.init()
};
static ref UPSTREAM_TIMES: Histogram<u64> = {
- global::meter(&METER_NAME)
+ global::meter(**&METER_NAME)
.u64_histogram("rest.upstream_http_request_duration_miliseconds")
.with_description("Time took to request discord")
.init()
};
static ref TICKET_TIMES: Histogram<u64> = {
- global::meter(&METER_NAME)
+ global::meter(**&METER_NAME)
.u64_histogram("rest.ticket_http_request_duration_miliseconds")
.with_description("Time took to get a ticket from the ratelimiter")
.init()
};
static ref HEADERS_SUBMIT_TIMES: Histogram<u64> = {
- global::meter(&METER_NAME)
+ global::meter(**&METER_NAME)
.u64_histogram("rest.header_submit_http_request_duration_miliseconds")
.with_description("Time took to get a ticket from the ratelimiter")
.init()
@@ -230,10 +230,10 @@ pub async fn handle_request(
(bucket, uri_string, path_name(&path))
};
- REQUESTS.add(&cx, 1, &[KeyValue::new("bucket", name)]);
+ REQUESTS.add( 1, &[KeyValue::new("bucket", name)]);
let ticket_start = SystemTime::now();
- TICKET_CALLS.add(&cx, 1, &[KeyValue::new("bucket", name)]);
+ TICKET_CALLS.add(1, &[KeyValue::new("bucket", name)]);
// waits for the request to be authorized
match ratelimiter
.ticket(bucket.clone())
@@ -243,7 +243,6 @@ pub async fn handle_request(
Ok(_) => {
#[allow(clippy::cast_possible_truncation)]
TICKET_TIMES.record(
- &cx,
ticket_start.elapsed()?.as_millis() as u64,
&[KeyValue::new("bucket", name)],
);
@@ -291,12 +290,11 @@ pub async fn handle_request(
*request.uri_mut() = uri;
let span = debug_span!("upstream request to discord");
let upstream_start = SystemTime::now();
- UPSTREAM_CALLS.add(&cx, 1, &[KeyValue::new("bucket", name)]);
+ UPSTREAM_CALLS.add(1, &[KeyValue::new("bucket", name)]);
let resp = match client.request(request).instrument(span).await {
Ok(response) => {
#[allow(clippy::cast_possible_truncation)]
UPSTREAM_TIMES.record(
- &cx,
upstream_start.elapsed()?.as_millis() as u64,
&[KeyValue::new("bucket", name)],
);
@@ -322,14 +320,13 @@ pub async fn handle_request(
.collect();
let headers_start = SystemTime::now();
- HEADERS_SUBMIT_CALLS.add(&cx, 1, &[KeyValue::new("bucket", name)]);
+ HEADERS_SUBMIT_CALLS.add( 1, &[KeyValue::new("bucket", name)]);
ratelimiter
.submit_headers(bucket.clone(), headers)
.instrument(info_span!("submitting headers"))
.await?;
#[allow(clippy::cast_possible_truncation)]
HEADERS_SUBMIT_TIMES.record(
- &cx,
headers_start.elapsed()?.as_millis() as u64,
&[KeyValue::new("bucket", name)],
);
diff --git a/exes/rest/src/lib.rs b/exes/rest/src/lib.rs
index 917f524..58f232b 100644
--- a/exes/rest/src/lib.rs
+++ b/exes/rest/src/lib.rs
@@ -47,11 +47,12 @@ impl Component for ReverseProxyServer {
));
let https = hyper_rustls::HttpsConnectorBuilder::new()
.with_native_roots()
+ .expect("Native roots not available")
.https_or_http()
.enable_http1()
.build();
- let client: Client<_, hyper::Body> = Client::builder().build(https);
+ let client: Client<_, hyper::body::Body> = Client::builder().build(https);
let token = settings.config.discord.token.clone();
let config = settings.config.clone();
let service_fn = make_service_fn(move |_: &AddrStream| {