-
Notifications
You must be signed in to change notification settings - Fork 136
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
feat(iroh, iroh-gossip): introduce log-self
feature
#1544
Conversation
log-self
featurelog-self
feature
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not always do this instead of the extra feature and conditional compilation? If it's useful, which it clearly is, then let's just always do it.
if let Err(err) = actor.run().await { | ||
let fut = actor.run(); | ||
#[cfg(feature = "log-self")] | ||
let fut = fut.instrument(trace_span!("gossip", %me)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
since this is a spawned future I'd strongly recommend to use an info_span
. And also to not make it depend on the feature. Every task should have it's own info_span
attached as a general rule.
The span should also cover the bit of error handing in the lines below that are still inside this spawned task.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you explain why info_span
? looking throughout the code we still have trace_span
once in baomap
, debug_span
16 times. Looking at what Frando did in his own branch for his needs he went with trace as well and it seems to work well. What's the difference?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My general guideline is to use info_span
for spawned tasks, motivation:
- If something is spawned it usually is a "top level task" of some sort (with a serious pinch of salt).
- In this case you want to see most log messages with that span attached
- and if you set the level to info, debug or trace you will see that attached span by default
- (bonus: this matches the "info is for operators" guidance we just discussed)
This does not mean we already do this everywhere consistently. I've done a few PRs in the past making this more consistent but it certainly isn't complete.
Now I understand your reluctance to always having this logging on and that having this as debug or trace makes it even easier to hide. but i do really think this is more useful at info.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok just to be clear about my question I don't understand what this changes, not sure what the effect of this is.
Is the effect to add the fields only from info and above? if so then don't think this will help in debugging tests
if the effect is to limit to info and below then it's probably better
but then it's confusing that trace still gives me debug logs with peer_ids.
TLDR: I'm confused about what the levels do here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See also https://discord.com/channels/949724860232392765/950683937661935667/1156506832567808060 where @Frando is also asked me this question and I (hopefully!) gave a similar answer.
@@ -237,6 +241,12 @@ impl Downloader { | |||
|
|||
let service = Service::new(getter, dialer, concurrency_limits, msg_rx); | |||
|
|||
#[cfg(feature = "log-self")] | |||
{ | |||
service.run().instrument(trace_span!("downloader", %me)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here, it should always attach the span and be info_span
as it's run in a task. Again try to do it around the entire spawned future and not just the service.run()
method.
if let Err(err) = actor.run().instrument(span).await { | ||
let fut = actor.run(); | ||
#[cfg(feature = "log-self")] | ||
let fut = fut.instrument(trace_span!("sync", %me)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same note, info_span
and cover entire future that's spawned into the task.
This might / will be PII eventually, so having the option to scrub it is nice. |
unlikely, peerids are sent over the network and shared as identifiers. |
Yeah, let's add this. Test logs with multiple nodes are basically unusable without. I did parts of this in #1530 but let's get this in here! @flub has more experience with In addition to the places where you added the span, I'd recommend to...
|
can people comment on deciding to make this a compile time flag? @Frando @dignifiedquire @flub (heck we are four here let's just bring @ramfox and @b5 ) my thinking is that logs are already very hard to read. Your own peer id is useful only when you are dealing with multiple nodes in the single run. This is not the case of users in general, and I would not include this in release builds by default for example. Basically I think it's very nice to be able to have cleaner logs by just removing a feature because this adds "a lot" to already noisy logs |
agreed feature is not necessary |
for completeness: everyone agreed the logging added here is super useful and we should totally have it. but we prefer it always-on, so without the crate-level feature to control it. i don't mind if you want to re-open this and remove the crate-feature or re-create the PR. though I think it's a reasonable refactor to do to this PR so re-opening might be easier. |
## Description second take at #1544 since forced pushed closed prs can't be reopened #### Magicsock ``` 2023-10-02T18:46:34.455601Z DEBUG magicsock{me=2luekswh7o3a5tz4}:derp.actor:recv_detail:client-connect{key=2luekswh7o3a5tz4enymovsoksgnpb2qpmxlvifp6ywwjnacihya}:connect_0: rustls::client::tls13: TLS1.3 encrypted extensions: [ServerNameAck] ``` #### Sync ```log 2023-09-28T20:51:18.908126Z DEBUG sync{me=oywqb57ovmdry243}: iroh::sync_engine::live: sync[dial]: start namespace=NamespaceId(q47zmyim5r6isz22…) peer=PublicKey(2jnygwapdm26wwa2) reason=DirectJoin last_state=None ``` #### Gossip ```logs 2023-09-28T20:58:42.854730Z DEBUG gossip{me=zooj7iazcl7rsoal}: iroh_gossip::net: handle out_event EmitEvent(TopicId(wno5nwxtkhhtnqsm…), Received(GossipEvent { content: <33b>, delivered_from: PublicKey(7a7kkzndvbt6eulu), scope: Neighbors })) ``` #### Downloader ``` 2023-09-28T21:00:11.107411Z DEBUG downloader{me=4vabufwku3wselbl}: iroh::downloader: download completed peer=2jnygwapdm26wwa26tvcprm3m5vqajmhwz7lx5xizwx637ad5sea kind=Blob { hash: Hash(224746ea89d286220e0770f89cda2ab138143b00e384dd795d5a13b77b094822) } ``` ## Notes & open questions probably we will add this in other places or change the logging level but would be good to get this in to at least have something over which we can iterate ## Change checklist - [x] Self-review. - [ ] Documentation updates if relevant. - [ ] Tests if relevant.
Description
Aff a feature flag to turn on logging our own
peer_id
in short form and plug this in in sync, gossip and the downloader. This is enabled by default (not sure if we want this for releases thought. Having it as a feature flag at least gives us the option to chose.This is what I did to debug #1531 and it was really useful
Notes & open questions
Log sample:
Sync
Gossip
Downloader
Change checklist