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

Add more log details #474

Merged
merged 5 commits into from
May 11, 2021
Merged

Add more log details #474

merged 5 commits into from
May 11, 2021

Conversation

bonomat
Copy link
Member

@bonomat bonomat commented May 5, 2021

Resolves #448

  1. The first commit adds an additional log statement of the exchange rate for each state-update. This is useful because it allows us to measure profitability easily, i.e. by knowing what was the exchange rate when the swap was started and what was it when it was finalized.
  2. The second commit changes a bunch of log messages.
  3. The third commit is adds a new commandline flag to toggle json format.

@bonomat bonomat requested review from thomaseizinger and da-kami May 5, 2021 07:00
@bonomat bonomat marked this pull request as draft May 5, 2021 07:00
@bonomat bonomat changed the title Add more log details Add more log details: Help needed. May 5, 2021
Copy link
Contributor

@thomaseizinger thomaseizinger left a comment

Choose a reason for hiding this comment

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

Overall: Very big fan of utilizing tracing's fields more in the messages, thanks for doing this!

I think all the problems you mentioned in the description go away if you just use a command-line flag for the log output.

I don't think we should be too smart about when we enable / disable JSON. If the app is just running within systemd, JSON logs will be pretty annoying :)

swap/src/protocol/alice/swap.rs Outdated Show resolved Hide resolved
swap/src/bin/asb.rs Outdated Show resolved Hide resolved
swap/src/bin/asb.rs Outdated Show resolved Hide resolved
swap/src/bitcoin/wallet.rs Outdated Show resolved Hide resolved
swap/src/monero/wallet.rs Outdated Show resolved Hide resolved
swap/src/network/cbor_request_response.rs Outdated Show resolved Hide resolved
Err(e) => {
tracing::warn!(%peer, "Failed to make State0 for execution setup: {:#}", e);
Err(error) => {
tracing::warn!(%peer, %error, "Failed to make State0 for execution setup.");
Copy link
Contributor

Choose a reason for hiding this comment

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

This change is not quite functionally equivalent. {:#} will log the whole causality chain for an anyhow::Error whereas % will just invoke regular Display. See this open ticket here: tokio-rs/tracing#1311

It is not yet resolved and I think we should really keep the causality chain otherwise debugging might be painful.

Copy link
Member Author

Choose a reason for hiding this comment

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

It is not yet resolved and I think we should really keep the causality chain otherwise debugging might be painful.

Good catch, I did not know that.

Copy link
Member Author

Choose a reason for hiding this comment

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

I revert and print the error message inside the message and unified somehow across all log messages.

swap/src/protocol/alice/swap.rs Outdated Show resolved Hide resolved
swap/src/asb/config.rs Outdated Show resolved Hide resolved
@thomaseizinger thomaseizinger mentioned this pull request May 7, 2021
@bonomat bonomat force-pushed the 448-more-logging branch from 0c445d3 to dcf9867 Compare May 10, 2021 02:07
@bonomat bonomat marked this pull request as ready for review May 10, 2021 02:07
@bonomat bonomat changed the title Add more log details: Help needed. Add more log details May 10, 2021
Copy link
Member

@da-kami da-kami left a comment

Choose a reason for hiding this comment

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

Looking good, I added a few minor things that can be adapted.
I think it will be important to run this in production asap to see if it fulfills our needs.

swap/src/asb/config.rs Outdated Show resolved Hide resolved
swap/src/bitcoin/wallet.rs Outdated Show resolved Hide resolved
swap/src/monero/wallet.rs Outdated Show resolved Hide resolved
swap/src/network/cbor_request_response.rs Outdated Show resolved Hide resolved
swap/src/protocol/alice/swap.rs Outdated Show resolved Hide resolved
@bonomat bonomat force-pushed the 448-more-logging branch 4 times, most recently from bc7261d to 90dd500 Compare May 11, 2021 01:20
@bonomat bonomat requested review from thomaseizinger and da-kami May 11, 2021 01:23
@bonomat bonomat force-pushed the 448-more-logging branch from 90dd500 to fc0cceb Compare May 11, 2021 05:28
Copy link
Member

@da-kami da-kami left a comment

Choose a reason for hiding this comment

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

OK to merge - definitely an improvement!
IMO we can fiddle with the cleanup of some message / best practices for logs later so feel free to ignore my comments :)

swap/src/asb/config.rs Outdated Show resolved Hide resolved
swap/src/bin/asb.rs Outdated Show resolved Hide resolved
swap/src/bitcoin/wallet.rs Outdated Show resolved Hide resolved
swap/src/monero/wallet_rpc.rs Outdated Show resolved Hide resolved
let identity = seed.derive_libp2p_identity();
let transport = transport::build_clear_net(&identity)?;
let peer_id = identity.public().into_peer_id();
tracing::debug!("Our peer-id: {}", peer_id);
tracing::debug!(%peer_id, "Our peer-id");
Copy link
Member

Choose a reason for hiding this comment

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

Same here - I think the output will repeat itself Our peer-id peer_id=...
Not really a big deal, but eventually we might want to think about some best practices for our log statements.

@bonomat
Copy link
Member Author

bonomat commented May 11, 2021

bors r+

bors bot added a commit that referenced this pull request May 11, 2021
474: Add more log details r=bonomat a=bonomat

Resolves #448 

1. The first commit adds an additional log statement of the exchange rate for each state-update. This is useful because it allows us to measure profitability easily, i.e. by knowing what was the exchange rate when the swap was started and what was it when it was finalized.
2. The second commit changes a bunch of log messages. 
3. The third commit is adds a new commandline flag to toggle json format.




Co-authored-by: Philipp Hoenisch <[email protected]>
Co-authored-by: Philipp Hoenisch <[email protected]>
@bors
Copy link
Contributor

bors bot commented May 11, 2021

Build failed:

@bonomat
Copy link
Member Author

bonomat commented May 11, 2021

docker failure :/

@bonomat
Copy link
Member Author

bonomat commented May 11, 2021

bors retry

@bors
Copy link
Contributor

bors bot commented May 11, 2021

Already running a review

@bors bors bot merged commit f03e8fa into master May 11, 2021
@bors bors bot deleted the 448-more-logging branch May 11, 2021 06:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ASB Metrics
3 participants