-
Notifications
You must be signed in to change notification settings - Fork 2.8k
[receiver/pprof] attempt to convert from pprof to pdata and back #40548
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
base: main
Are you sure you want to change the base?
Conversation
aa49ba8
to
856302b
Compare
856302b
to
9ed9b02
Compare
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.
Just a first quick look
func pprofToPprofile(parsed *profile.Profile, originalPayload []byte) pprofile.Profiles { | ||
result := pprofile.NewProfiles() | ||
// create a new profile record | ||
resultProfile := result.ResourceProfiles().AppendEmpty().ScopeProfiles().AppendEmpty().Profiles().AppendEmpty() |
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.
A single Resource Profile in OTel Profiling can have multiple Scope Profiles. And OTel eBPF Profiler is already using multiple Scope Profiles to differentiate between on CPU and off CPU profiling. Mixing these profiles will cause issues.
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 that defined somewhere I can reuse?
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.
To add more complexity 🙈 open-telemetry/opentelemetry-ebpf-profiler#517 will implement the recent changes in the OTel Profiling signal to generate a single ResourceProfile
per container and an additional ResourceProfile for all non-containerized processes. As, I think, google/pprof does not differentiate between containerized elements and others, I think it is hard to map this correctly. Google/pprof might be able to set attributes accordingly, but they might not be standartized.
But I think, there should be one OTel/ScopeProfile per Google/pprof Profile.sample_type. This will then also be according to open-telemetry/opentelemetry-proto#649.
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.
OK, can this be clarified in a spec? This is a bit of a departure from other signals where scope typically is to identify the instrumentation used.
// per https://github.com/open-telemetry/semantic-conventions/blob/main/model/profile/registry.yaml | ||
resultProfile.SetOriginalPayloadFormat("go") |
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.
There is no direct correlation between the frame types that are reported with OTel Profiling (https://github.com/open-telemetry/semantic-conventions/blob/main/model/profile/registry.yaml) and the SetOriginalPayloadFormat
. Regular OTel Profiles will also contain python and frames from other programing languges.
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 didn't understand, sorry. Is this value invalid?
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.
Sorry, I was confused about this element.
The best value, when converting Google/pprof to OTel Profiling should be pprof
or something similar, as it should indicate the original resource (google/pprof in this case).
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.
that's not what the spec says though - pointing back at the schema you linked, the exhaustive list of enums has go: https://github.com/open-telemetry/semantic-conventions/blob/main/model/profile/registry.yaml#L71
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.
The spec you are referring to is about profile.frame.type and Describes the interpreter or compiler of a single frame.
. The known list of frame types is in no relation to SetOriginalPayloadFormat
.
The type of a single frame is different to the format of SetOriginalPayloadFormat
. To my knowledge, there is no enum/list that describes known values for SetOriginalPayloadFormat
.
The field original_payload_format
is closely tight to the field original_payload
. And in this context, JFR
is named as a potential payload (and respective format value) in the proto file:
hash = md5.Sum(originalPayload) //nolint:gosec | ||
|
||
// set period | ||
resultProfile.SetPeriod(parsed.Period) |
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.
Here is also a conflict with off CPU profiling as off CPU profiling does not have a regular period but is triggered by scheduler events. So its cadence can change depending on the workload and is not constant, like sampling based on CPU profiling.
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.
should I put something else here? Or not set it in some situations?
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.
It depends, I guess 😅
If the input originates from a sampling based approach, then this value should be set. Otherwise, it should be left out.
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 cannot really know that, can I? Whatever pprof provides can be passed in and pprof can make that assertion?
func pprofToPprofile(parsed *profile.Profile, originalPayload []byte) pprofile.Profiles { | ||
result := pprofile.NewProfiles() | ||
// create a new profile record | ||
resultProfile := result.ResourceProfiles().AppendEmpty().ScopeProfiles().AppendEmpty().Profiles().AppendEmpty() |
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.
To add more complexity 🙈 open-telemetry/opentelemetry-ebpf-profiler#517 will implement the recent changes in the OTel Profiling signal to generate a single ResourceProfile
per container and an additional ResourceProfile for all non-containerized processes. As, I think, google/pprof does not differentiate between containerized elements and others, I think it is hard to map this correctly. Google/pprof might be able to set attributes accordingly, but they might not be standartized.
But I think, there should be one OTel/ScopeProfile per Google/pprof Profile.sample_type. This will then also be according to open-telemetry/opentelemetry-proto#649.
// per https://github.com/open-telemetry/semantic-conventions/blob/main/model/profile/registry.yaml | ||
resultProfile.SetOriginalPayloadFormat("go") |
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.
Sorry, I was confused about this element.
The best value, when converting Google/pprof to OTel Profiling should be pprof
or something similar, as it should indicate the original resource (google/pprof in this case).
hash = md5.Sum(originalPayload) //nolint:gosec | ||
|
||
// set period | ||
resultProfile.SetPeriod(parsed.Period) |
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.
It depends, I guess 😅
If the input originates from a sampling based approach, then this value should be set. Otherwise, it should be left out.
resultL := result.ProfilesDictionary().LocationTable().AppendEmpty() | ||
resultL.SetAddress(l.Address) | ||
resultL.SetIsFolded(l.IsFolded) | ||
for i, m := range result.ProfilesDictionary().MappingTable().All() { |
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.
This might not scale well, if OTels result.ProfilesDictionary().MappingTable()
is prepopulated and for each Location all populated elements are iterated. Maybe just add the mapping from google/pprof into ProfilesDictionary().MappingTable
at this point and set the OTel Location.mapping_index accordingly.
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.
we are not trying to scale, just make a roundtrip pprof -> otlp -> pprof. After that works we can fine tune.
resultS.SetLocationsLength(int32(len(parsed.Location))) | ||
} | ||
|
||
for _, f := range parsed.Function { |
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.
Similar to mappings, the resulting connection between OTel Sample.Location.Line.Function is missing. So I would also suggest to add the google/pprof Function to the OTel Function Dictionary while encountering it while iterating over google Samples.
// TODO set aggregation temporality | ||
} | ||
|
||
commentsIndices := make([]int32, len(parsed.Comments)) |
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.
As google/pprof mixes sample types and profiles in general, it might be hard to assign the google/Profile.comment to the corresponding OTel Profile.comment_strindices, as there could be multiple OTel Profiles per google/Profile.
Co-authored-by: Florian Lehner <florianl@users.noreply.github.com>
This is not ready - opening for discussion and to help move the effort forward.