Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
Signed-off-by: Bob Weinand <[email protected]>
  • Loading branch information
bwoebi committed Jul 2, 2024
1 parent 42df0f3 commit 891a058
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 6 deletions.
3 changes: 3 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions live-debugger-ffi/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ percent-encoding = "2.1"
uuid = { version = "1.7.0", features = ["v4"] }
serde_json = "1.0"
tokio = "1.36.0"
tokio-util = { version = "0.7", features = ["rt"] }
log = "0.4.21"

[features]
Expand Down
3 changes: 2 additions & 1 deletion live-debugger-ffi/src/data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ impl<'a> From<&'a datadog_live_debugger::SpanDecorationProbe> for SpanDecoration
span_tags: tags.as_ptr(),
span_tags_num: tags.len(),
};
std::mem::forget(conditions);
std::mem::forget(tags);
new
}
Expand All @@ -139,7 +140,7 @@ impl<'a> Drop for SpanDecorationProbe<'a> {
);
let num_conditions = tags.iter().filter(|p| p.next_condition).count();
_ = Vec::from_raw_parts(
self.conditions as *mut ProbeCondition,
self.conditions as *mut &ProbeCondition,
num_conditions,
num_conditions,
);
Expand Down
5 changes: 2 additions & 3 deletions live-debugger-ffi/src/evaluator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -236,9 +236,8 @@ pub fn ddog_evaluate_string<'a>(
) -> Cow<'a, str> {
let mut ctx = EvalCtx::new(context);
let (result, new_errors) = datadog_live_debugger::eval_string(&mut ctx, condition);
if !new_errors.is_empty() {
*errors = Some(Box::new(new_errors));
}
let found_errors = if !new_errors.is_empty() { Some(Box::new(new_errors)) } else { None };
std::mem::forget(std::mem::replace(errors, found_errors));
result
}

Expand Down
6 changes: 5 additions & 1 deletion live-debugger-ffi/src/sender.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use percent_encoding::{percent_encode, CONTROLS};
use std::sync::Arc;
use std::thread::JoinHandle;
use tokio::sync::mpsc;
use tokio_util::task::TaskTracker;

macro_rules! try_c {
($failable:expr) => {
Expand Down Expand Up @@ -46,6 +47,7 @@ async fn sender_routine(
mut receiver: mpsc::Receiver<SendData>,
) {
let tags = Arc::new(tags);
let tracker = TaskTracker::new();
loop {
let data = match receiver.recv().await {
None => break,
Expand All @@ -54,7 +56,7 @@ async fn sender_routine(

let endpoint = endpoint.clone();
let tags = tags.clone();
tokio::spawn(async move {
tracker.spawn(async move {
let data = match &data {
SendData::Raw(vec) => vec.as_slice(),
SendData::Wrapped(wrapped) => wrapped.slice.as_bytes(),
Expand All @@ -65,6 +67,8 @@ async fn sender_routine(
}
});
}

tracker.wait().await;
}

pub struct SenderHandle {
Expand Down
2 changes: 1 addition & 1 deletion live-debugger/src/redacted_names.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ lazy_static! {
REDACTED_TYPES_INITIALIZED.store(true, Ordering::Relaxed);
Regex::new(&REDACTED_WILDCARD_TYPES_PATTERN).unwrap()
};

static ref ASSUMED_SAFE_NAME_LEN: usize = {
REDACTED_NAMES_INITIALIZED.store(true, Ordering::Relaxed);
REDACTED_NAMES.iter().map(|n| n.len()).max().unwrap() + 5
Expand Down

0 comments on commit 891a058

Please sign in to comment.