Skip to content

Commit

Permalink
chore: remove log4rs and switch to tracing ecosystem
Browse files Browse the repository at this point in the history
Signed-off-by: Alex Chi <[email protected]>
  • Loading branch information
skyzh authored Jan 28, 2022
1 parent 1b94bcb commit 5f077b9
Show file tree
Hide file tree
Showing 25 changed files with 107 additions and 123 deletions.
2 changes: 1 addition & 1 deletion .github/workflow-template/template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ jobs:
chmod +x ./rust/target/debug/risingwave_regress_test
./scripts/start_cluster.sh 3
psql --version
cd rust && target/debug/risingwave_regress_test -h 127.0.0.1 \
RUST_LOG=info cd rust && target/debug/risingwave_regress_test -h 127.0.0.1 \
-p ${{ env.RW_PORT }} \
--input `pwd`/tests/regress/data \
--output `pwd`/tests/regress/output \
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ jobs:
chmod +x ./rust/target/debug/risingwave_regress_test
./scripts/start_cluster.sh 3
psql --version
cd rust && target/debug/risingwave_regress_test -h 127.0.0.1 \
RUST_LOG=info cd rust && target/debug/risingwave_regress_test -h 127.0.0.1 \
-p ${{ env.RW_PORT }} \
--input `pwd`/tests/regress/data \
--output `pwd`/tests/regress/output \
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ jobs:
chmod +x ./rust/target/debug/risingwave_regress_test
./scripts/start_cluster.sh 3
psql --version
cd rust && target/debug/risingwave_regress_test -h 127.0.0.1 \
RUST_LOG=info cd rust && target/debug/risingwave_regress_test -h 127.0.0.1 \
-p ${{ env.RW_PORT }} \
--input `pwd`/tests/regress/data \
--output `pwd`/tests/regress/output \
Expand Down
28 changes: 13 additions & 15 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,28 +54,26 @@ It will start processes in the background. After testing, you can run the follow

## Monitoring

RisingWave internally records performance counters and statistics. Currently they can be enabled and explored with following steps:
Uncomment `grafana` and `prometheus` services in `riselab.yml`, and you can view the metrics.

```shell
./compute-node [--other-startup-options] --metrics-level 1
```
## Tracing

