Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(logs)!: reduce logs #1534

Merged
merged 6 commits into from
Mar 29, 2023
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion aquamarine/src/actor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,11 @@ where

let waker = cx.waker().clone();
// Schedule execution of functions
self.functions.execute(r.effects.call_requests, waker);
self.functions.execute(
r.effects.particle.id.clone(),
r.effects.call_requests,
waker,
);

let effects = RoutingEffects {
particle: r.effects.particle,
Expand Down
1 change: 1 addition & 0 deletions aquamarine/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ mod config;
mod deadline;
mod error;
mod invoke;
mod log;
mod particle_data_store;
mod particle_effects;
mod particle_executor;
Expand Down
10 changes: 10 additions & 0 deletions aquamarine/src/log.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/// Function that prescribes different log levels for different builtin namespaces
pub fn builtin_log_level(service: &str) -> log::Level {
match service {
"array" | "cmp" | "debug" | "math" | "op" | "getDataSrv" | "run-console" => {
log::Level::Debug
}
"peer" | "script" | "stat" | "sig" | "srv" | "dist" | "kad" => log::Level::Info,
_ => log::Level::Info,
}
}
31 changes: 24 additions & 7 deletions aquamarine/src/particle_functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,16 @@ use futures::future::BoxFuture;
use futures::stream::FuturesUnordered;
use futures::{FutureExt, StreamExt};
use humantime::format_duration as pretty;
use serde_json::json;
use serde_json::Value as JValue;

use particle_args::{Args, JError};
use particle_execution::{
FunctionOutcome, ParticleFunctionStatic, ParticleParams, ServiceFunction,
};
use peer_metrics::FunctionKind;
use serde_json::json;
use serde_json::Value as JValue;

use crate::log::builtin_log_level;

#[derive(Clone, Debug)]
/// Performance statistics about executed function call
Expand All @@ -44,6 +47,7 @@ pub struct SingleCallStat {

#[derive(Clone, Debug)]
pub struct SingleCallResult {
/// `call_id` comes from AVM's CallRequest
call_id: u32,
result: CallServiceResult,
stat: SingleCallStat,
Expand Down Expand Up @@ -85,10 +89,10 @@ impl<F: ParticleFunctionStatic> Functions<F> {
}

/// Add a bunch of call requests to execution
pub fn execute(&mut self, requests: CallRequests, waker: Waker) {
pub fn execute(&mut self, particle_id: String, requests: CallRequests, waker: Waker) {
let futs: Vec<_> = requests
.into_iter()
.map(|(id, call)| self.call(id, call, waker.clone()))
.map(|(id, call)| self.call(particle_id.clone(), id, call, waker.clone()))
.collect();
self.function_calls.extend(futs);
}
Expand All @@ -114,6 +118,7 @@ impl<F: ParticleFunctionStatic> Functions<F> {
// maybe it's a good option.
fn call(
&self,
particle_id: String,
call_id: u32,
call: CallRequestParams,
waker: Waker,
Expand Down Expand Up @@ -142,6 +147,7 @@ impl<F: ParticleFunctionStatic> Functions<F> {
};

let log_args = format!("{:?} {:?}", args.service_id, args.function_name);
let log_level = builtin_log_level(&args.service_id);

let start = Instant::now();

Expand Down Expand Up @@ -192,10 +198,21 @@ impl<F: ParticleFunctionStatic> Functions<F> {
};

if let Err(err) = &result {
let elapsed = pretty(elapsed);
log::warn!("Failed host call {} ({}): {}", log_args, elapsed, err)
log::warn!(
"Failed host call {} ({}) [{}]: {}",
log_args,
pretty(elapsed),
particle_id,
err
)
} else {
log::info!("Executed host call {} ({})", log_args, pretty(elapsed));
log::log!(
log_level,
"Executed host call {} ({}) [{}]",
log_args,
pretty(elapsed),
particle_id
);
};

let stats = SingleCallStat {
Expand Down
14 changes: 13 additions & 1 deletion particle-node/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,19 @@ async fn main() -> eyre::Result<()> {
.format_timestamp_micros()
// Disable most spamming modules
.filter_module("cranelift_codegen", LevelFilter::Off)
.filter_module("wasmer_wasi_fl", LevelFilter::Off)
.filter_module("walrus", LevelFilter::Off)
folex marked this conversation as resolved.
Show resolved Hide resolved
.filter_module("polling", LevelFilter::Off)
.filter_module("wasmer_wasi_fl", LevelFilter::Error)
.filter_module("wasmer_interface_types_fl", LevelFilter::Error)
.filter_module("wasmer_wasi", LevelFilter::Error)
.filter_module("tide", LevelFilter::Error)
.filter_module("tokio_threadpool", LevelFilter::Error)
.filter_module("tokio_reactor", LevelFilter::Error)
.filter_module("mio", LevelFilter::Error)
.filter_module("tokio_io", LevelFilter::Error)
.filter_module("soketto", LevelFilter::Error)
.filter_module("cranelift_codegen", LevelFilter::Error)
.filter_module("async_io", LevelFilter::Error)
.init();

let version = format!("{}; AIR version {}", VERSION, air_interpreter_wasm::VERSION);
Expand Down