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

refactor: remove sentry #780

Merged
merged 3 commits into from
Aug 16, 2022
Merged
Show file tree
Hide file tree
Changes from all 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
143 changes: 0 additions & 143 deletions Cargo.lock

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

2 changes: 0 additions & 2 deletions crates/block-producer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@ async-trait = "0.1"
semver = "1.0"
thiserror = "1.0"
# For latest tracing
sentry = { git = "https://github.com/getsentry/sentry-rust", rev = "df694a49595d6890c510d80b85cfbb4b5ae6159a" }
sentry-tracing = { git = "https://github.com/getsentry/sentry-rust", rev = "df694a49595d6890c510d80b85cfbb4b5ae6159a" }
tracing = { version = "0.1", features = ["attributes"] }
tracing-subscriber = { version = "0.3", features = ["env-filter", "parking_lot", "smallvec", "tracing-log"] }
tracing-opentelemetry = "0.17"
Expand Down
12 changes: 0 additions & 12 deletions crates/block-producer/src/runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -557,18 +557,6 @@ impl BaseInitComponents {
}

pub async fn run(config: Config, skip_config_check: bool) -> Result<()> {
// Set up sentry.
let _guard = match &config.sentry_dsn.as_ref() {
Some(sentry_dsn) => sentry::init((
sentry_dsn.as_str(),
sentry::ClientOptions {
release: sentry::release_name!(),
..Default::default()
},
)),
None => sentry::init(()),
};

spawn_starvation_detector();

// Set up runtim monitor.
Expand Down
11 changes: 1 addition & 10 deletions crates/block-producer/src/trace.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use anyhow::Result;
use gw_config::Trace;
use sentry_tracing::EventFilter;
use tracing_subscriber::prelude::*;

pub struct ShutdownGuard {
Expand All @@ -19,17 +18,9 @@ pub fn init(trace: Option<Trace>) -> Result<ShutdownGuard> {
let env_filter_layer = tracing_subscriber::EnvFilter::try_from_default_env()
.or_else(|_| tracing_subscriber::EnvFilter::try_new("info"))?;

// NOTE: `traces_sample_rate` in sentry client option is 0.0 by default, which disable sentry
// tracing. Here we just use sentry-log feature.
let sentry_layer = sentry_tracing::layer().event_filter(|md| match md.level() {
&tracing::Level::ERROR | &tracing::Level::WARN => EventFilter::Event,
_ => EventFilter::Ignore,
});

let registry = tracing_subscriber::registry()
.with(tracing_subscriber::fmt::layer().with_ansi(false))
.with(env_filter_layer)
.with(sentry_layer);
.with(env_filter_layer);

match trace {
Some(Trace::Jaeger) => {
Expand Down
8 changes: 3 additions & 5 deletions crates/config/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ pub struct Config {
#[serde(default)]
pub db_block_validator: Option<DBBlockValidatorConfig>,
pub store: StoreConfig,
pub sentry_dsn: Option<String>,
#[serde(default)]
pub trace: Option<Trace>,
#[serde(default)]
Expand Down Expand Up @@ -467,14 +466,13 @@ pub struct DynamicConfig {
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "lowercase")]
pub enum ContractLogConfig {
Default, //print contract log in place
Redirect, //print all of the contract logs, send error logs to sentry
RedirectError, //only print logs when the tx hit an error, send error logs to sentry
Verbose,
Error,
}

impl Default for ContractLogConfig {
fn default() -> Self {
ContractLogConfig::Default
ContractLogConfig::Verbose
}
}

Expand Down
2 changes: 0 additions & 2 deletions crates/generator/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,7 @@ tokio = "1.15"
arc-swap = "1.5"
ethabi = "16.0.0"
tracing = { version = "0.1", features = ["attributes"] }
sentry = { git = "https://github.com/getsentry/sentry-rust", rev = "df694a49595d6890c510d80b85cfbb4b5ae6159a" }

[dev-dependencies]
gw-utils = {path = "../utils" }
tempfile = "3"
sentry = { git = "https://github.com/getsentry/sentry-rust", rev = "df694a49595d6890c510d80b85cfbb4b5ae6159a", features=["test"] }
2 changes: 2 additions & 0 deletions crates/generator/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,8 @@ pub enum TransactionError {
InsufficientPoolCycles { cycles: RunResultCycles, limit: u64 },
#[error("Exceeded max block cycles: cycles {cycles:?}, limit {limit}")]
ExceededMaxBlockCycles { cycles: RunResultCycles, limit: u64 },
#[error("Convert to UTF-8 error: {0}")]
Utf8Error(std::str::Utf8Error),
}

impl From<VMError> for TransactionError {
Expand Down
15 changes: 8 additions & 7 deletions crates/generator/src/generator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ use crate::{
constants::{L2TX_MAX_CYCLES, MAX_READ_DATA_BYTES_LIMIT, MAX_WRITE_DATA_BYTES_LIMIT},
error::{BlockError, TransactionValidateError, WithdrawalError},
run_result_state::RunResultState,
syscalls::redir_log::RedirLogHandler,
typed_transaction::types::TypedRawTransaction,
types::vm::VMVersion,
utils::get_tx_type,
Expand Down Expand Up @@ -146,7 +145,7 @@ pub struct Generator {
backend_manage: BackendManage,
account_lock_manage: AccountLockManage,
rollup_context: RollupContext,
redir_log_handler: RedirLogHandler,
contract_log_config: ContractLogConfig,
}

impl Generator {
Expand All @@ -156,12 +155,11 @@ impl Generator {
rollup_context: RollupContext,
contract_log_config: ContractLogConfig,
) -> Self {
let redir_log_handler = RedirLogHandler::new(contract_log_config);
Generator {
backend_manage,
account_lock_manage,
rollup_context,
redir_log_handler,
contract_log_config,
}
}

Expand Down Expand Up @@ -190,7 +188,6 @@ impl Generator {
mut cycles_pool,
} = args;

self.redir_log_handler.start(raw_tx);
let mut run_result = RunResult::default();
let used_cycles;
let exit_code;
Expand All @@ -204,6 +201,7 @@ impl Generator {
ver => panic!("Unsupport VMVersion: {}", ver),
};
let core_machine = vm_version.init_core_machine(max_cycles);
let mut sys_log_buf = Vec::with_capacity(1024);
let machine_builder = DefaultMachineBuilder::new(core_machine)
.syscall(Box::new(L2Syscalls {
chain,
Expand All @@ -214,8 +212,8 @@ impl Generator {
account_lock_manage: &self.account_lock_manage,
result: &mut run_result,
code_store: state,
redir_log_handler: &self.redir_log_handler,
cycles_pool: &mut cycles_pool,
log_buf: &mut sys_log_buf,
}))
.instruction_cycle_func(Box::new(instruction_cycles));
let default_machine = machine_builder.build();
Expand Down Expand Up @@ -280,7 +278,10 @@ impl Generator {
return Err(err.into());
}
}
self.redir_log_handler.flush(exit_code);
if self.contract_log_config == ContractLogConfig::Verbose || exit_code != 0 {
let s = std::str::from_utf8(&sys_log_buf).map_err(TransactionError::Utf8Error)?;
log::debug!("[contract debug]: {}", s);
}
log::debug!(
"[execute tx] VM machine_run time: {}ms, exit code: {} used_cycles: {}",
t.elapsed().as_millis(),
Expand Down
Loading