Skip to content

Commit

Permalink
fix(firestore): remove excessive spans on iterator (googleapis#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 googleapis#4133.

Signed-off-by: Ahmet Alp Balkan <[email protected]>

Co-authored-by: Christopher Wilcox <[email protected]>
Co-authored-by: Chris Cotter <[email protected]>
  • Loading branch information
3 people authored 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
Original file line number Diff line number Diff line change
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.