Skip to content

Commit aa24498

Browse files
authored
[PROF-11524] Minor tweak: Set profile start_time after resetting (#987)
**What does this PR do?** This PR applies a suggestion from #963 (comment) to set the `start_time` after obtaining the old profile. This will hopefully make it more clear that the `start_time` is used for the old profile, not the new one. **Motivation:** Make code more readable. **Additional Notes:** N/A **How to test the change?** Existing test coverage should be enough to validate this change (for instance, the Ruby profiler test suite explicitly tests the timestamps on profiles).
1 parent fed767f commit aa24498

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -747,12 +747,11 @@ pub unsafe extern "C" fn ddog_prof_Profile_serialize(
747747
(|| {
748748
let profile = profile_ptr_to_inner(profile)?;
749749

750+
let mut old_profile = profile.reset_and_return_previous()?;
750751
if let Some(start_time) = start_time {
751-
profile.set_start_time(start_time.into())?;
752+
old_profile.set_start_time(start_time.into())?;
752753
}
753754

754-
let old_profile = profile.reset_and_return_previous()?;
755-
756755
let end_time = end_time.map(SystemTime::from);
757756
old_profile.serialize_into_compressed_pprof(end_time, None)
758757
})()

0 commit comments

Comments
 (0)