Skip to content

Commit 143f1b2

Browse files
anivarcharlieegan3
authored andcommitted
docs: Focus metrics documentation on specific builtins per review
Following final review guidance to document only builtin-specific metrics in their respective reference pages. Changes: - http.mdx: Document http.send timer and cache metrics - regex.mdx: Document regex cache hit metric - glob.mdx: Document glob cache hit metric - rest-api.md: Clarify available instrumentation metrics Removed broader metrics documentation from monitoring.md and policy-performance.md per reviewer request to keep changes focused. Fixes #6730 Signed-off-by: Anivar A Aravind <[email protected]>
1 parent 70bc91f commit 143f1b2

File tree

4 files changed

+40
-16
lines changed

4 files changed

+40
-16
lines changed

docs/docs/policy-reference/builtins/glob.mdx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,13 @@ The following table shows examples of how `glob.match` works:
2727
| `output := glob.match("{cat,bat,[fr]at}", [], "bat")` | `true` | A glob with pattern-alternatives matchers. |
2828
| `output := glob.match("{cat,bat,[fr]at}", [], "rat")` | `true` | A glob with pattern-alternatives matchers. |
2929
| `output := glob.match("{cat,bat,[fr]at}", [], "at")` | `false` | A glob with pattern-alternatives matchers. |
30+
31+
## Performance Metrics
32+
33+
When OPA is configured with metrics enabled, `glob.match` operations expose the following metrics in per-query metrics (accessible when `?metrics=true` is specified in API requests):
34+
35+
| Metric | Description |
36+
| ------ | ----------- |
37+
| `counter_rego_builtin_glob_interquery_value_cache_hits` | Number of inter-query cache hits for compiled glob patterns |
38+
39+
Effective glob pattern caching improves performance when the same patterns are used repeatedly across queries. High cache hit ratios indicate that glob compilation overhead is being minimized through caching.

docs/docs/policy-reference/builtins/http.mdx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,3 +113,15 @@ The table below shows examples of calling `http.send`:
113113
| Files containing TLS material | `http.send({"method": "get", "url": "https://127.0.0.1:65331", "tls_ca_cert_file": "testdata/ca.pem", "tls_client_cert_file": "testdata/client-cert.pem", "tls_client_key_file": "testdata/client-key.pem"})` |
114114
| Environment variables containing TLS material | `http.send({"method": "get", "url": "https://127.0.0.1:65360", "tls_ca_cert_env_variable": "CLIENT_CA_ENV", "tls_client_cert_env_variable": "CLIENT_CERT_ENV", "tls_client_key_env_variable": "CLIENT_KEY_ENV"})` |
115115
| Unix Socket URL Format | `http.send({"method": "get", "url": "unix://localhost/?socket=%F2path%F2file.socket"})` |
116+
117+
## Performance Metrics
118+
119+
When OPA is configured with metrics enabled, `http.send` operations expose the following metrics in per-query metrics (accessible when `?metrics=true` is specified in API requests):
120+
121+
| Metric | Description |
122+
| ------ | ----------- |
123+
| `timer_rego_builtin_http_send_ns` | Total time spent in `http.send` calls during query evaluation |
124+
| `counter_rego_builtin_http_send_interquery_cache_hits` | Number of inter-query cache hits for `http.send` requests |
125+
| `counter_rego_builtin_http_send_network_requests` | Number of actual network requests made by `http.send` |
126+
127+
High cache hit ratios indicate effective caching and reduced network overhead. These metrics help identify I/O bottlenecks in policies that make external HTTP requests.

docs/docs/policy-reference/builtins/regex.mdx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,3 +110,13 @@ overlap. This can be useful when using patterns to define permissions or access
110110
rules. The function returns `true` if the two patterns overlap and `false` otherwise.
111111

