fix: Panic in query/controller on Statistics

pull/10616/head
Nathaniel Cook 2018-07-27 09:15:28 -06:00
parent 0783a16c26
commit 47b7f512da
1 changed files with 6 additions and 1 deletions

View File

@ -435,6 +435,9 @@ func (q *Query) Done() {
// Statistics reports the statisitcs for the query. // Statistics reports the statisitcs for the query.
// The statisitcs are not complete until the query is finished. // The statisitcs are not complete until the query is finished.
func (q *Query) Statistics() query.Statistics { func (q *Query) Statistics() query.Statistics {
q.mu.Lock()
defer q.mu.Lock()
stats := query.Statistics{} stats := query.Statistics{}
stats.TotalDuration = q.parentSpan.Duration stats.TotalDuration = q.parentSpan.Duration
if q.compileSpan != nil { if q.compileSpan != nil {
@ -453,7 +456,9 @@ func (q *Query) Statistics() query.Statistics {
stats.ExecuteDuration = q.executeSpan.Duration stats.ExecuteDuration = q.executeSpan.Duration
} }
stats.Concurrency = q.concurrency stats.Concurrency = q.concurrency
stats.MaxAllocated = q.alloc.Max() if q.alloc != nil {
stats.MaxAllocated = q.alloc.Max()
}
return stats return stats
} }