-
Notifications
You must be signed in to change notification settings - Fork 10
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] use internal Label instead of pprof::Label #454
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #454 +/- ##
==========================================
- Coverage 67.90% 67.89% -0.02%
==========================================
Files 193 193
Lines 24651 24643 -8
==========================================
- Hits 16740 16731 -9
- Misses 7911 7912 +1
|
I believe this means we can also remove |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
.map(|res| res.map(pprof::Label::from)), | ||
) | ||
.chain(timestamp.map(|ts| Ok(Label::num(self.timestamp_key, ts.get(), None).into()))) | ||
.map(|l| self.get_label(*l).copied()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thought: since Label
is Copy
, should get_label
just return an owned object rather than a reference?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(not needed for this PR, but might be interesting to not bother taking Copy
types by reference
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know for small types, yes, it's definitely preferred to work by-value instead of reference. I'm not sure what "small" means for Rust calling conventions, though. Is Label
small?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Label
has StringId
, which is u32
and LabelValue
.
libdatadog/profiling/src/internal/label.rs
Lines 16 to 19 in 633b0b0
pub struct Label { | |
key: StringId, | |
value: LabelValue, | |
} |
LabelVale
is an enum which can be
StringId
, againu32
i64
and optionalStringId
pub enum LabelValue { |
label.get_key(), | ||
match label.get_value() { | ||
LabelValue::Str(str) => *str, | ||
LabelValue::Num { .. } => StringId::ZERO, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this an error if this case is reached?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I simply looked at impl From<&Label> for pprof::Label
here.
libdatadog/profiling/src/internal/label.rs
Lines 59 to 73 in 0593cd7
impl From<&Label> for pprof::Label { | |
fn from(l: &Label) -> pprof::Label { | |
let key = l.key.to_raw_id(); | |
match l.value { | |
LabelValue::Str(str) => Self { | |
key, | |
str: str.to_raw_id(), | |
num: 0, | |
num_unit: 0, | |
}, | |
LabelValue::Num { num, num_unit } => Self { | |
key, | |
str: 0, | |
num, | |
num_unit: num_unit.map(StringId::into_raw_id).unwrap_or_default(), |
I don't think this was treated as an error before this PR.
What does this PR do?
Resolves a TODO. Use
internal::Label
instead ofpprof::Label
to make it easier to fuzz test. Even thoughpprof::Label
can also derivebolero_generator::TypeGenerator
guarded bycfg(test)
, it would be best to keep internal things internal.Also, this lets us use
pprof::Label
only when returning pprof.Motivation
TODO
Additional Notes
Anything else we should know when reviewing?
How to test the change?
cargo nextest run