Skip to content

Commit

Permalink
fix(firestore): remove excessive spans on iterator (#4163)
Browse files Browse the repository at this point in the history
Currently the trace span is logged for each iterator.Next()
even if it's not sending an RPC. Therefore, only the first
iteration is actually useful, the rest happens in memory and not
networked.

Fixes #4133.

Signed-off-by: Ahmet Alp Balkan <ahmetb@google.com>

Co-authored-by: Christopher Wilcox <crwilcox@google.com>
Co-authored-by: Chris Cotter <cjcotter@google.com>
  • Loading branch information
3 people committed Jun 4, 2021
1 parent 99537fe commit 812ef1f
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions firestore/query.go
Expand Up @@ -701,11 +701,11 @@ func newQueryDocumentIterator(ctx context.Context, q *Query, tid []byte) *queryD
}

func (it *queryDocumentIterator) next() (_ *DocumentSnapshot, err error) {
it.ctx = trace.StartSpan(it.ctx, "cloud.google.com/go/firestore.Query.RunQuery")
defer func() { trace.EndSpan(it.ctx, err) }()

client := it.q.c
if it.streamClient == nil {
it.ctx = trace.StartSpan(it.ctx, "cloud.google.com/go/firestore.Query.RunQuery")
defer func() { trace.EndSpan(it.ctx, err) }()

sq, err := it.q.toProto()
if err != nil {
return nil, err
Expand Down

0 comments on commit 812ef1f

Please sign in to comment.