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

feat(server): Expose rate limits for metrics #3347

Merged
merged 14 commits into from
Mar 28, 2024
Prev Previous commit
Next Next commit
doc: More docs
  • Loading branch information
jan-auer committed Mar 28, 2024
commit 0f7de8a24986b92f8ed5d4e993ffcec98c11faa8
14 changes: 12 additions & 2 deletions relay-quotas/src/quota.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ pub struct ItemScoping<'a> {
/// Scoping of the data.
pub scoping: &'a Scoping,

/// Namespace if applicable. `None` matches any namespace.
/// Namespace for metric items, requiring [`DataCategory::MetricBucket`].
pub namespace: MetricNamespaceScoping,
}

Expand Down Expand Up @@ -147,7 +147,17 @@ impl ItemScoping<'_> {

/// Returns `true` if the rate limit namespace matches the namespace of the item.
///
/// If the list of namespaces is empty, this method returns `true`.
/// Matching behavior depends on the passed namespaces and the namespace of the scoping:
/// - If the list of namespaces is empty, this check always returns `true`.
/// - If the list of namespaces contains at least one namespace, a namespace on the scoping is
/// required. [`MetricNamespaceScoping::None`] will not match.
/// - If the namespace of this scoping is [`MetricNamespaceScoping::Any`], this check will
/// always return true.
/// - Otherwise, an exact match of the scoping's namespace must be found in the list.
///
/// `namespace` can be either a slice, an iterator, or a reference to an
/// `Option<MetricNamespace>`. In case of `None`, this method behaves like an empty list and
/// permits any namespace.
pub(crate) fn matches_namespaces<'a, I>(&self, namespaces: I) -> bool
where
I: IntoIterator<Item = &'a MetricNamespace>,
Expand Down
Loading