You've already forked AstralRinth
forked from didirus/AstralRinth
Tracing support (#3372)
* Tracing support * Add console subscriber * Add console subscriber
This commit is contained in:
@@ -21,6 +21,11 @@ prometheus = "0.13.4"
|
||||
actix-web-prom = { version = "0.9.0", features = ["process"] }
|
||||
governor = "0.6.3"
|
||||
|
||||
tracing = "0.1.41"
|
||||
tracing-subscriber = "0.3.19"
|
||||
tracing-actix-web = "0.7.16"
|
||||
console-subscriber = "0.4.1"
|
||||
|
||||
tokio = { version = "1.35.1", features = ["sync"] }
|
||||
tokio-stream = "0.1.14"
|
||||
|
||||
@@ -74,8 +79,6 @@ censor = "0.3.0"
|
||||
spdx = { version = "0.10.3", features = ["text"] }
|
||||
|
||||
dotenvy = "0.15.7"
|
||||
log = "0.4.20"
|
||||
env_logger = "0.10.1"
|
||||
thiserror = "1.0.56"
|
||||
either = "1.13"
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
use log::info;
|
||||
use prometheus::{IntGauge, Registry};
|
||||
use sqlx::migrate::MigrateDatabase;
|
||||
use sqlx::postgres::{PgPool, PgPoolOptions};
|
||||
use sqlx::{Connection, PgConnection, Postgres};
|
||||
use std::time::Duration;
|
||||
use tracing::info;
|
||||
|
||||
pub async fn connect() -> Result<PgPool, sqlx::Error> {
|
||||
info!("Initializing database connection");
|
||||
|
||||
@@ -4,12 +4,12 @@ use std::time::Duration;
|
||||
|
||||
use actix_web::web;
|
||||
use database::redis::RedisPool;
|
||||
use log::{info, warn};
|
||||
use queue::{
|
||||
analytics::AnalyticsQueue, payouts::PayoutsQueue, session::AuthQueue,
|
||||
socket::ActiveSockets,
|
||||
};
|
||||
use sqlx::Postgres;
|
||||
use tracing::{info, warn};
|
||||
|
||||
extern crate clickhouse as clickhouse_crate;
|
||||
use clickhouse_crate::Client;
|
||||
|
||||
@@ -1,13 +1,16 @@
|
||||
use actix_web::{App, HttpServer};
|
||||
use actix_web_prom::PrometheusMetricsBuilder;
|
||||
use env_logger::Env;
|
||||
use labrinth::database::redis::RedisPool;
|
||||
use labrinth::file_hosting::S3Host;
|
||||
use labrinth::search;
|
||||
use labrinth::util::ratelimit::RateLimit;
|
||||
use labrinth::{check_env_vars, clickhouse, database, file_hosting, queue};
|
||||
use log::{error, info};
|
||||
use std::sync::Arc;
|
||||
use tracing::{error, info};
|
||||
use tracing_actix_web::TracingLogger;
|
||||
use tracing_subscriber::layer::SubscriberExt;
|
||||
use tracing_subscriber::util::SubscriberInitExt;
|
||||
use tracing_subscriber::{fmt, EnvFilter};
|
||||
|
||||
#[cfg(feature = "jemalloc")]
|
||||
#[global_allocator]
|
||||
@@ -21,8 +24,7 @@ pub struct Pepper {
|
||||
#[actix_rt::main]
|
||||
async fn main() -> std::io::Result<()> {
|
||||
dotenvy::dotenv().ok();
|
||||
env_logger::Builder::from_env(Env::default().default_filter_or("info"))
|
||||
.init();
|
||||
console_subscriber::init();
|
||||
|
||||
if check_env_vars() {
|
||||
error!("Some environment variables are missing!");
|
||||
@@ -123,6 +125,7 @@ async fn main() -> std::io::Result<()> {
|
||||
// Init App
|
||||
HttpServer::new(move || {
|
||||
App::new()
|
||||
.wrap(TracingLogger::default())
|
||||
.wrap(prometheus.clone())
|
||||
.wrap(RateLimit(Arc::clone(&labrinth_config.rate_limiter)))
|
||||
.wrap(actix_web::middleware::Compress::default())
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
use flate2::read::GzDecoder;
|
||||
use log::warn;
|
||||
use maxminddb::geoip2::Country;
|
||||
use std::io::{Cursor, Read};
|
||||
use std::net::Ipv6Addr;
|
||||
use tar::Archive;
|
||||
use tokio::sync::RwLock;
|
||||
use tracing::warn;
|
||||
|
||||
pub struct MaxMindIndexer {
|
||||
pub reader: RwLock<Option<maxminddb::Reader<Vec<u8>>>>,
|
||||
|
||||
@@ -15,12 +15,12 @@ use crate::search::SearchConfig;
|
||||
use crate::util::date::get_current_tenths_of_ms;
|
||||
use crate::util::guards::admin_key_guard;
|
||||
use actix_web::{get, patch, post, web, HttpRequest, HttpResponse};
|
||||
use log::info;
|
||||
use serde::Deserialize;
|
||||
use sqlx::PgPool;
|
||||
use std::collections::HashMap;
|
||||
use std::net::Ipv4Addr;
|
||||
use std::sync::Arc;
|
||||
use tracing::info;
|
||||
|
||||
pub fn config(cfg: &mut web::ServiceConfig) {
|
||||
cfg.service(
|
||||
|
||||
@@ -17,7 +17,6 @@ use crate::routes::ApiError;
|
||||
use actix_web::{delete, get, patch, post, web, HttpRequest, HttpResponse};
|
||||
use ariadne::ids::base62_impl::{parse_base62, to_base62};
|
||||
use chrono::Utc;
|
||||
use log::{info, warn};
|
||||
use rust_decimal::prelude::ToPrimitive;
|
||||
use rust_decimal::Decimal;
|
||||
use serde::Serialize;
|
||||
@@ -34,6 +33,7 @@ use stripe::{
|
||||
PaymentIntentSetupFutureUsage, PaymentMethodId, SetupIntent,
|
||||
UpdateCustomer, Webhook,
|
||||
};
|
||||
use tracing::{info, warn};
|
||||
|
||||
pub fn config(cfg: &mut web::ServiceConfig) {
|
||||
cfg.service(
|
||||
|
||||
@@ -114,7 +114,7 @@ pub async fn ws_init(
|
||||
.insert(socket_id);
|
||||
|
||||
#[cfg(debug_assertions)]
|
||||
log::info!("Connection {socket_id} opened by {}", user.id);
|
||||
tracing::info!("Connection {socket_id} opened by {}", user.id);
|
||||
|
||||
broadcast_friends(
|
||||
user.id,
|
||||
@@ -161,7 +161,10 @@ pub async fn ws_init(
|
||||
|
||||
#[cfg(debug_assertions)]
|
||||
if !message.is_binary() {
|
||||
log::info!("Received message from {socket_id}: {:?}", message);
|
||||
tracing::info!(
|
||||
"Received message from {socket_id}: {:?}",
|
||||
message
|
||||
);
|
||||
}
|
||||
|
||||
match message {
|
||||
|
||||
@@ -31,11 +31,11 @@ use actix_web::{web, HttpRequest, HttpResponse};
|
||||
use chrono::Utc;
|
||||
use futures::stream::StreamExt;
|
||||
use itertools::Itertools;
|
||||
use log::error;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use sqlx::postgres::PgPool;
|
||||
use std::collections::{HashMap, HashSet};
|
||||
use std::sync::Arc;
|
||||
use tracing::error;
|
||||
use validator::Validate;
|
||||
|
||||
fn default_requested_status() -> VersionStatus {
|
||||
|
||||
@@ -36,7 +36,7 @@ impl Drop for Scheduler {
|
||||
}
|
||||
}
|
||||
|
||||
use log::{info, warn};
|
||||
use tracing::{info, warn};
|
||||
|
||||
pub fn schedule_versions(
|
||||
scheduler: &mut Scheduler,
|
||||
|
||||
@@ -2,8 +2,8 @@ use chrono::{DateTime, Utc};
|
||||
use dashmap::DashMap;
|
||||
use futures::TryStreamExt;
|
||||
use itertools::Itertools;
|
||||
use log::info;
|
||||
use std::collections::HashMap;
|
||||
use tracing::info;
|
||||
|
||||
use super::IndexingError;
|
||||
use crate::database::models::loader_fields::{
|
||||
|
||||
@@ -5,12 +5,12 @@ use crate::database::redis::RedisPool;
|
||||
use crate::search::{SearchConfig, UploadSearchProject};
|
||||
use ariadne::ids::base62_impl::to_base62;
|
||||
use local_import::index_local;
|
||||
use log::info;
|
||||
use meilisearch_sdk::client::{Client, SwapIndexes};
|
||||
use meilisearch_sdk::indexes::Index;
|
||||
use meilisearch_sdk::settings::{PaginationSetting, Settings};
|
||||
use sqlx::postgres::PgPool;
|
||||
use thiserror::Error;
|
||||
use tracing::info;
|
||||
#[derive(Error, Debug)]
|
||||
pub enum IndexingError {
|
||||
#[error("Error while connecting to the MeiliSearch database")]
|
||||
|
||||
Reference in New Issue
Block a user