Skip to content
Merged
Show file tree
Hide file tree
Changes from 32 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
06eb54a
feat: introduce metrics crate
karlem Jul 4, 2024
46629ad
feat: improve library with macros, add top down events
karlem Jul 5, 2024
89106eb
feat: add domain filter
karlem Jul 5, 2024
f756bd1
feat: emit metrics
karlem Jul 8, 2024
3780b2d
feat: add remaining top down events
karlem Jul 9, 2024
2c9f5f4
feat: fix test
karlem Jul 9, 2024
487560f
feat: remove unused code & fix build
karlem Jul 9, 2024
5ac87a1
feat: keep file journal disabled
karlem Jul 9, 2024
2dcec96
feat: address comments
karlem Jul 10, 2024
90e092b
feat: use latency wrapper instead
karlem Jul 10, 2024
3ef23f3
feat: register metrics
karlem Jul 10, 2024
31dc460
feat: add config filters
karlem Jul 11, 2024
a6bc67a
feat: add config as a cmd flags
karlem Jul 12, 2024
92b9d5f
feat: fix comments
karlem Jul 15, 2024
b693a80
Introduce New Observability - Configuration (#1063)
karlem Jul 15, 2024
366069c
feat: add consensus traces
karlem Jul 12, 2024
deae3bd
feat: add execution metrics
karlem Jul 12, 2024
f78e40c
feat: add proposals metrics & reason
karlem Jul 15, 2024
9086667
feat: add mempool event
karlem Jul 16, 2024
dd6e49f
feat: remove
karlem Jul 16, 2024
43e7d51
feat: add metrics
karlem Jul 16, 2024
4eb611f
feat: address comments
karlem Jul 16, 2024
d4e8a54
feat: address comments
karlem Jul 16, 2024
053d614
feat: fix clippy
karlem Jul 16, 2024
71a57cf
Introduce New Observability - Remaining events (#1064)
karlem Jul 16, 2024
2093d38
minor cleanup.
raulk Jul 16, 2024
8c63b8c
Merge branch 'main' into new-observability
raulk Jul 16, 2024
e590217
fix code typo.
raulk Jul 16, 2024
1ecb44f
feat: fix typo
karlem Jul 16, 2024
2a0b425
feat: standartize mpool trace
karlem Jul 16, 2024
e7e7cb5
feat: address comments
karlem Jul 18, 2024
0e7c1f1
lint: clippy
karlem Jul 18, 2024
3a94fed
feat: revert risky changes & small cleanup
karlem Jul 19, 2024
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
19 changes: 19 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 7 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ members = [
"ipc/provider",
"ipc/api",
"ipc/types",
"ipc/observability",

# ipld
"ipld/resolver",
Expand Down Expand Up @@ -157,7 +158,11 @@ tokio-util = { version = "0.7.8", features = ["compat"] }
tokio-tungstenite = { version = "0.18.0", features = ["native-tls"] }
toml = "0.8"
tracing = "0.1"
tracing-subscriber = { version = "0.3", features = ["env-filter", "json", "registry"] }
tracing-subscriber = { version = "0.3", features = [
"env-filter",
"json",
"registry",
] }
tracing-appender = "0.2.3"
url = { version = "2.4.1", features = ["serde"] }
zeroize = "1.6"
Expand All @@ -168,6 +173,7 @@ ipc-provider = { path = "ipc/provider" }
ipc-wallet = { path = "ipc/wallet", features = ["with-ethers"] }
ipc_ipld_resolver = { path = "ipld/resolver" }
ipc-types = { path = "ipc/types" }
ipc-observability = { path = "ipc/observability" }
ipc_actors_abis = { path = "contracts/binding" }

# Vendored for cross-compilation, see https://github.com/cross-rs/cross/wiki/Recipes#openssl
Expand Down
3 changes: 2 additions & 1 deletion fendermint/abci/examples/kvstore.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ impl Application for KVStore {
&self,
request: request::PrepareProposal,
) -> Result<response::PrepareProposal> {
let mut txs = take_until_max_size(request.txs, request.max_tx_bytes.try_into().unwrap());
let (txs, _) = take_until_max_size(request.txs, request.max_tx_bytes.try_into().unwrap());
let mut txs = txs.clone();

// Enfore transaciton limit so that we don't have a problem with buffering.
txs.truncate(MAX_TXNS);
Expand Down
2 changes: 1 addition & 1 deletion fendermint/abci/src/application.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ pub trait Application {
&self,
request: request::PrepareProposal,
) -> AbciResult<response::PrepareProposal> {
let txs = take_until_max_size(request.txs, request.max_tx_bytes.try_into().unwrap());
let (txs, _) = take_until_max_size(request.txs, request.max_tx_bytes.try_into().unwrap());

Ok(response::PrepareProposal { txs })
}
Expand Down
4 changes: 2 additions & 2 deletions fendermint/abci/src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
/// Take the first transactions until the first one that would exceed the maximum limit.
///
/// The function does not skip or reorder transaction even if a later one would stay within the limit.
pub fn take_until_max_size<T: AsRef<[u8]>>(txs: Vec<T>, max_tx_bytes: usize) -> Vec<T> {
pub fn take_until_max_size<T: AsRef<[u8]>>(txs: Vec<T>, max_tx_bytes: usize) -> (Vec<T>, usize) {
let mut size: usize = 0;
let mut out = Vec::new();
for tx in txs {
Expand All @@ -15,5 +15,5 @@ pub fn take_until_max_size<T: AsRef<[u8]>>(txs: Vec<T>, max_tx_bytes: usize) ->
size += bz.len();
out.push(tx);
}
out
(out, size)
}
2 changes: 2 additions & 0 deletions fendermint/app/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ fendermint_vm_resolver = { path = "../vm/resolver" }
fendermint_vm_snapshot = { path = "../vm/snapshot" }
fendermint_vm_topdown = { path = "../vm/topdown" }


fvm = { workspace = true }
fvm_ipld_blockstore = { workspace = true }
fvm_ipld_car = { workspace = true }
Expand All @@ -72,6 +73,7 @@ fvm_shared = { workspace = true }
ipc-api = { workspace = true }
ipc-provider = { workspace = true }
ipc_ipld_resolver = { workspace = true }
ipc-observability = { workspace = true }

[dev-dependencies]
tempfile = { workspace = true }
Expand Down
1 change: 1 addition & 0 deletions fendermint/app/options/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ fvm_shared = { workspace = true }
ipc-api = { workspace = true }
ipc-types = { workspace = true }
url = { workspace = true }
ipc-observability = { workspace = true }

fendermint_vm_genesis = { path = "../../vm/genesis" }
fendermint_vm_actor_interface = { path = "../../vm/actor_interface" }
Expand Down
53 changes: 48 additions & 5 deletions fendermint/app/options/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use clap::{Args, Parser, Subcommand};
use config::ConfigArgs;
use debug::DebugArgs;
use fvm_shared::address::Network;
use ipc_observability::traces::FileLayerConfig;
use lazy_static::lazy_static;
use tracing_subscriber::EnvFilter;

Expand All @@ -27,7 +28,7 @@ pub mod run;
mod log;
mod parse;

use log::{parse_log_level, LogLevel};
use log::{parse_log_level, parse_rotation_kind, LogLevel, RotationKind};
use parse::parse_network;

lazy_static! {
Expand Down Expand Up @@ -102,13 +103,44 @@ pub struct Options {
#[arg(long, env = "FM_CONFIG_DIR")]
config_dir: Option<PathBuf>,

// TODO Karel - move all FM_LOG_FILE* flags to a configuration file instead
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's land the final config experience before merging this to main. Agree that this should be configured via the config.toml. Best way would be to group all these options in a struct, and place that struct in the ipc-observability crate, where it can then be embedded in the various configuration files of the various binaries (e.g. the relayer has its own configuration file, and it should also write a journal).

Copy link
Copy Markdown
Contributor Author

@karlem karlem Jul 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alright - there is an issue for it. I can pick it up once we finish review of this PR.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#1078 dropping it here to have the configuration PR linked. It's almost done!


// Enable logging to a file.
#[arg(long, env = "FM_LOG_FILE_ENABLED")]
pub log_file_enabled: Option<bool>,

/// Set a custom directory for ipc log files.
#[arg(long, env = "FM_LOG_DIR")]
#[arg(long, env = "FM_LOG_FILE_DIR")]
pub log_dir: Option<PathBuf>,

/// Set a custom prefix for ipc log files.
#[arg(long, env = "FM_LOG_FILE_PREFIX")]
pub log_file_prefix: Option<String>,
#[arg(long, env = "FM_LOG_FILE_MAX_FILES")]
pub max_log_files: Option<usize>,

#[arg(
long,
default_value = "daily",
value_enum,
env = "FM_LOG_FILE_ROTATION",
help = "The kind of rotation to use for log files. Options: minutely, hourly, daily, never.",
value_parser = parse_rotation_kind,
)]
pub log_files_rotation: Option<RotationKind>,

#[arg(
long,
env = "FM_LOG_FILE_DOMAINS_FILTER",
help = "Filter log events by domains. Only events from the specified domains will be logged. Comma separated.",
value_delimiter = ','
)]
pub domains_filter: Option<Vec<String>>,

#[arg(
long,
env = "FM_LOG_FILE_EVENTS_FILTER",
help = "Filter log events by name. Only events with the specified names will be logged. Comma separated.",
value_delimiter = ','
)]
pub events_filter: Option<Vec<String>>,

/// Optionally override the default configuration.
#[arg(short, long, default_value = "dev")]
Expand Down Expand Up @@ -162,6 +194,17 @@ impl Options {
}
}