112112
<PlaygroundExample dir={require.context('../_examples/regex/globs_match/role_patterns')} />
113+
114+
## Performance Metrics
115+
116+
When OPA is configured with metrics enabled, regex operations expose the following metrics in per-query metrics (accessible when `?metrics=true` is specified in API requests):
117+
118+
| Metric | Description |
119+
| ------ | ----------- |
120+
| `counter_rego_builtin_regex_interquery_value_cache_hits` | Number of regex cache hits for compiled patterns |
121+
122+
Effective regex caching improves performance when the same patterns are used repeatedly. High cache hit ratios indicate that regex compilation overhead is being minimized through caching.

docs/docs/rest-api.md

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2311,28 +2311,17 @@ Content-Type: application/json
23112311
}
23122312
```
23132313

2314-
> **Note**: These are per-query metrics returned inline with API responses. For system-wide instance metrics, see the `/metrics` Prometheus endpoint described in [Monitoring](./monitoring#prometheus).
2314+
OPA currently supports the following query performance metrics:
23152315

2316-
OPA provides the following query performance metrics:
2317-
2318-
### Core Query Metrics
23192316
- **timer_rego_input_parse_ns**: time taken (in nanoseconds) to parse the input
23202317
- **timer_rego_query_parse_ns**: time taken (in nanoseconds) to parse the query.
23212318
- **timer_rego_query_compile_ns**: time taken (in nanoseconds) to compile the query.
23222319
- **timer_rego_query_eval_ns**: time taken (in nanoseconds) to evaluate the query.
23232320
- **timer_rego_module_parse_ns**: time taken (in nanoseconds) to parse the input policy module.
23242321
- **timer_rego_module_compile_ns**: time taken (in nanoseconds) to compile the loaded policy modules.
2325-
- **timer_server_handler_ns**: time taken (in nanoseconds) to handle the API request.
2322+
- **timer_server_handler_ns**: time take (in nanoseconds) to handle the API request.
23262323
- **counter_server_query_cache_hit**: number of cache hits for the query.
23272324

2328-
When query instrumentation is enabled (`instrument=true`), the following additional detailed evaluation metrics are included:
2329-
- **timer_eval_op_***: Various evaluation operation timers (e.g., `timer_eval_op_plug_ns`, `timer_eval_op_resolve_ns`)
2330-
- **histogram_eval_op_***: Histograms tracking evaluation operation time distributions
2331-
- **timer_rego_builtin_***: Built-in function execution times
2332-
- **counter_rego_builtin_***: Built-in function call counts and cache hits
2333-
2334-
See [Policy Performance](./policy-performance#performance-metrics) for details on interpreting these metrics.
2335-
23362325
The `counter_server_query_cache_hit` counter gives an indication about whether OPA creates a new Rego query
23372326
or it uses a pre-processed query which holds some prepared state to serve the API request. A pre-processed query will be
23382327
faster to evaluate since OPA will not have to re-parse or compile it. Hence, when the query is served from the cache
@@ -2344,9 +2333,12 @@ Query instrumentation can help diagnose performance problems, however, it can
23442333
add significant overhead to query evaluation. We recommend leaving query
23452334
instrumentation off unless you are debugging a performance problem.
23462335

2347-
When instrumentation is enabled there are several additional performance metrics
2348-
for the compilation stages. They follow the format of `timer_compile_stage_*_ns`
2349-
and `timer_query_compile_stage_*_ns` for the query and module compilation stages.
2336+
When query instrumentation is enabled (`instrument=true`), the following additional detailed evaluation metrics are included:
2337+
- **timer_eval_op_***: Various evaluation operation timers (e.g., `timer_eval_op_plug_ns`, `timer_eval_op_resolve_ns`)
2338+
- **histogram_eval_op_***: Histograms tracking evaluation operation time distributions
2339+
- **timer_rego_builtin_***: Built-in function execution times
2340+
- **counter_rego_builtin_***: Built-in function call counts and cache hits
2341+
- **timer_compile_stage_*_ns**: Compilation stage timers for the query and module compilation stages
23502342

23512343
## Provenance
23522344

0 commit comments

Comments
 (0)