Skip to content

Commit

Permalink
clippy
Browse files Browse the repository at this point in the history
Signed-off-by: Bob Weinand <[email protected]>
  • Loading branch information
bwoebi committed Nov 13, 2024
1 parent 0dc83e9 commit 698ee10
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 17 deletions.
4 changes: 2 additions & 2 deletions sidecar-ffi/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -702,11 +702,11 @@ pub unsafe extern "C" fn ddog_sidecar_send_debugger_datum(
#[no_mangle]
#[allow(clippy::missing_safety_doc)]
#[allow(improper_ctypes_definitions)] // DebuggerPayload is just a pointer, we hide its internals
pub unsafe extern "C" fn ddog_sidecar_send_debugger_diagnostics<'a>(
pub unsafe extern "C" fn ddog_sidecar_send_debugger_diagnostics(
transport: &mut Box<SidecarTransport>,
instance_id: &InstanceId,
queue_id: QueueId,
diagnostics_payload: DebuggerPayload<'a>,
diagnostics_payload: DebuggerPayload,
) -> MaybeError {
try_c!(blocking::send_debugger_diagnostics(
transport,
Expand Down
4 changes: 2 additions & 2 deletions sidecar/src/service/blocking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -366,11 +366,11 @@ pub fn send_debugger_data_shm_vec(
/// # Returns
///
/// An `io::Result<()>` indicating the result of the operation.
pub fn send_debugger_diagnostics<'a>(
pub fn send_debugger_diagnostics(
transport: &mut SidecarTransport,
instance_id: &InstanceId,
queue_id: QueueId,
diagnostics_payload: DebuggerPayload<'a>,
diagnostics_payload: DebuggerPayload,
) -> io::Result<()> {
transport.send(SidecarInterfaceRequest::SendDebuggerDiagnostics {
instance_id: instance_id.clone(),
Expand Down
27 changes: 14 additions & 13 deletions sidecar/src/service/debugger_diagnostics_bookkeeper.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// Copyright 2021-Present Datadog, Inc. https://www.datadoghq.com/
// SPDX-License-Identifier: Apache-2.0
use datadog_live_debugger::debugger_defs::{
DebuggerData, DebuggerPayload, Diagnostics, ProbeStatus,
};
Expand Down Expand Up @@ -43,7 +45,7 @@ impl DebuggerDiagnosticsBookkeeper {
active.active_probes.retain(|_, status| {
status.last_update.elapsed() < MAX_TIME_BEFORE_REMOVAL
});
active.active_probes.len() != 0
!active.active_probes.is_empty()
});
},
_ = cancel.cancelled() => {
Expand Down Expand Up @@ -75,16 +77,15 @@ impl DebuggerDiagnosticsBookkeeper {
.active_probes
.get_mut(diagnostics.runtime_id.as_ref())
{
if !matches!(diagnostics.status, ProbeStatus::Received) {
if matches!(status.status, ProbeStatus::Received)
|| (!matches!(diagnostics.status, ProbeStatus::Installed)
&& matches!(status.status, ProbeStatus::Installed))
{
if status.last_update.elapsed() < MAX_TIME_BEFORE_FALLBACK {
send = false;
}
}
}
// This is a bit confusing now, but clippy requested me to collapse this:
// Essentially, we shall send if the last emitted/error/installed/etc. is older
// than MAX_TIME_BEFORE_FALLBACK. If it's installed, we also
// send it the current status is Received.
send = matches!(diagnostics.status, ProbeStatus::Received)
|| (!matches!(status.status, ProbeStatus::Received)
&& (matches!(diagnostics.status, ProbeStatus::Installed)
|| !matches!(status.status, ProbeStatus::Installed)))
|| status.last_update.elapsed() > MAX_TIME_BEFORE_FALLBACK;
if send {
status.last_update = Instant::now();
if status.status != diagnostics.status {
Expand All @@ -94,12 +95,12 @@ impl DebuggerDiagnosticsBookkeeper {
}
}
} else {
insert_probe(buffer, &diagnostics);
insert_probe(buffer, diagnostics);
}
} else {
buffers.insert(diagnostics.runtime_id.to_string(), {
let mut data = DebuggerActiveData::default();
insert_probe(&mut data, &diagnostics);
insert_probe(&mut data, diagnostics);
data
});
}
Expand Down

0 comments on commit 698ee10

Please sign in to comment.