After compute node gets started, [Prometheus](https://github.com/prometheus/prometheus) can be used to pull metrics from compute node's endpoint by using:
Compute node supports streaming tracing. Simply uncomment `jaeger` service in `riselab.yml`.

```shell
./prometheus --config.file=rust/storage/src/metrics/prometheus.yml
```
## Dashboard

By now, you can get the time-seris metrics provided by `Prometheus` through `curl` or visiting the website (`http://localhost:9090`):
You may use RisingWave Dashboard to see actors in the system. It will be started along with meta node.

```shell
curl http://localhost:9090/metrics
```
Furthermore, [Grafana](https://prometheus.io/docs/visualization/grafana/) can be used to provide better visualization of the metrics. After following the official instructions by Grafana, you can use browser to visit `http://localhost:3000/` to get the metrics dashboard.
## Logging

## Tracing
The Java frontend uses `logback.xml` to configure its logging config.

The Rust components use `tokio-tracing` to handle both logging and tracing. The default log level is set as:

* Third-party libraries: warn
* Other libraries: debug

Compute node supports streaming tracing. To enable this, either enable `tracing` functionality in `RiseLAB` by `./riselab configure`, or pass `--enable-tracing` to the `compute-node` binary.
If you need to adjust log levels, simply change the logging filters in `compute_node.rs` and `meta_node.rs`.

## Code Formatting

Expand Down
1 change: 0 additions & 1 deletion Makefile.toml
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,6 @@ script = '''
set -e
cp "java/pgserver/src/main/resources/logback.xml" "${PREFIX_CONFIG}/logback.xml"
cp "rust/config/log4rs.yaml" "${PREFIX_CONFIG}/log4rs.yaml"
cp "grafana/dashboard.json" "${PREFIX_CONFIG}/grafana_dashboard.json"
cp "rust/config/risingwave.toml" "${PREFIX_CONFIG}/risingwave.toml"
cp "rust/riselab/run_command.sh" "${PREFIX_BIN}/run_command.sh"
Expand Down
14 changes: 5 additions & 9 deletions rust/Cargo.lock

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

1 change: 0 additions & 1 deletion rust/batch/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ risingwave-pb = { path = "../prost" }
risingwave_common = { path = "../common" }
risingwave_source = { path = "../source" }
risingwave_storage = { path = "../storage" }
rust_decimal = "1"
serde = { version = "1", features = ["derive"] }
serde-value = "0.7"
serde_json = "1"
Expand Down
58 changes: 0 additions & 58 deletions rust/config/log4rs.yaml

This file was deleted.

1 change: 0 additions & 1 deletion rust/connector/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ rdkafka = { version = "0.28", features = ["cmake-build"] }
risingwave-pb = { path = "../prost" }
risingwave_common = { path = "../common" }
risingwave_storage = { path = "../storage" }
rust_decimal = "1"
serde = { version = "1", features = ["derive"] }
serde-protobuf = "0.8"
serde-value = "0.7"
Expand Down
3 changes: 2 additions & 1 deletion rust/frontend/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ dyn-clone = "1.0.4"
itertools = "0.10"
lazy_static = "1"
log = "0.4"
log4rs = "1"
paste = "1"
pgwire = { path = "../utils/pgwire" }
risingwave-pb = { path = "../prost" }
Expand All @@ -29,6 +28,8 @@ smallvec = { version = "1.6.1", features = ["serde"] }
thiserror = "1"
tokio = { version = "1", features = ["rt", "rt-multi-thread", "sync", "macros", "time", "signal", "fs"] }
tonic = "0.6"
tracing = "0.1"
tracing-subscriber = "0.3"

[dev-dependencies]
serial_test = "*"
Expand Down
32 changes: 31 additions & 1 deletion rust/frontend/src/bin/frontend_node.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
use tracing::Level;
use tracing_subscriber::filter;
use tracing_subscriber::layer::SubscriberExt;
use tracing_subscriber::prelude::*;

#[cfg(not(tarpaulin_include))]
#[tokio::main(flavor = "multi_thread", worker_threads = 4)]
async fn main() {
Expand All @@ -9,7 +14,32 @@ async fn main() {
use pgwire::pg_server::pg_serve;

let opts: FrontendOpts = FrontendOpts::parse();
log4rs::init_file(&opts.log4rs_config, Default::default()).unwrap();

let fmt_layer = {
// Configure log output to stdout
let fmt_layer = tracing_subscriber::fmt::layer().compact().with_ansi(false);
let filter = filter::Targets::new()
// Only enable WARN and ERROR for 3rd-party crates
.with_target("rusoto_core", Level::WARN)
.with_target("hyper", Level::WARN)
.with_target("h2", Level::WARN)
.with_target("tower", Level::WARN)
.with_target("isahc", Level::WARN)
.with_target("sled", Level::WARN);

// Configure RisingWave's own crates to log at TRACE level, uncomment the following line if
// needed.

// let filter = configure_risingwave_targets(filter);

// Enable DEBUG level for all other crates
// TODO: remove this in release mode
let filter = filter.with_default(Level::DEBUG);

fmt_layer.with_filter(filter)
};

tracing_subscriber::registry().with(fmt_layer).init();

let session_mgr = Arc::new(RwSessionManager::new(&opts).await.unwrap());
pg_serve(&opts.host, session_mgr).await.unwrap();
Expand Down
4 changes: 0 additions & 4 deletions rust/frontend/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@ mod test_utils;
use clap::Parser;
#[derive(Parser, Clone)]
pub struct FrontendOpts {
// The custom log4rs config file.
#[clap(long, default_value = "config/log4rs.yaml")]
pub log4rs_config: String,

#[clap(long, default_value = "127.0.0.1:4566")]
pub host: String,

Expand Down
6 changes: 3 additions & 3 deletions rust/meta/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,10 @@ crc32fast = "1"
dashmap = "5"
either = "1"
futures = "0.3"
hyper = "0.14.16"
hyper = "0.14"
itertools = "0.10"
lazy_static = "1"
log = "0.4"
log4rs = "1"
memcomparable = { path = "../utils/memcomparable" }
num-integer = "0.1"
num-traits = "0.2"
Expand All @@ -35,7 +34,6 @@ risingwave-pb = { path = "../prost" }
risingwave_common = { path = "../common" }
risingwave_rpc_client = { path = "../rpc_client" }
risingwave_storage = { path = "../storage" }
rust_decimal = "1"
serde = { version = "1", features = ["derive"] }
serde-value = "0.7"
serde_derive = "1"
Expand All @@ -50,6 +48,8 @@ tokio-stream = { version = "0.1", features = ["net"] }
tonic = "0.6"
tower = { version = "0.4", features = ["util", "load-shed"] }
tower-http = { version = "0.2", features = ["add-extension", "cors"] }
tracing = "0.1"
tracing-subscriber = "0.3"
uuid = { version = "0.8", features = ["v4"] }

[dev-dependencies]
Expand Down
Loading

0 comments on commit 5f077b9

Please sign in to comment.