Skip to content

Commit

Permalink
replace all work_id occurences with id
Browse files Browse the repository at this point in the history
  • Loading branch information
dshulyak committed Jul 23, 2024
1 parent 9901795 commit 6bb7fc9
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 41 deletions.
2 changes: 1 addition & 1 deletion e2e/examples/http.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ async fn post_job(State(storage): State<JobStorage>, Json(input): Json<JobInput>
Json(job_result)
}

#[instrument(skip_all, fields(work_id = %id))]
#[instrument(skip_all, fields(id = %id))]
async fn get_job(
State(storage): State<JobStorage>,
axum::extract::Path(id): axum::extract::Path<usize>,
Expand Down
4 changes: 2 additions & 2 deletions explore/data.ipynb
Git LFS file not shown
4 changes: 2 additions & 2 deletions past/src/bpf/past.bpf.c
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ int handle__sched_process_exec(u64 *ctx)
}

SEC("usdt")
int BPF_USDT(past_tracing_enter, u64 span_id, u64 parent_span_id, u64 work_id, u64 amount, void *name)
int BPF_USDT(past_tracing_enter, u64 span_id, u64 parent_span_id, u64 id, u64 amount, void *name)
{
u64 __pid_tgid = bpf_get_current_pid_tgid();
gid_t tgid = __pid_tgid >> 32;
Expand All @@ -401,7 +401,7 @@ int BPF_USDT(past_tracing_enter, u64 span_id, u64 parent_span_id, u64 work_id, u
event->pid = pid;
event->span_id = span_id;
event->parent_id = parent_span_id;
event->work_id = work_id;
event->id = id;
event->amount = amount;
bpf_probe_read_user_str(&event->name, sizeof(event->name), name);
bpf_ringbuf_submit(event, BPF_RB_NO_WAKEUP);
Expand Down
2 changes: 1 addition & 1 deletion past/src/bpf/past.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ struct tracing_enter_event {
__u32 pid;
__u64 span_id;
__u64 parent_id;
__u64 work_id;
__u64 id;
__u64 amount;
__u8 name[TASK_COMM_LEN];
};
Expand Down
8 changes: 4 additions & 4 deletions past/src/collector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ impl<'a> From<&'a [u8]> for Received<'a> {
#[derive(Debug)]
struct SpanEnter {
parent_id: u64,
work_id: u64,
id: u64,
amount: u64,
name: Bytes,
first_enter_ts: u64,
Expand Down Expand Up @@ -160,7 +160,7 @@ impl Collector {
btree_map::Entry::Vacant(vacant) => {
vacant.insert(SpanEnter {
parent_id: event.parent_id,
work_id: event.work_id,
id: event.id,
amount: event.amount,
name: Bytes::copy_from_slice(null_terminated(&event.name)),
first_enter_ts: event.ts,
Expand Down Expand Up @@ -198,7 +198,7 @@ impl Collector {
command: command.clone(),
span_id: event.span_id as i64,
parent_id: span.parent_id as i64,
work_id: span.work_id as i64,
id: span.id as i64,
amount: span.amount as i64,
name: span.name.clone(),
ustack: event.ustack,
Expand Down Expand Up @@ -232,7 +232,7 @@ impl Collector {
command: command.clone(),
span_id: event.span_id as i64,
parent_id: span.parent_id as i64,
work_id: span.work_id as i64,
id: span.id as i64,
amount: span.amount as i64,
name: span.name.clone(),
});
Expand Down
36 changes: 18 additions & 18 deletions past/src/parquet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ fn events_schema() -> types::Type {
required int32 pid (INTEGER(32, false));
required int64 span_id (INTEGER(64, false));
required int64 parent_id (INTEGER(64, false));
required int64 work_id (INTEGER(64, false));
required int64 id (INTEGER(64, false));
required int64 amount (INTEGER(64, false));
required binary command (UTF8);
required binary trace_name (UTF8);
Expand Down Expand Up @@ -110,7 +110,7 @@ pub(crate) enum Event {
pid: i32,
span_id: i64,
parent_id: i64,
work_id: i64,
id: i64,
amount: i64,
name: Bytes,
command: Bytes,
Expand All @@ -124,7 +124,7 @@ pub(crate) enum Event {
pid: i32,
span_id: i64,
parent_id: i64,
work_id: i64,
id: i64,
amount: i64,
name: Bytes,
command: Bytes,
Expand All @@ -145,7 +145,7 @@ pub(crate) struct Group {
pid: Vec<i32>,
span_id: Vec<i64>,
parent_id: Vec<i64>,
work_id: Vec<i64>,
id: Vec<i64>,
amount: Vec<i64>,
command: Vec<ByteArray>,
trace_name: Vec<ByteArray>,
Expand All @@ -171,7 +171,7 @@ impl Group {
pid: Vec::with_capacity(capacity),
span_id: Vec::with_capacity(capacity),
parent_id: Vec::with_capacity(capacity),
work_id: Vec::with_capacity(capacity),
id: Vec::with_capacity(capacity),
amount: Vec::with_capacity(capacity),
command: Vec::with_capacity(capacity),
trace_name: Vec::with_capacity(capacity),
Expand Down Expand Up @@ -217,7 +217,7 @@ impl Group {
self.pid.swap(i, i - 1);
self.span_id.swap(i, i - 1);
self.parent_id.swap(i, i - 1);
self.work_id.swap(i, i - 1);
self.id.swap(i, i - 1);
self.amount.swap(i, i - 1);
self.command.swap(i, i - 1);
self.trace_name.swap(i, i - 1);
Expand Down Expand Up @@ -286,7 +286,7 @@ impl Group {
self.pid.push(0);
self.span_id.push(0);
self.parent_id.push(0);
self.work_id.push(0);
self.id.push(0);
self.amount.push(amount as i64);
self.command.push(command.into());
self.trace_name.push(Bytes::new().into());
Expand All @@ -302,7 +302,7 @@ impl Group {
pid,
span_id,
parent_id,
work_id,
id,
amount,
name,
command,
Expand All @@ -315,7 +315,7 @@ impl Group {
self.pid.push(pid);
self.span_id.push(span_id);
self.parent_id.push(parent_id);
self.work_id.push(work_id);
self.id.push(id);
self.amount.push(amount);
self.command.push(command.into());
self.trace_name.push(name.into());
Expand All @@ -331,7 +331,7 @@ impl Group {
pid,
span_id,
parent_id,
work_id,
id,
amount,
name,
command,
Expand All @@ -343,7 +343,7 @@ impl Group {
self.pid.push(pid);
self.span_id.push(span_id);
self.parent_id.push(parent_id);
self.work_id.push(work_id);
self.id.push(id);
self.amount.push(amount);
self.command.push(command.into());
self.trace_name.push(name.into());
Expand All @@ -364,7 +364,7 @@ impl Group {
self.pid.clear();
self.span_id.clear();
self.parent_id.clear();
self.work_id.clear();
self.id.clear();
self.amount.clear();
self.command.clear();
self.trace_name.clear();
Expand All @@ -381,7 +381,7 @@ impl Group {
fn add_empty_trace(&mut self) {
self.span_id.push(0);
self.parent_id.push(0);
self.work_id.push(0);
self.id.push(0);
self.amount.push(0);
self.trace_name.push(Bytes::new().into());
}
Expand Down Expand Up @@ -501,12 +501,12 @@ impl<W: Write + Send> GroupWriter<W> {
.context("parent_id")?;
parent_id.close()?;

let mut work_id = rows.next_column()?.expect("work_id column");
work_id
let mut id = rows.next_column()?.expect("id column");
id
.typed::<Int64Type>()
.write_batch(&group.work_id, None, None)
.context("work_id")?;
work_id.close()?;
.write_batch(&group.id, None, None)
.context("id")?;
id.close()?;

let mut amount = rows.next_column()?.expect("amount column");
amount
Expand Down
19 changes: 6 additions & 13 deletions tracing-past/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,21 @@ pub fn init() {
struct SpanInfo {
span_id: u64,
parent_span_id: u64,
work_id: u64,
id: u64,
amount: u64,
name: [u8; 16],

exit_stack: bool,
}

const WORK_ID: &str = "work_id";
const ID: &str = "id";
const THROUGHPUT_METRIC: &str = "amount";
const EXIT_STACK: &str = "exit_stack";

impl Visit for SpanInfo {
fn record_u64(&mut self, field: &tracing_core::Field, value: u64) {
match field.name() {
WORK_ID => self.work_id = value,
ID => self.id = value,
THROUGHPUT_METRIC => self.amount = value,
_ => {}
}
Expand All @@ -38,14 +38,7 @@ impl Visit for SpanInfo {
}
}

fn record_debug(&mut self, field: &tracing_core::Field, _: &dyn std::fmt::Debug) {
match field.name() {
WORK_ID => debug_assert!(false, "field `work_id` is not u64"),
THROUGHPUT_METRIC => {
debug_assert!(false, "field `amount` is not u64")
}
_ => {}
}
fn record_debug(&mut self, _: &tracing_core::Field, _: &dyn std::fmt::Debug) {
}
}

Expand All @@ -68,7 +61,7 @@ where
name: buf,
parent_span_id: attrs.parent().or(ctx.current_span().id()).map_or(0, |id| id.into_u64()),
span_id: id.into_u64(),
work_id: 0,
id: 0,
amount: 0,
exit_stack: false,
};
Expand All @@ -86,7 +79,7 @@ where
enter,
span_info.span_id as *const u64,
span_info.parent_span_id as *const u64,
span_info.work_id as *const u64,
span_info.id as *const u64,
span_info.amount as *const u64,
span_info.name.as_ptr()
);
Expand Down

0 comments on commit 6bb7fc9

Please sign in to comment.