pub fn log_file_config(&self) -> FileLayerConfig {
FileLayerConfig {
enabled: self.log_file_enabled.unwrap_or(false),
directory: self.log_dir.clone(),
max_log_files: self.max_log_files,
rotation: self.log_files_rotation.clone(),
domain_filter: self.domains_filter.clone(),
events_filter: self.events_filter.clone(),
}
}

/// Path to the configuration directories.
///
/// If not specified then returns the default under the home directory.
Expand Down
12 changes: 12 additions & 0 deletions fendermint/app/options/src/log.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ use clap::{builder::PossibleValue, ValueEnum};
use lazy_static::lazy_static;
use tracing_subscriber::EnvFilter;

pub use ipc_observability::traces::RotationKind;

/// Standard log levels, or something we can pass to <https://docs.rs/tracing-subscriber/latest/tracing_subscriber/filter/struct.EnvFilter.html>
///
/// To be fair all of these could be handled by the `EnvFilter`, even `off`,
Expand Down Expand Up @@ -79,3 +81,13 @@ pub fn parse_log_level(s: &str) -> Result<LogLevel, String> {
Ok(LogLevel::Filter(s.to_string()))
}
}

pub fn parse_rotation_kind(s: &str) -> Result<RotationKind, String> {
match s {
"minutely" => Ok(RotationKind::Minutely),
"hourly" => Ok(RotationKind::Hourly),
"daily" => Ok(RotationKind::Daily),
"never" => Ok(RotationKind::Never),
_ => Err(format!("invalid rotation kind: {}", s)),
}
}
Loading