cave/activitypub/send: remove histogram instrumentation
This commit is contained in:
parent
669f9b4e52
commit
5b9ff9213f
|
@ -1,9 +1,8 @@
|
||||||
use std::{
|
use std::{
|
||||||
sync::Arc,
|
sync::Arc,
|
||||||
time::{Instant, SystemTime},
|
time::SystemTime,
|
||||||
};
|
};
|
||||||
use http::StatusCode;
|
use http::StatusCode;
|
||||||
use metrics::histogram;
|
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
use sigh::{PrivateKey, SigningConfig, alg::RsaSha256};
|
use sigh::{PrivateKey, SigningConfig, alg::RsaSha256};
|
||||||
use super::{digest, error::Error};
|
use super::{digest, error::Error};
|
||||||
|
@ -43,20 +42,14 @@ pub async fn send_raw(
|
||||||
.header("digest", digest_header)
|
.header("digest", digest_header)
|
||||||
.body(body.as_ref().clone())
|
.body(body.as_ref().clone())
|
||||||
.map_err(Error::HttpReq)?;
|
.map_err(Error::HttpReq)?;
|
||||||
let t1 = Instant::now();
|
|
||||||
SigningConfig::new(RsaSha256, private_key, key_id)
|
SigningConfig::new(RsaSha256, private_key, key_id)
|
||||||
.sign(&mut req)?;
|
.sign(&mut req)?;
|
||||||
let t2 = Instant::now();
|
|
||||||
let req: reqwest::Request = req.try_into()?;
|
let req: reqwest::Request = req.try_into()?;
|
||||||
let res = client.execute(req)
|
let res = client.execute(req)
|
||||||
.await?;
|
.await?;
|
||||||
let t3 = Instant::now();
|
|
||||||
histogram!("relay_http_request_duration", t2 - t1);
|
|
||||||
if res.status() >= StatusCode::OK && res.status() < StatusCode::MULTIPLE_CHOICES {
|
if res.status() >= StatusCode::OK && res.status() < StatusCode::MULTIPLE_CHOICES {
|
||||||
histogram!("relay_http_response_duration", t3 - t2, "res" => "ok", "host" => host);
|
|
||||||
Ok(())
|
Ok(())
|
||||||
} else {
|
} else {
|
||||||
histogram!("relay_http_response_duration", t3 - t2, "res" => "err", "host" => host);
|
|
||||||
tracing::error!("send_raw {} response HTTP {}", url, res.status());
|
tracing::error!("send_raw {} response HTTP {}", url, res.status());
|
||||||
let response = res.text().await?;
|
let response = res.text().await?;
|
||||||
Err(Error::Response(response))
|
Err(Error::Response(response))
|
||||||
|
|
Loading…
Reference in New Issue