Skip to content

Commit 4154b78

Browse files
authored
Merge pull request #127 from josephschorr/bulk-check-debug
Add debug trace support to bulk check API
2 parents 05f596b + 4b70b0b commit 4154b78

2 files changed

Lines changed: 25 additions & 0 deletions

File tree

authzed/api/v1/debug.proto

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ message CheckDebugTrace {
4646
}
4747

4848
// resource holds the resource on which the Check was performed.
49+
// for batched calls, the object_id field contains a comma-separated list of object IDs
50+
// for all the resources checked in the batch.
4951
ObjectReference resource = 1 [ (validate.rules).message.required = true ];
5052

5153
// permission holds the name of the permission or relation on which the Check was performed.
@@ -82,6 +84,21 @@ message CheckDebugTrace {
8284
// optional_expires_at is the time at which at least one of the relationships used to
8385
// compute this result, expires (if any). This is *not* related to the caching window.
8486
google.protobuf.Timestamp optional_expires_at = 10;
87+
88+
// trace_operation_id is a unique identifier for this trace's operation, that will
89+
// be shared for all traces created for the same check operation in SpiceDB.
90+
//
91+
// In cases where SpiceDB performs automatic batching of subproblems, this ID can be used
92+
// to correlate work that was shared across multiple traces.
93+
//
94+
// This identifier is generated by SpiceDB, is to be considered opaque to the caller
95+
// and only guaranteed to be unique within the same overall Check or CheckBulk operation.
96+
string trace_operation_id = 11;
97+
98+
// source holds the source of the result. It is of the form:
99+
// `<sourcetype>:<sourceid>`, where sourcetype can be, among others:
100+
// `spicedb`, `materialize`, etc.
101+
string source = 12;
85102
}
86103

87104
// CaveatEvalInfo holds information about a caveat expression that was evaluated.

authzed/api/v1/permission_service.proto

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -421,6 +421,11 @@ message CheckBulkPermissionsRequest {
421421
Consistency consistency = 1;
422422

423423
repeated CheckBulkPermissionsRequestItem items = 2 [ (validate.rules).repeated .items.message.required = true ];
424+
425+
// with_tracing, if true, indicates that each response should include a debug trace.
426+
// This can be useful for debugging and performance analysis, but adds a small amount
427+
// of compute overhead to the request.
428+
bool with_tracing = 3;
424429
}
425430

426431
message CheckBulkPermissionsRequestItem {
@@ -454,6 +459,9 @@ message CheckBulkPermissionsResponseItem {
454459
CheckPermissionResponse.Permissionship permissionship = 1 [ (validate.rules).enum = {defined_only: true, not_in: [0]} ];
455460

456461
PartialCaveatInfo partial_caveat_info = 2 [ (validate.rules).message.required = false ];
462+
463+
// debug_trace is the debugging trace of this check, if requested.
464+
DebugInformation debug_trace = 3;
457465
}
458466

459467
// ExpandPermissionTreeRequest returns a tree representing the expansion of all

0 commit comments

Comments
 (0)