Skip to content

Commit 75b7706

Browse files
committed
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
1 parent eaccbfa commit 75b7706

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
@@ -2263,28 +2263,17 @@ Content-Type: application/json
22632263
}
22642264
```
22652265

2266-
> **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).
2266+
OPA currently supports the following query performance metrics:
22672267

2268-
OPA provides the following query performance metrics:
2269-
2270-
### Core Query Metrics
22712268
- **timer_rego_input_parse_ns**: time taken (in nanoseconds) to parse the input
22722269
- **timer_rego_query_parse_ns**: time taken (in nanoseconds) to parse the query.
22732270
- **timer_rego_query_compile_ns**: time taken (in nanoseconds) to compile the query.
22742271
- **timer_rego_query_eval_ns**: time taken (in nanoseconds) to evaluate the query.
22752272
- **timer_rego_module_parse_ns**: time taken (in nanoseconds) to parse the input policy module.
22762273
- **timer_rego_module_compile_ns**: time taken (in nanoseconds) to compile the loaded policy modules.
2277-
- **timer_server_handler_ns**: time taken (in nanoseconds) to handle the API request.
2274+
- **timer_server_handler_ns**: time take (in nanoseconds) to handle the API request.
22782275
- **counter_server_query_cache_hit**: number of cache hits for the query.
22792276

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

2299-
When instrumentation is enabled there are several additional performance metrics
2300-
for the compilation stages. They follow the format of `timer_compile_stage_*_ns`
2301-
and `timer_query_compile_stage_*_ns` for the query and module compilation stages.
2288+
When query instrumentation is enabled (`instrument=true`), the following additional detailed evaluation metrics are included:
2289+
- **timer_eval_op_***: Various evaluation operation timers (e.g., `timer_eval_op_plug_ns`, `timer_eval_op_resolve_ns`)
2290+
- **histogram_eval_op_***: Histograms tracking evaluation operation time distributions
2291+
- **timer_rego_builtin_***: Built-in function execution times
2292+
- **counter_rego_builtin_***: Built-in function call counts and cache hits
2293+
- **timer_compile_stage_*_ns**: Compilation stage timers for the query and module compilation stages
23022294

23032295
## Provenance
23042296

0 commit comments

Comments
 (0)