Skip to content
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

feature: Customize status bundle_loading_duration_ns #7156

Conversation

jwu730-1
Copy link
Contributor

@jwu730-1 jwu730-1 commented Nov 5, 2024

Why the changes in this PR are needed?

This PR enables the customization of the status configuration to set the bundle_loading_duration_ns buckets and resolves issue #6950

What are the changes in this PR?

extend the support of the prometheus config as below

status:
    prometheus: true
    prometheus_config:
      bundle_loading_duration_ns:
        buckets: [1, 1000, 10_000, 1e8]
  • inject the prometheus configuration during config parsing
  • updated bundleLoadDuration to be customized based on the config
  • during reconfig, re-register collector bundleLoadDuration
  • added unit test
  • small refactoring to make the change more readable

Notes to assist PR review:

Further comments:

Copy link

netlify bot commented Nov 5, 2024

Deploy Preview for openpolicyagent ready!

Name Link
🔨 Latest commit 87d6e6d
🔍 Latest deploy log https://app.netlify.com/sites/openpolicyagent/deploys/6737c40b6f59ef0008726b95
😎 Deploy Preview https://deploy-preview-7156--openpolicyagent.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@jwu730-1 jwu730-1 force-pushed the customize-bundle_loading_duration_ns-buckets branch from d525ba6 to fba2a44 Compare November 5, 2024 16:05
Copy link
Member

@ashutosh-narkar ashutosh-narkar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the contribution @jwu730-1. One thing I notice in your implementation is that we're allowing users to configure the buckets and then defaulting to ExponentialBuckets. I understand this can be an implementation detail but if we simply allowed the user to configure the exponential bucket parameters (start, factor, count for example) and fallback to the current values, it would help to better understand the changes. This should serve your use-case as well and probably simplify the implementation. WDYT?

@jwu730-1
Copy link
Contributor Author

jwu730-1 commented Nov 6, 2024

Hi Ashutosh, thanks for your comment!

I think it would be flexible to set a customized bucket array. e.g. for our use case, we mostly need rough range e.g. 1s, 10s, 1min 3min (mostly)
Also, this configuration will be consistent with buckets setup as http_request_duration_seconds. I keep the default of ExponentialBuckets to be consistent as before in case someone alredy use that for their opa metrics.

Thanks for the contribution @jwu730-1. One thing I notice in your implementation is that we're allowing users to configure the buckets and then defaulting to ExponentialBuckets. I understand this can be an implementation detail but if we simply allowed the user to configure the exponential bucket parameters (start, factor, count for example) and fallback to the current values, it would help to better understand the changes. This should serve your use-case as well and probably simplify the implementation. WDYT?

@ashutosh-narkar
Copy link
Member

I think it would be flexible to set a customized bucket array. e.g. for our use case, we mostly need rough range e.g. 1s, 10s, 1min 3min (mostly)

Can't this be accomplished by setting the parameters of ExponentialBuckets?

@jwu730-1
Copy link
Contributor Author

jwu730-1 commented Nov 7, 2024

if using parameter of ExponentialBuckets, there would be possibly some unused buckets, we would like to eliminate the unused buckets to reduce the metrics size :)

Can't this be accomplished by setting the parameters of ExponentialBuckets?

@ashutosh-narkar
Copy link
Member

there would be possibly some unused buckets, we would like to eliminate the unused buckets to reduce the metrics size :)

Thanks for the context. Are you able to quantify this? If it's not significant, then going with the simpler implementation of configuring the exponential bucket parameters should suffice.

@jwu730-1
Copy link
Contributor Author

Thanks for the context. Are you able to quantify this? If it's not significant, then going with the simpler implementation of configuring the exponential bucket parameters should suffice.

we use the bundle_loading_duration_ns_bucket le as a metric cardinality tag, so we want to reduce the unique values to avoid unnecessary time series.

BTW, I think with exponential bucket parameter, the implementation update is almost the same except

Would love to get comments/suggestions to simplify the implementation, it probably also applies to the current PR. Thanks!

Copy link
Member

@ashutosh-narkar ashutosh-narkar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jwu730-1 the changes seem good. Few comments 👇 . We should also add a test case to exercise the reconfig scenario in the status plugin.

docs/content/configuration.md Outdated Show resolved Hide resolved
docs/content/management-status.md Show resolved Hide resolved
plugins/status/metrics.go Outdated Show resolved Hide resolved
plugins/status/plugin.go Outdated Show resolved Hide resolved
@jwu730-1 jwu730-1 force-pushed the customize-bundle_loading_duration_ns-buckets branch from 26092ab to 984a59e Compare November 15, 2024 21:18
Copy link
Member

@ashutosh-narkar ashutosh-narkar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jwu730-1 the changes look good. Few minor comments. Please squash your commits per the guidelines here and we can get this in. Thanks for working on this!

plugins/status/metrics.go Outdated Show resolved Hide resolved
plugins/status/plugin.go Outdated Show resolved Hide resolved
@jwu730-1 jwu730-1 force-pushed the customize-bundle_loading_duration_ns-buckets branch from 6dc4b54 to 2183ae4 Compare November 18, 2024 15:23
Copy link
Member

@ashutosh-narkar ashutosh-narkar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Please squash your commits and we can get this in.

@jwu730-1 jwu730-1 force-pushed the customize-bundle_loading_duration_ns-buckets branch 2 times, most recently from 05ed19b to facbf98 Compare November 19, 2024 16:09
Signed-off-by: Jessie Wu <jwu730@bloomberg.net>
@jwu730-1 jwu730-1 force-pushed the customize-bundle_loading_duration_ns-buckets branch from facbf98 to d47ee92 Compare November 19, 2024 16:10
@jwu730-1
Copy link
Contributor Author

Done. Thank you @ashutosh-narkar!

Copy link
Member

@ashutosh-narkar ashutosh-narkar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the contribution @jwu730-1!

@ashutosh-narkar ashutosh-narkar merged commit 0d50f52 into open-policy-agent:main Nov 19, 2024
28 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants