Skip to content

Added flag to track replaying awareness of tracing span #20

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

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/vm/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,11 @@ pub struct CoreVM {
// State machine
context: Context,
last_transition: Result<State, Error>,

// Flag to indicate whether span replay attribute should be set
// When replaying this is set on the sys call
// When not replaying this is reset on the sys call that transitioned the state
tracing_replaying_flag: bool,
}

impl CoreVM {
Expand Down Expand Up @@ -166,6 +171,7 @@ impl super::VM for CoreVM {
options,
},
last_transition: Ok(State::WaitingStart),
tracing_replaying_flag: true,
})
}

Expand Down
23 changes: 23 additions & 0 deletions src/vm/transitions/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,29 @@ impl CoreVM {
let was_closed = matches!(s, State::Ended | State::Suspended);
match TransitionAndReturn::transition_and_return(s, &mut self.context, event) {
Ok((new_state, output)) => {
match new_state {
State::Replaying {
current_await_point,
..
} => {
// Replay record is not yet set in the span
if self.tracing_replaying_flag && current_await_point.is_some() {
tracing::Span::current().record("replaying", true);
self.tracing_replaying_flag = false;
}
}
State::Processing {
current_await_point,
..
} => {
// Replay record is not yet reset in the span
if !self.tracing_replaying_flag && current_await_point.is_some() {
tracing::Span::current().record("replaying", false);
self.tracing_replaying_flag = true;
}
}
_ => {}
}
self.last_transition = Ok(new_state);
Ok(output)
}
Expand Down