Skip to content
Merged
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
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# Changelog

## Unreleased

**Features**:

**Bug Fixes**:

**Internal**:

- Fix flamegraph endpoint span nesting. ([#677](https://github.com/getsentry/vroom/pull/677))

## 26.9.0

- No documented changes.
Expand Down
5 changes: 2 additions & 3 deletions cmd/vroom/flamegraph.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,21 +54,20 @@ func (env *environment) postFlamegraph(w http.ResponseWriter, r *http.Request) {
return
}

s = sentry.StartSpan(ctx, "processing")
s = sentry.StartSpan(downloadContext, "processing")
var ma *metrics.Aggregator
if body.GenerateMetrics {
agg := metrics.NewAggregator(maxUniqueFunctionsPerProfile, 5, minDepth)
ma = &agg
}
speedscope, err := flamegraph.GetFlamegraphFromCandidates(
downloadContext,
s.Context(),
env.storage,
organizationID,
body.Transaction,
body.Continuous,
readJobs,
ma,
s,
)
s.Finish()
if err != nil {
Expand Down
21 changes: 10 additions & 11 deletions internal/flamegraph/flamegraph.go
Original file line number Diff line number Diff line change
Expand Up @@ -367,21 +367,21 @@ func GetFlamegraphFromCandidates(
continuousProfileCandidates []examples.ContinuousProfileCandidate,
jobs chan storageutil.ReadJob,
ma *metrics.Aggregator,
span *sentry.Span,
) (speedscope.Output, error) {
hub := sentry.GetHubFromContext(ctx)

results := make(chan storageutil.ReadJobResult)
defer close(results)

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

for _, candidate := range transactionProfileCandidates {
jobs <- profile.CallTreesReadJob{
Ctx: ctx,
Ctx: dispatchSpan.Context(),
OrganizationID: organizationID,
ProjectID: candidate.ProjectID,
ProfileID: candidate.ProfileID,
Expand All @@ -392,7 +392,7 @@ func GetFlamegraphFromCandidates(

for _, candidate := range continuousProfileCandidates {
jobs <- chunk.CallTreesReadJob{
Ctx: ctx,
Ctx: dispatchSpan.Context(),
OrganizationID: organizationID,
ProjectID: candidate.ProjectID,
ProfilerID: candidate.ProfilerID,
Expand All @@ -405,13 +405,11 @@ func GetFlamegraphFromCandidates(
Result: results,
}
}

dispatchSpan.Finish()
}()

var flamegraphTree []*nodetree.Node

flamegraphSpan := span.StartChild("processing candidates")
flamegraphSpan := sentry.StartSpan(ctx, "processing candidates")

numCandidates := len(transactionProfileCandidates) + len(continuousProfileCandidates)

Expand Down Expand Up @@ -439,7 +437,7 @@ func GetFlamegraphFromCandidates(
}

if result, ok := res.(profile.CallTreesReadJobResult); ok {
transactionProfileSpan := span.StartChild("calltree")
transactionProfileSpan := flamegraphSpan.StartChild("calltree")
transactionProfileSpan.Description = "transaction profile"

start, end := result.Profile.StartAndEndEpoch()
Expand All @@ -463,7 +461,7 @@ func GetFlamegraphFromCandidates(

transactionProfileSpan.Finish()
} else if result, ok := res.(chunk.CallTreesReadJobResult); ok {
chunkProfileSpan := span.StartChild("calltree")
chunkProfileSpan := flamegraphSpan.StartChild("calltree")
chunkProfileSpan.Description = "continuous profile"

for threadID, callTree := range result.CallTrees {
Expand Down Expand Up @@ -498,16 +496,17 @@ func GetFlamegraphFromCandidates(
chunkProfileSpan.Finish()
} else {
// This should never happen
flamegraphSpan.Finish()
return speedscope.Output{}, errors.New("unexpected result from storage")
}
}

flamegraphSpan.Finish()

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

sp := toSpeedscope(ctx, flamegraphTree, 1000, 0)
sp := toSpeedscope(serializeSpan.Context(), flamegraphTree, 1000, 0)
if ma != nil {
fm := ma.ToMetrics()
sp.Metrics = &fm
Expand Down
Loading