Repository navigation
docs: Document metrics for http.send, regex, and glob builtins - #8103
Conversation
5eb1145 to
67ce08d
Compare
✅ Deploy Preview for openpolicyagent ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
✅ Deploy Preview for openpolicyagent ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
This pull request has been automatically marked as stale because it has not had any activity in the last 30 days. |
✅ Deploy Preview for openpolicyagent ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
1735ad5 to
e0d2a51
Compare
✅ Deploy Preview for openpolicyagent ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
Hey @anivar, have you had another chanced to look at this yet? Keen to get this in now if we can. |
✅ Deploy Preview for openpolicyagent ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
dcbc7a6 to
a47d1de
Compare
charlieegan3
left a comment
There was a problem hiding this comment.
Please can you leave all sections as they are, but review the http one as I think something is wrong there. Please provide the policy and commands you are using to test these docs in the thread.
I am finding this PR's updates very hard to review due to the rebasing, please do not rebase this PR until we are ready to merge so I can review changes as you make them.
| | `output := glob.match("{cat,bat,[fr]at}", [], "rat")` | `true` | A glob with pattern-alternatives matchers. | | ||
| | `output := glob.match("{cat,bat,[fr]at}", [], "at")` | `false` | A glob with pattern-alternatives matchers. | | ||
|
|
||
| ## Performance Metrics |
There was a problem hiding this comment.
This section has been checked, please leave it as is.
| | ------ | ----------- | | ||
| | `timer_rego_builtin_http_send_ns` | Time spent in `http.send` calls during evaluation | | ||
| | `counter_rego_builtin_http_send_interquery_cache_hits` | Number of `http.send` requests served from the inter-query cache. Only present when [inter-query caching](/docs/configuration/#caching) is enabled | | ||
| | `counter_rego_builtin_http_send_network_requests` | Number of actual network requests made, excluding cached responses | |
There was a problem hiding this comment.
Please share the command you are using to test this, I am not seeing counter_rego_builtin_http_send_interquery_cache_hits and counter_rego_builtin_http_send_network_requests with the ?metrics=true and config:
caching:
inter_query_builtin_cache:
max_size_bytes: 10485760There was a problem hiding this comment.
Here's the policy and commands I used to verify the http.send metrics:
policy.rego:
package httptest
import rego.v1
result := http.send({
"method": "GET",
"url": "https://httpbin.org/get",
"cache": true,
"force_cache": true,
"force_cache_duration_seconds": 30,
})
config.yaml:
caching:
inter_query_builtin_cache:
max_size_bytes: 10485760
Commands:
opa run --server --config-file config.yaml policy.rego
1st request — populates cache:
curl -s 'http://localhost:8181/v1/data/httptest/result?metrics=true'
# metrics: timer_rego_builtin_http_send_ns, counter_rego_builtin_http_send_network_requests: 1
2nd request — hits cache:
curl -s 'http://localhost:8181/v1/data/httptest/result?metrics=true'
# metrics: timer_rego_builtin_http_send_ns, counter_rego_builtin_http_send_interquery_cache_hits: 1
The cache hit counter requires "cache": true or "force_cache": true in the http.send request object . server-level caching config alone isn't sufficient.
There was a problem hiding this comment.
Ok great, thanks for clarifying this!
|
|
||
| <PlaygroundExample dir={require.context('../_examples/regex/globs_match/role_patterns')} /> | ||
|
|
||
| ## Performance Metrics |
There was a problem hiding this comment.
This section has been checked, please leave it as is.
| When instrumentation is enabled there are several additional performance metrics | ||
| for the compilation stages. They follow the format of `timer_compile_stage_*_ns` | ||
| and `timer_query_compile_stage_*_ns` for the query and module compilation stages. | ||
| When query instrumentation is enabled (`instrument=true`), the following additional metrics are included: |
There was a problem hiding this comment.
Please do not change this section has it has been checked.
charlieegan3
left a comment
There was a problem hiding this comment.
I think there was some confusion, my comments "This section has been checked, please leave it as is." meant just "please do not update this section in the next commit".
So in:
You have brought back some older changes that I didn't think we wanted to keep.
I think now if we jump back to the version you had in e71a3bf and make the suggestd change about the http.send configuration in this review, then rebase against main, we should be good here.
| | Metric | Description | | ||
| | ------ | ----------- | | ||
| | `timer_rego_builtin_http_send_ns` | Total time spent in `http.send` calls during query evaluation | | ||
| | `counter_rego_builtin_http_send_interquery_cache_hits` | Number of inter-query cache hits for `http.send` requests. Only appears when [inter-query caching is enabled](/docs/configuration/#caching) in OPA's configuration and the request includes `cache` or `force_cache` set to `true` | |
There was a problem hiding this comment.
| | `counter_rego_builtin_http_send_interquery_cache_hits` | Number of inter-query cache hits for `http.send` requests. Only appears when [inter-query caching is enabled](/docs/configuration/#caching) in OPA's configuration and the request includes `cache` or `force_cache` set to `true` | | |
| | `counter_rego_builtin_http_send_interquery_cache_hits` | Number of inter-query cache hits for `http.send` requests. Only appears when [inter-query caching is enabled](/docs/configuration/#caching) in OPA's configuration and the `http.send` request configuration has `cache` or `force_cache` set to `true` | |
| | ------ | ----------- | | ||
| | `timer_rego_builtin_http_send_ns` | Time spent in `http.send` calls during evaluation | | ||
| | `counter_rego_builtin_http_send_interquery_cache_hits` | Number of `http.send` requests served from the inter-query cache. Only present when [inter-query caching](/docs/configuration/#caching) is enabled | | ||
| | `counter_rego_builtin_http_send_network_requests` | Number of actual network requests made, excluding cached responses | |
There was a problem hiding this comment.
Ok great, thanks for clarifying this!
3d1e5aa to
a0399f7
Compare
|
Hi, the DCO check is failing, are you able to sign off your commits. As I have explained in my previous PR reviews, #8103 (review) and #8103 (review), it is very hard to review this with the sweeping edits and the rebasing. Would it be possible to avoid rebasing this while we work towards an acceptable version? Please ensure that all new commits have DCO as required, and please do not rebase from main until we are ready to merge to aid reviewing. |
a0399f7 to
f9e962e
Compare
I exactly followed your instruction last time and not rebased |
✅ Deploy Preview for openpolicyagent ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
charlieegan3
left a comment
There was a problem hiding this comment.
Ok thanks, I have reviewed now and this looks good to me.
Fixes open-policy-agent#6730 Signed-off-by: Anivar A Aravind <ping@anivar.net>
f9e962e to
fc4b2a5
Compare
This PR addresses issue #6730 and the feedback from the closed PR #7929.
The original PR attempted to create a comprehensive metrics registry documenting all OPA metrics. After review, that approach was too broad - it created maintenance overhead and put documentation in places where users wouldn't naturally look for it.
This PR takes a simpler approach: document metrics right where users need them - on the builtin reference pages themselves. When someone is reading about
http.send, they can scroll down and see exactly what metrics it exposes. Same forregexandglob.Added Performance Metrics sections to three builtin pages:
These are the most commonly used builtins that expose their own metrics. Also clarified the REST API docs to explain what additional metrics you get when you enable
instrument=true.Following reviewer feedback, this PR intentionally does NOT create a comprehensive registry, add a generator tool, or update monitoring.md/policy-performance.md. Those can be addressed separately if needed.
Fixes #6730