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

1892 tracing #1957

Merged
merged 8 commits into from Jan 29, 2020
Merged

1892 tracing #1957

merged 8 commits into from Jan 29, 2020

Conversation

@tcharding
Copy link
Contributor

tcharding commented Jan 29, 2020

Convert code base to use tokio-rs tracing library. With this applied (after running btc_eth/happy e2e test):

Jan 29 14:12:50.122  INFO cnd::trace: Initialized tracing with level: TRACE
Jan 29 14:12:50.122  INFO cnd::seed: RootSeed file parent directory does not exist, creating recursively: /tmp/tmp-125556e02qp5UNTGu/seed.pem
Jan 29 14:12:50.122  INFO cnd::seed: No seed file found, creating at: /tmp/tmp-125556e02qp5UNTGu/seed.pem
Jan 29 14:12:50.288  INFO cnd::db: SQLite database file: /tmp/tmp-125556e02qp5UNTGu/cnd.sqlite
Jan 29 14:12:50.290  INFO cnd::network: Starting with peer_id: QmafYkp7uHUj3FghWAbPZDbRTEFtJRdH3nQF5kXBYdXQYt
Jan 29 14:12:50.293 DEBUG cnd::load_swaps: loading swaps from database ...
Jan 29 14:12:50.295  INFO cnd: Starting HTTP server on 0.0.0.0:42789
Jan 29 14:12:53.583 TRACE cnd::http_api::routes::rfc003::handlers::post_swap: initiating new request: 932784b5-8ed9-47c1-8219-f216a9e0a017
Jan 29 14:12:53.589  INFO http: 127.0.0.1:39774 "POST /swaps/rfc003 HTTP/1.1" 201 "-" "axios/0.19.0" 39.353322ms    
Jan 29 14:12:53.589 DEBUG cnd::network: Making swap request to QmQskR8UngQvXfHrvrubAACkhQNVo4D2dPowjW81hWUxSu@/ip4/127.0.0.1/tcp/33085: SwapId(932784b5-8ed9-47c1-8219-f216a9e0a017)

And we get the same total number of log lines from running btc_eth/happy e2e test as before.

Fixes: #1892

tcharding added 5 commits Jan 28, 2020
Add tracing, initialize a subscriber, log a single event
'tracing initialized'.
Use tracing library for all log events.  This is simply a matter of replacing
logging calls that use `log::foo` with `tracing::foo`.
We can convert all upstream logging events to use tracing and be
available for the default subscriber simply by using the line

	LogTracer::init()?;

Connect upstream libraries to tracing using LogTracer.
Convert the current logging configuration to configure tracing instead.
Now we have tracing convert the `libp2p-comit` crate to use it.
@tcharding tcharding requested review from thomaseizinger, luckysori and D4nte Jan 29, 2020
@tcharding tcharding self-assigned this Jan 29, 2020
@mergify

This comment has been minimized.

Copy link
Contributor

mergify bot commented Jan 29, 2020

Are you sure the changelog does not need updating?

@D4nte
D4nte approved these changes Jan 29, 2020
Clippy is emitting warnings that the cognitive complexity is to high.
Refactor the error variants into a separate function.  This actually
does not clear the warning but the code is cleaner anyways.  Add an
attribute to quieten Clippy to the newly created function.

fn level_from_level_filter(level: LevelFilter) -> Level {
match level {
LevelFilter::Off => Level::ERROR,

This comment has been minimized.

Copy link
@thomaseizinger

thomaseizinger Jan 29, 2020

Member

Why are we not respecting off? Could just not initialize anything?

This comment has been minimized.

Copy link
@tcharding

tcharding Jan 29, 2020

Author Contributor

Good idea, will implement.

let base_log_level = settings.logging.level;
logging::initialize(base_log_level, settings.logging.structured)?;
// We still want upstream library log messages, just only at Info level.
LogTracer::init_with_filter(LevelFilter::Info)?;

This comment has been minimized.

Copy link
@thomaseizinger

thomaseizinger Jan 29, 2020

Member

I would see this as part of the initialization, no?
Why add this level of detail to main?

This comment has been minimized.

Copy link
@tcharding

tcharding Jan 29, 2020

Author Contributor

Good point, thanks. Implemented.

Tracing library at some times causes Clippy to emit a cognitive complexity
warning.  Issue raised on the tokio-rs/tracing repo

	tokio-rs/tracing#553

Add Clippy attributes to allow cognitive complexity where needed.
Some of the initialization is in main still, do it all within the init
function.  While we are at it, lets respect `LevelFilter::Off` to allow
tracing to be turned off.
@tcharding tcharding removed the no-mergify label Jan 29, 2020
@tcharding

This comment has been minimized.

Copy link
Contributor Author

tcharding commented Jan 29, 2020

bors r+

bors bot added a commit that referenced this pull request Jan 29, 2020
Merge #1957
1957: 1892 tracing r=tcharding a=tcharding

Convert code base to use tokio-rs tracing library.  With this applied (after running btc_eth/happy e2e test):
```
Jan 29 14:12:50.122  INFO cnd::trace: Initialized tracing with level: TRACE
Jan 29 14:12:50.122  INFO cnd::seed: RootSeed file parent directory does not exist, creating recursively: /tmp/tmp-125556e02qp5UNTGu/seed.pem
Jan 29 14:12:50.122  INFO cnd::seed: No seed file found, creating at: /tmp/tmp-125556e02qp5UNTGu/seed.pem
Jan 29 14:12:50.288  INFO cnd::db: SQLite database file: /tmp/tmp-125556e02qp5UNTGu/cnd.sqlite
Jan 29 14:12:50.290  INFO cnd::network: Starting with peer_id: QmafYkp7uHUj3FghWAbPZDbRTEFtJRdH3nQF5kXBYdXQYt
Jan 29 14:12:50.293 DEBUG cnd::load_swaps: loading swaps from database ...
Jan 29 14:12:50.295  INFO cnd: Starting HTTP server on 0.0.0.0:42789
Jan 29 14:12:53.583 TRACE cnd::http_api::routes::rfc003::handlers::post_swap: initiating new request: 932784b5-8ed9-47c1-8219-f216a9e0a017
Jan 29 14:12:53.589  INFO http: 127.0.0.1:39774 "POST /swaps/rfc003 HTTP/1.1" 201 "-" "axios/0.19.0" 39.353322ms    
Jan 29 14:12:53.589 DEBUG cnd::network: Making swap request to QmQskR8UngQvXfHrvrubAACkhQNVo4D2dPowjW81hWUxSu@/ip4/127.0.0.1/tcp/33085: SwapId(932784b5-8ed9-47c1-8219-f216a9e0a017)
```

And we get the same total number of log lines from running btc_eth/happy e2e test as before.

Fixes: #1892

Co-authored-by: Tobin C. Harding <tobin.harding@coblox.tech>
@mergify

This comment has been minimized.

Copy link
Contributor

mergify bot commented Jan 29, 2020

bors r+

@bors

This comment has been minimized.

Copy link
Contributor

bors bot commented Jan 29, 2020

Already running a review

@bors

This comment has been minimized.

Copy link
Contributor

bors bot commented Jan 29, 2020

@bors bors bot merged commit 4e4a353 into master Jan 29, 2020
5 checks passed
5 checks passed
automation
Details
Summary 3 rules match
Details
bors Build succeeded
Details
ci/circleci: debug-build-test Your tests passed on CircleCI!
Details
license/cla Contributor License Agreement is signed.
Details
@mergify mergify bot deleted the 1892-tracing branch Jan 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

3 participants
You can’t perform that action at this time.