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

feat(s2n-quic-core): add USDT probe support #2089

Merged
merged 1 commit into from
Jan 13, 2024
Merged

Conversation

camshaft
Copy link
Contributor

@camshaft camshaft commented Jan 11, 2024

Description of changes:

This change adds support for defining static probes throughout the codebase:

crate::probe::define!(
extern "probe" {
/// Emitted when a buffer is allocated for a particular offset
#[link_name = s2n_quic_core__buffer__receive_buffer__alloc]
pub fn alloc(offset: u64, capacity: usize);
/// Emitted when a chunk is read from the beginning of the buffer
#[link_name = s2n_quic_core__buffer__receive_buffer__pop]
pub fn pop(offset: u64, len: usize);
/// Emitted when a chunk of data is written at an offset
#[link_name = s2n_quic_core__buffer__receive_buffer__write]
pub fn write(offset: u64, len: usize);
}
);

In the code, you can then just call your probes like regular functions - all with autocompletion and strict typing!

pub fn write(self, buffer: &mut BytesMut) {
super::probe::write(self.offset, self.data.len());

The probe can then be configured through feature flags to:

  • emit a tracing record
  • register as a USDT probe, which can be read by tools like bpftrace.

Testing:

I've enabled probe-tracing on the s2n-quic dev-dependencies, so all of the integration tests can be more-easily traced:

$ S2N_LOG=trace cargo test -p s2n-quic client_server -- --nocapture | rg receive_buffer::probe
    Finished test [unoptimized + debuginfo] target(s) in 0.11s
     Running unittests src/lib.rs (target/debug/deps/s2n_quic-f075e86750846335)
0:00:00.050000 s2n_quic_core::buffer::receive_buffer::probe::alloc: offset=0 capacity=4096
0:00:00.050000 s2n_quic_core::buffer::receive_buffer::probe::write: offset=0 len=234
0:00:00.050000 s2n_quic_core::buffer::receive_buffer::probe::pop: offset=0 len=4
0:00:00.050000 s2n_quic_core::buffer::receive_buffer::probe::pop: offset=4 len=230
0:00:00.100000 s2n_quic_core::buffer::receive_buffer::probe::alloc: offset=0 capacity=4096
0:00:00.100000 s2n_quic_core::buffer::receive_buffer::probe::write: offset=0 len=90
0:00:00.100000 s2n_quic_core::buffer::receive_buffer::probe::pop: offset=0 len=4
0:00:00.100000 s2n_quic_core::buffer::receive_buffer::probe::pop: offset=4 len=86
0:00:00.100000 s2n_quic_core::buffer::receive_buffer::probe::alloc: offset=0 capacity=4096
0:00:00.100000 s2n_quic_core::buffer::receive_buffer::probe::write: offset=0 len=600
0:00:00.100000 s2n_quic_core::buffer::receive_buffer::probe::pop: offset=0 len=4
0:00:00.100000 s2n_quic_core::buffer::receive_buffer::probe::pop: offset=4 len=88
...

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@camshaft camshaft force-pushed the camshaft/core-probe branch from cd06c58 to b9a3db1 Compare January 11, 2024 23:16
@camshaft camshaft marked this pull request as ready for review January 11, 2024 23:20
@camshaft camshaft merged commit 584e7c2 into main Jan 13, 2024
109 of 110 checks passed
@camshaft camshaft deleted the camshaft/core-probe branch January 13, 2024 01:59
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.

2 participants