Skip to content
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

[profiling] Fuzz profiler API #449

Merged
merged 54 commits into from
Jun 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
041973b
[profiling] Fuzz profiler API
danielsn May 23, 2024
50929a6
make owned types orthogonal to api types
danielsn May 23, 2024
2ddda7a
make owned types orthogonal to api types
danielsn May 23, 2024
ef3de36
reformat
danielsn May 23, 2024
f23896c
reformat
danielsn May 23, 2024
aa6fd91
all the nice types
danielsn May 23, 2024
82cbc79
initial fuzz test, fails with duplicate labels on sample
danielsn May 23, 2024
1ccf691
add timestamp to fuzz test
danielsn May 23, 2024
afdb3b6
serialize the pprof at the end
danielsn May 23, 2024
f41836c
remove arbitrary from deps
taegyunkim May 24, 2024
09f6c27
fuzz with right length samples
taegyunkim May 24, 2024
1fa27ba
impl custom PartialEq and Hash so that the fuzzer can generate unique…
taegyunkim May 24, 2024
60bdbfb
comments
taegyunkim May 24, 2024
61d54ad
rename
taegyunkim May 24, 2024
bb3e6da
fuzz add_endpoint
taegyunkim May 24, 2024
1c8a173
use saturating add
taegyunkim May 24, 2024
bc2cba9
derive TypeGenerator for UpscalingInfo
taegyunkim May 24, 2024
a5aa7d7
use roundtrip to test
taegyunkim May 28, 2024
313781c
follow ids to assert the values
taegyunkim May 28, 2024
232dd13
test mapping
taegyunkim May 28, 2024
a01599c
pprof vs. owned_type test
taegyunkim May 29, 2024
7a80bac
use same code for timestamped and non-timestamped samples
taegyunkim May 29, 2024
1caaf05
helper functions
taegyunkim May 29, 2024
f8a8ec1
use the same pattern for fixed_sample_length
taegyunkim May 29, 2024
fe06bb7
update comments
taegyunkim May 29, 2024
f7ca80b
clippy
taegyunkim May 29, 2024
fac921d
api function calls
taegyunkim May 29, 2024
799a4e8
fuzz with add_endpoint
taegyunkim May 29, 2024
383fe4b
fix clippy
taegyunkim May 29, 2024
88bde3d
assert, expect
taegyunkim May 29, 2024
fa1680e
comments
taegyunkim May 29, 2024
cdb9236
remove unneeded
taegyunkim May 29, 2024
5b576f7
remove is_well_formed
taegyunkim May 29, 2024
6a11770
update expect
taegyunkim May 29, 2024
583f483
refactor into add_sample
taegyunkim May 29, 2024
5c8c354
clippy
taegyunkim May 29, 2024
a94c126
narrow search space by not using times
taegyunkim May 29, 2024
5117532
reduce range for miri
taegyunkim May 29, 2024
41a5deb
refactor: move stuff for better diff, convert String to Box<str>
morrisonlevi May 30, 2024
58c1317
refactor: move fuzz tests for profile.rs into their own file
morrisonlevi May 30, 2024
ce4b453
refactor: simplify derives, rename method
morrisonlevi May 31, 2024
65e64fa
constructors
taegyunkim May 31, 2024
301961b
use constructors
taegyunkim May 31, 2024
ba175c2
string_table_fetch helper function
taegyunkim May 31, 2024
7839872
also use fuzz_add_sample
taegyunkim May 31, 2024
c1cba8d
add fuzz_failure_001 to help debug
morrisonlevi May 31, 2024
be84229
resolve comments
taegyunkim Jun 1, 2024
95d2987
explain -1
taegyunkim Jun 4, 2024
17134b8
add comment
taegyunkim Jun 10, 2024
2779220
fix failure case
taegyunkim Jun 10, 2024
2441563
add comments
taegyunkim Jun 10, 2024
7de94c0
revive is_well_formed
taegyunkim Jun 10, 2024
288ff5c
use different default ranges for miri
taegyunkim Jun 10, 2024
7417cf1
sort not needed
taegyunkim Jun 10, 2024
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
1 change: 1 addition & 0 deletions profiling/src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ pub struct Sample<'a> {
}

#[derive(Debug)]
#[cfg_attr(test, derive(bolero_generator::TypeGenerator))]
pub enum UpscalingInfo {
Poisson {
// sum_value_offset and count_value_offset are offsets in the profile values type array
Expand Down
3 changes: 2 additions & 1 deletion profiling/src/internal/endpoint_stats.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ impl From<HashMap<String, i64>> for ProfiledEndpointsStats {

impl ProfiledEndpointsStats {
pub fn add_endpoint_count(&mut self, endpoint_name: String, value: i64) {
*self.count.entry(endpoint_name).or_insert(0) += value;
let entry = self.count.entry(endpoint_name).or_insert(0);
*entry = entry.saturating_add(value);
}

pub fn is_empty(&self) -> bool {
Expand Down
1 change: 0 additions & 1 deletion profiling/src/internal/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ pub use label::*;
pub use location::*;
pub use mapping::*;
pub use observation::*;
pub use owned_types::*;
pub use profile::*;
pub use sample::*;
pub use stack_trace::*;
Expand Down
36 changes: 0 additions & 36 deletions profiling/src/internal/owned_types.rs

This file was deleted.

44 changes: 44 additions & 0 deletions profiling/src/internal/owned_types/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// Copyright 2021-Present Datadog, Inc. https://www.datadoghq.com/
// SPDX-License-Identifier: Apache-2.0

use crate::api;

#[cfg_attr(test, derive(bolero_generator::TypeGenerator))]
#[derive(Clone, Debug)]
pub struct ValueType {
pub typ: Box<str>,
pub unit: Box<str>,
}

impl<'a> From<&'a api::ValueType<'a>> for ValueType {
#[inline]
fn from(value_type: &'a api::ValueType<'a>) -> Self {
Self {
typ: Box::from(value_type.r#type),
unit: Box::from(value_type.unit),
}
}
}

impl<'a> From<&'a ValueType> for api::ValueType<'a> {
fn from(value: &'a ValueType) -> Self {
Self::new(&value.typ, &value.unit)
}
}

#[cfg_attr(test, derive(bolero_generator::TypeGenerator))]
#[derive(Clone, Debug)]
pub struct Period {
pub typ: ValueType,
pub value: i64,
}

impl<'a> From<&'a api::Period<'a>> for Period {
#[inline]
fn from(period: &'a api::Period<'a>) -> Self {
Self {
typ: ValueType::from(&period.r#type),
value: period.value,
}
}
}
Loading