mirror of
https://github.com/redlib-org/redlib.git
synced 2025-06-07 23:27:51 +00:00
Make stats collection opt-out
This commit is contained in:
parent
255307a4f7
commit
5f562876f4
6 changed files with 42 additions and 12 deletions
|
@ -20,10 +20,11 @@ use std::{
|
|||
result::Result,
|
||||
str::{from_utf8, Split},
|
||||
string::ToString,
|
||||
sync::atomic::Ordering::SeqCst,
|
||||
};
|
||||
use time::Duration;
|
||||
|
||||
use crate::{dbg_msg, instance_info::INSTANCE_INFO};
|
||||
use crate::{config, dbg_msg, instance_info::INSTANCE_INFO};
|
||||
|
||||
type BoxResponse = Pin<Box<dyn Future<Output = Result<Response<Body>, String>> + Send>>;
|
||||
|
||||
|
@ -234,8 +235,11 @@ impl Server {
|
|||
match router.recognize(&format!("/{}{}", req.method().as_str(), path)) {
|
||||
// If a route was configured for this path
|
||||
Ok(found) => {
|
||||
// Add to total_requests count
|
||||
INSTANCE_INFO.total_requests.fetch_add(1, std::sync::atomic::Ordering::SeqCst);
|
||||
if config::get_setting("LIBREDDIT_DISABLE_STATS_COLLECTION").is_none() {
|
||||
// Add to total_requests count
|
||||
INSTANCE_INFO.total_requests.fetch_add(1, SeqCst);
|
||||
}
|
||||
|
||||
let mut parammed = req;
|
||||
parammed.set_params(found.params().clone());
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue