diff --git a/internal/datastore/spanner/reader.go b/internal/datastore/spanner/reader.go index d8b4beb181..821de67035 100644 --- a/internal/datastore/spanner/reader.go +++ b/internal/datastore/spanner/reader.go @@ -182,6 +182,9 @@ func queryExecutor(txSource txFactory) common.ExecuteQueryFunc { span.AddEvent("start reading iterator") defer span.AddEvent("finished reading iterator") + relCount := 0 + defer span.SetAttributes(attribute.Int("count", relCount)) + if err := iter.Do(func(row *spanner.Row) error { var resourceObjectType string var resourceObjectID string @@ -210,6 +213,7 @@ func queryExecutor(txSource txFactory) common.ExecuteQueryFunc { return err } + relCount++ if !yield(tuple.Relationship{ RelationshipReference: tuple.RelationshipReference{ Resource: tuple.ObjectAndRelation{ diff --git a/internal/services/v1/experimental_test.go b/internal/services/v1/experimental_test.go index 252d20e442..b098909f51 100644 --- a/internal/services/v1/experimental_test.go +++ b/internal/services/v1/experimental_test.go @@ -14,6 +14,7 @@ import ( v1 "github.com/authzed/authzed-go/proto/authzed/api/v1" "github.com/authzed/grpcutil" "github.com/ccoveille/go-safecast" + "github.com/jzelinskie/stringz" "github.com/scylladb/go-set" "github.com/stretchr/testify/require" "go.uber.org/goleak" @@ -644,11 +645,7 @@ func TestBulkCheckPermission(t *testing.T) { }, } - rel := reqRel.Subject.Relation - if rel == tuple.Ellipsis { - rel = "" - } - + rel := stringz.Default(reqRel.Subject.Relation, "", tuple.Ellipsis) pair := &v1.BulkCheckPermissionPair{ Request: &v1.BulkCheckPermissionRequestItem{ Resource: &v1.ObjectReference{ @@ -701,10 +698,7 @@ func TestBulkCheckPermission(t *testing.T) { func relToBulkRequestItem(rel string) *v1.BulkCheckPermissionRequestItem { r := tuple.MustParse(rel) - subjectRel := r.Subject.Relation - if subjectRel == tuple.Ellipsis { - subjectRel = "" - } + subjectRel := stringz.Default(r.Subject.Relation, "", tuple.Ellipsis) item := &v1.BulkCheckPermissionRequestItem{ Resource: &v1.ObjectReference{