Skip to content

Commit

Permalink
Add usage metrics for export
Browse files Browse the repository at this point in the history
  • Loading branch information
tstirrat15 committed Sep 17, 2024
1 parent 0e7bb64 commit 40bc64a
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions internal/services/v1/permissions.go
Original file line number Diff line number Diff line change
Expand Up @@ -1075,6 +1075,8 @@ func ExportBulk(ctx context.Context, ds datastore.Datastore, batchSize uint64, r
}

emptyRels := make([]*v1.Relationship, limit)
// The number of batches/dispatches for the purpose of usage metrics
var batches uint32
for _, ns := range namespaces {
rels := emptyRels

Expand Down Expand Up @@ -1154,7 +1156,16 @@ func ExportBulk(ctx context.Context, ds datastore.Datastore, batchSize uint64, r
}); err != nil {
return shared.RewriteErrorWithoutConfig(ctx, err)
}
// Increment batches for usagemetrics
batches++
}
}

// Record usage metrics
respMetadata := &dispatch.ResponseMeta{
DispatchCount: batches,
}
usagemetrics.SetInContext(ctx, respMetadata)

return nil
}

0 comments on commit 40bc64a

Please sign in to comment.