Skip to content

Conversation

@Frando
Copy link
Member

@Frando Frando commented Nov 23, 2025

Expand qlog support:

  • Set the vantage point for qlog traces
  • Record frames for received packets
  • Record frames for sent packets
  • Record ConnectionStarted event

Based on #177 because iroh feat-multipath is now based on that. Failures/lints are on protocol-simplications - will rebase as soon as that branch becomes green.

@Frando Frando changed the title feat: expand qlog support (on top of protocol-simplifications) feat: Expand qlog support (on top of protocol-simplifications) Nov 23, 2025
@n0bot n0bot bot added this to iroh Nov 23, 2025
@github-project-automation github-project-automation bot moved this to 🏗 In progress in iroh Nov 23, 2025
feat: add ConnectionStarted to qlog

feat: track received packets in qlog

fix: cid groups, padding size, cleanups

fixup vantage_point method signature

chore: clippy
@Frando Frando changed the title feat: Expand qlog support (on top of protocol-simplifications) feat: Expand qlog support Nov 25, 2025
Copy link
Collaborator

@flub flub left a comment

Choose a reason for hiding this comment

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

Generally looks great, but let's add good doc comments. Even for internal APIs.

The other main comment is that the qlog module is cfg-disabling all the bodies of functions so that the callsites don't have to have cfg everywhere. I think you should continue that style for the newly added methods. That would get rid of a lot of cfg lines.

Comment on lines +15 to +17
use std::net::{IpAddr, SocketAddr};
#[cfg(feature = "qlog")]
use std::sync::{Arc, Mutex};
Copy link
Collaborator

Choose a reason for hiding this comment

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

stdlib imports should be before 3rd party crates, no?

#[cfg(feature = "qlog")]
impl QlogStream {
fn emit_event(&self, orig_rem_cid: ConnectionId, event: EventData, now: Instant) {
fn emit_event(&self, initial_dst_cid: ConnectionId, event: EventData, now: Instant) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

that is so much a better variable name for this

) {
#[cfg(feature = "qlog")]
{
use qlog::events::connectivity::ConnectionStarted;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why is this not in the import block at the top of the file?

let Some(stream) = self.stream.as_ref() else {
return;
};
// TODO: Review fields. The standard has changed since.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is it possible to say which draft the fields used here are in the comment? That would probably help the future.

..Default::default()
};
#[derive(Default)]
pub(crate) struct QlogSentPacket {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe add a doc comment that this is intentionally a noop struct if the cfg is disabled, and that the expectation is that the compiler completely removes it from function call parameters. Preferably somehow all on the first line so that IDEs show it nicely :)

stream.emit_event(orig_rem_cid, EventData::PacketReceived(event), now);
#[cfg(feature = "qlog")]
impl QlogSentPacket {
pub(crate) fn header(
Copy link
Collaborator

Choose a reason for hiding this comment

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

I know these are all internal APIs. But I love doc comments for internal stuff too.

}

stream.emit_event(orig_rem_cid, EventData::PacketReceived(event), now);
#[cfg(feature = "qlog")]
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think the philosophy of this module is to keep all/most the cfgs inside the function bodies. That way the call sites are not littered with cfgs. And the compiler is expected to optimise out the noop function calls. So you probably should follow the same pattern for these new impls?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: 🏗 In progress

Development

Successfully merging this pull request may close these issues.

3 participants