Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin' into viglia/feat/use-unsamlped-…
Browse files Browse the repository at this point in the history
…profiles-for-aggregation
  • Loading branch information
viglia committed Jan 23, 2024
2 parents 33d36c3 + f87340c commit 6faad25
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
with:
fetch-depth: 0
- name: TruffleHog OSS
uses: trufflesecurity/[email protected].9
uses: trufflesecurity/[email protected].10
with:
path: ./
base: ${{ github.event.repository.default_branch }}
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
**Features**:

- Add support for speedscope rendering of Android reactnative profiles ([#386](https://github.com/getsentry/vroom/pull/386))
- Add callTree generation for reactnative (android+js) profiles ([#390](https://github.com/getsentry/vroom/pull/390))
- Use profiles that were not dynamically sampled to enhance slowest functions aggregation ([#300](https://github.com/getsentry/vroom/pull/300))

**Bug Fixes**:
Expand All @@ -13,6 +14,7 @@
- Bump trufflesecurity/trufflehog from 3.63.5 to 3.63.7 ([#385](https://github.com/getsentry/vroom/pull/385))
- Bump number of workers for flamegraph dynamically ([#388](https://github.com/getsentry/vroom/pull/388))
- Bump trufflesecurity/trufflehog from 3.63.8 to 3.63.9 ([#389](https://github.com/getsentry/vroom/pull/389))
- Bump trufflesecurity/trufflehog from 3.63.9 to 3.63.10 ([#391](https://github.com/getsentry/vroom/pull/391))

## 23.12.0

Expand Down
39 changes: 39 additions & 0 deletions internal/profile/legacy.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
const maxProfileDurationForCallTrees = 15 * time.Second

var ErrProfileHasNoTrace = errors.New("profile has no trace")
var ErrReactHasInvalidJsTrace = errors.New("react-android profile has invalid js trace")
var member void

type (
Expand Down Expand Up @@ -147,6 +148,26 @@ func (p LegacyProfile) CallTrees() (map[uint64][]*nodetree.Node, error) {
if p.Trace == nil {
return nil, ErrProfileHasNoTrace
}
_, ok := p.Trace.(Android)
// this is to handle only the Reactnative (android + js)
// use case. If it's an Android profile but there is no
// js profile, we'll skip this entirely
if ok && p.JsProfile != nil && len(p.JsProfile) > 0 {
st, err := unmarshalSampleProfile(p.JsProfile)
if err != nil {
return nil, ErrReactHasInvalidJsTrace
}
jsProf := sample.Profile{
RawProfile: sample.RawProfile{
Trace: st,
},
}
err = fillSampleProfileMetadata(&jsProf)
if err != nil {
return nil, err
}
return jsProf.CallTrees()
}
return p.Trace.CallTrees(), nil
}

Expand Down Expand Up @@ -481,3 +502,21 @@ func unmarshalSampleProfile(p json.RawMessage) (sample.Trace, error) {

return st, nil
}

// CallTree generation expect activeThreadID to be set in
// order to be able to choose which samples should be used
// for the aggregation.
// Here we set it to the only thread that the js profile has.
func fillSampleProfileMetadata(sp *sample.Profile) error {
for threadID := range sp.Trace.ThreadMetadata {
tid, err := strconv.ParseUint(threadID, 10, 64)
if err != nil {
return err
}
sp.Transaction = transaction.Transaction{
ActiveThreadID: tid,
}
break
}
return nil
}

0 comments on commit 6faad25

Please sign in to comment.