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 (rate limiting).
Sentry applies multiple quotas to incoming data before accepting it, some of which can be
configured by the customer. Each piece of data (such as event, attachment) will be counted
against all quotas that it matches with based on the category
.
Fields§
§id: Option<String>
The unique identifier for counting this quota. Required, except for quotas with a limit
of
0
, since they are statically enforced.
categories: DataCategories
A set of data categories that this quota applies to. If missing or empty, this quota applies to all data.
scope: QuotaScope
A scope for this quota. This 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>
Identifier of the scope to apply to. If set, then this quota will only apply to the
specified scope instance (e.g. a project key). Requires scope
to be set explicitly.
limit: Option<u64>
Maximum number of matching events allowed. Can be 0
to reject all events, None
for an
unlimited counted quota, or a positive number for enforcement. Requires window
if the
limit is not 0
.
For attachments, this limit expresses the number of allowed bytes.
window: Option<u64>
The time window in seconds to enforce this quota in. Required in all cases except limit=0
,
since those quotas are not measured.
namespace: Option<MetricNamespace>
The namespace the quota applies to.
If None
, it will match any namespace.
reason_code: Option<ReasonCode>
A machine readable reason returned when this quota is exceeded. Required in all cases except
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.
There are a few conditions at which quotas are invalid:
- The quota only applies to
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.
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 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,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)§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