pub struct Quota {
pub id: Option<String>,
pub categories: DataCategories,
pub scope: QuotaScope,
pub scope_id: Option<String>,
pub limit: Option<u64>,
pub window: Option<u64>,
pub namespace: Option<MetricNamespace>,
pub reason_code: Option<ReasonCode>,
}
Expand description
Configuration for a data ingestion quota.
A quota defines restrictions on data ingestion based on data categories, scopes, and time windows. The system applies multiple quotas to incoming data, and items are counted against all matching quotas based on their categories.
Quotas can either:
- Reject all data (
limit
= 0) - Limit data to a specific quantity per time window (
limit
> 0) - Count data without limiting it (
limit
= None)
Different quotas may apply at different scope levels (organization, project, key).
Fields§
§id: Option<String>
The unique identifier for counting this quota.
Required for all quotas except those with limit
= 0, which are statically enforced.
categories: DataCategories
Data categories this quota applies to.
If missing or empty, this quota applies to all data categories.
scope: QuotaScope
The scope level at which this quota is enforced.
The quota is enforced separately within each instance of this scope
(e.g., for each project key separately). Defaults to QuotaScope::Organization
.
scope_id: Option<String>
Specific scope instance identifier this quota applies to.
If set, this quota only applies to the specified scope instance
(e.g., a specific project key). Requires scope
to be set explicitly.
limit: Option<u64>
Maximum number of events allowed within the time window.
Possible values:
Some(0)
: Reject all matching eventsSome(n)
: Allow up to n events per time windowNone
: Unlimited quota (counts but doesn’t limit)
Requires window
to be set if the limit is not 0.
window: Option<u64>
The time window in seconds for quota enforcement.
Required in all cases except limit
= 0, since those quotas
are not measured over time.
namespace: Option<MetricNamespace>
The metric namespace this quota applies to.
If None
, it matches any namespace.
reason_code: Option<ReasonCode>
A machine-readable reason code returned when this quota is exceeded.
Required for all quotas except those with limit
= None, since
unlimited quotas can never be exceeded.
Implementations§
Source§impl Quota
impl Quota
Sourcepub fn is_valid(&self) -> bool
pub fn is_valid(&self) -> bool
Returns whether this quota is valid for tracking.
A quota is considered invalid if any of the following conditions are true:
- The quota only applies to
DataCategory::Unknown
data categories. - The quota is counted (not limit
0
) but specifies categories with different units. - The quota references an unsupported namespace.
Sourcepub fn matches(&self, scoping: ItemScoping) -> bool
pub fn matches(&self, scoping: ItemScoping) -> bool
Checks whether the quota’s constraints match the current item.
This method determines if this quota should be applied to a given item based on its scope, categories, and namespace.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Quota
impl<'de> Deserialize<'de> for Quota
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for Quota
impl StructuralPartialEq for Quota
Auto Trait Implementations§
impl Freeze for Quota
impl RefUnwindSafe for Quota
impl Send for Quota
impl Sync for Quota
impl Unpin for Quota
impl UnwindSafe for Quota
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more