Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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 CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
**Internal**:

- Fix flamegraph endpoint span nesting. ([#677](https://github.com/getsentry/vroom/pull/677))
- More robust concurrency structure for flamegraph generation. ([#678](https://github.com/getsentry/vroom/pull/678))

## 26.9.0

Expand Down
21 changes: 16 additions & 5 deletions internal/flamegraph/flamegraph.go
Original file line number Diff line number Diff line change
Expand Up @@ -371,13 +371,16 @@ func GetFlamegraphFromCandidates(
hub := sentry.GetHubFromContext(ctx)

results := make(chan storageutil.ReadJobResult)
defer close(results)
dispatchDone := make(chan struct{})

go func() {
dispatchSpan := sentry.StartSpan(ctx, "dispatch candidates")
dispatchSpan.SetData("transaction_candidates", len(transactionProfileCandidates))
dispatchSpan.SetData("continuous_candidates", len(continuousProfileCandidates))
defer dispatchSpan.Finish()
defer func() {
dispatchSpan.Finish()
close(dispatchDone)
}()

for _, candidate := range transactionProfileCandidates {
jobs <- profile.CallTreesReadJob{
Expand Down Expand Up @@ -412,10 +415,15 @@ func GetFlamegraphFromCandidates(
flamegraphSpan := sentry.StartSpan(ctx, "processing candidates")

numCandidates := len(transactionProfileCandidates) + len(continuousProfileCandidates)
var processingErr error

for i := 0; i < numCandidates; i++ {
res := <-results

if processingErr != nil {
continue
}

err := res.Error()
if err != nil {
if errors.Is(err, storageutil.ErrObjectNotFound) {
Expand Down Expand Up @@ -495,14 +503,17 @@ func GetFlamegraphFromCandidates(
}
chunkProfileSpan.Finish()
} else {
// This should never happen
flamegraphSpan.Finish()
return speedscope.Output{}, errors.New("unexpected result from storage")
processingErr = errors.New("unexpected result from storage")
}
}

<-dispatchDone
flamegraphSpan.Finish()

if processingErr != nil {
return speedscope.Output{}, processingErr
}

serializeSpan := sentry.StartSpan(ctx, "serialize")
defer serializeSpan.Finish()

Expand Down
Loading