Skip to content

Commit 4276bdc

Browse files
fix(profiling): resolve clippy unwrap_used and rustfmt doc comment formatting
Replace unwrap() with ok_or_else() for string_storage access in add_string_id_sample and reflow doc comments to satisfy rustfmt. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 00e83b8 commit 4276bdc

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

libdd-profiling-ffi/src/profiles/datatypes.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -585,9 +585,9 @@ impl From<ProfileNewResult> for Result<Profile, Error> {
585585
/// This call is _NOT_ thread-safe.
586586
///
587587
/// # Arguments
588-
/// * `track_ptr` - If non-zero, also track this allocation for heap-live
589-
/// profiling. The sample data is copied into owned storage and will be
590-
/// automatically injected during profile reset. Use 0 to skip tracking.
588+
/// * `track_ptr` - If non-zero, also track this allocation for heap-live profiling. The sample data
589+
/// is copied into owned storage and will be automatically injected during profile reset. Use 0 to
590+
/// skip tracking.
591591
#[must_use]
592592
#[no_mangle]
593593
pub unsafe extern "C" fn ddog_prof_Profile_add(
@@ -949,8 +949,8 @@ pub unsafe extern "C" fn ddog_prof_Profile_reset(profile: *mut Profile) -> Profi
949949
/// # Arguments
950950
/// * `profile` - A mutable reference to the profile.
951951
/// * `max_tracked` - Maximum number of allocations to track simultaneously.
952-
/// * `excluded_labels` - Label keys to strip from tracked allocations
953-
/// (e.g., high-cardinality labels like "span id").
952+
/// * `excluded_labels` - Label keys to strip from tracked allocations (e.g., high-cardinality
953+
/// labels like "span id").
954954
/// * `excluded_labels_len` - Number of elements in `excluded_labels`.
955955
/// * `alloc_size_idx` - Index of alloc-size in the sample values array.
956956
/// * `heap_live_samples_idx` - Index of heap-live-samples in the sample values array.

libdd-profiling/src/internal/profile/mod.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,11 @@ impl Profile {
302302
// and copy sample data into owned storage before interning.
303303
if let Some(ptr) = track_ptr {
304304
if let Some(hl) = self.heap_live.as_mut() {
305-
let storage = self.string_storage.as_ref().unwrap();
305+
let storage = self.string_storage.as_ref().ok_or_else(|| {
306+
anyhow::anyhow!(
307+
"string storage required for heap-live tracking with string IDs"
308+
)
309+
})?;
306310
let locked = storage
307311
.lock()
308312
.map_err(|_| anyhow::anyhow!("string storage lock was poisoned"))?;
@@ -388,8 +392,8 @@ impl Profile {
388392
///
389393
/// # Arguments
390394
/// * `max_tracked` - Maximum number of allocations to track simultaneously
391-
/// * `excluded_labels` - Label keys to strip when copying into the tracker
392-
/// (e.g., high-cardinality labels like "span id", "trace id")
395+
/// * `excluded_labels` - Label keys to strip when copying into the tracker (e.g.,
396+
/// high-cardinality labels like "span id", "trace id")
393397
pub fn enable_heap_live_tracking(
394398
&mut self,
395399
max_tracked: usize,

0 commit comments

Comments
 (0)