-
Notifications
You must be signed in to change notification settings - Fork 904
chore: More complete tracing for RBAC functions #5690
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Remaining data points untracked: - Number of queries after a prepare - CompileToSQL time Excluded: - Any IDs, not needed - Authorize result (true/false) - Authorize reason (group or perms for true)
The input.json is required to play with the rego cli and debug the policy without golang. It is good to have an example to run the commands in the readme.md
Prometheus metrics only track single authorize and prepare calls
coderd/rbac/authz.go
Outdated
span.AddEvent("prepared", | ||
trace.WithAttributes(attribute.Int("num_queries", len(prepared.preparedQueries))), | ||
trace.WithAttributes(attribute.Bool("always_true", prepared.alwaysTrue)), | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think instead of adding an event to attach these attributes it'd make more sense to just attach them to the parent span above, or just give (RegoAuthorizer).Prepare
it's own span?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I made it an event because I wanted the timing of the prepare
call, so these are the return values. I agree it would be better on the parent.
If I use time.Now()
and WithTimestamp
though, I could start the span after the call happened and get all attributes. what do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it might just be better to call tracing.StartSpan()
inside prepare then? That way you have the timing for that function specifically and can add attributes to it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The attributes are the return though. So even if I put it in, I cannot put those attributes at the start of the call.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tracing.StartSpan
returns a span you can set the attributes on
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh TIL I can add attributes after a span was stared. I thought I read that you could not. I'll just add to parent span 👍
Github syncing is having issues on this PR for some reason.
Filter
function has tracing for the batch ifFilter
becomes slow.Extra
I also added more benchmarks to benchmark the
Authorize
function. I am seeing the average time being <1ms. Telemetry shows some slower authorize calls, hoping these attributes helps identify some patterns in what calls are slow.