Tracing
Polar’s tracing support prints logs of how a query is evaluated. It is available in both INFO
and TRACE
level outputs.
Enabling INFO
output
INFO
traces are viewed by setting the environment variable: POLAR_LOG=info
. The INFO
output is a more concise subset of TRACE
and is intended to by used by those developing and debugging polar policies in their local environment.
It will print out [oso][info]
messages for many notable points of the query execution, for example:
-
Queries for rules.
-
Source information for the rules which were applicable to each query, and a warning if none were found to be applicable.
-
Query successes and the contents of any variable bindings returned by Oso.
Enabling TRACE
output
TRACE
logs are viewed by setting an environment variable: POLAR_LOG=trace
.
POLAR_LOG=trace
exposes a more verbose view of a query execution in Polar and extends the contents of POLAR_LOG=info
. The POLAR_LOG=trace
traces will emit a log for every Goal encountered by the Polar virtual machine during the query execution. Notable examples include:
-
Showing parameter type checking information during query applicability tests.
-
Showing values that are bound to variables for each expression.
-
Showing values returned from calls into the application.
-
All query evaluations; not limited to rules like
POLAR_LOG=info
.
Example
[oso][info] QUERY RULE: allow(<__main__.User object at 0x7f1db433d640> TYPE `User`, "view", <__main__.Repository object at 0x7f1db433d610> TYPE `Repository`)
[oso][info] APPLICABLE_RULES:
[oso][info] allow(actor, action, resource) at line 11, column 5
[oso][info] QUERY RULE: has_permission(_actor_4, _action_5, _resource_6)
[oso][info] QUERY RULE: has_relation(_actor_11, "owner", _repository_12)
[oso][info] RESULT: SUCCESS
True
[oso][info] QUERY RULE: allow(<__main__.User object at 0x7f1db433d640> TYPE `User`, "view", <__main__.Project object at 0x7f1db433d310> TYPE `UNKNOWN`)
[oso][info] APPLICABLE_RULES:
[oso][info] allow(actor, action, resource) at line 11, column 5
[oso][info] QUERY RULE: has_permission(_actor_26, _action_27, _resource_28)
[oso][info] No matching rules found
False
All POLAR_LOG
output can be disabled by setting POLAR_LOG=0
or POLAR_LOG=off
.
Connect with us on Slack
If you have any questions, or just want to talk something through, jump into Slack. An Oso engineer or one of the thousands of developers in the growing community will be happy to help.