pub enum Context {
Metric(MetricContext),
Event(EventContext),
ServiceCheck(ServiceCheckContext),
}Expand description
A reusable DogStatsD identity of one of the three kinds.
Variants§
Metric(MetricContext)
A metric identity.
Event(EventContext)
An event identity.
ServiceCheck(ServiceCheckContext)
A service-check identity.
Implementations§
Source§impl Context
impl Context
Sourcepub fn mint_within(
kind: Kind,
rng: &mut (impl Rng + ?Sized),
budget: usize,
) -> Option<Context>
pub fn mint_within( kind: Kind, rng: &mut (impl Rng + ?Sized), budget: usize, ) -> Option<Context>
Mint a context of kind whose renders fit budget and that the Agent forwards, or None when
no such identity is available.
The identity is built against the budget, so it fits by construction and nothing is minted then
measured. The remaining re-mint loop is about content alone: the alphabet carries protocol
delimiters and some combinations land on the drop side, which a probe render is what detects.
An exhausted loop yields None rather than an identity of another kind, so the caller never
stores a metric in the event or service-check working set.
Sourcepub fn render(&self, rng: &mut (impl Rng + ?Sized), out: &mut Vec<u8>) -> usize
pub fn render(&self, rng: &mut (impl Rng + ?Sized), out: &mut Vec<u8>) -> usize
Render one datagram line (no trailing \n) for this identity with a fresh per-occurrence
payload. Returns the packed multi-value run length, or zero.
Sourcepub fn mint_non_utf8_within(
kind: Kind,
rng: &mut (impl Rng + ?Sized),
budget: usize,
) -> Option<Context>
pub fn mint_non_utf8_within( kind: Kind, rng: &mut (impl Rng + ?Sized), budget: usize, ) -> Option<Context>
Mint an identity of kind that carries an invalid UTF-8 byte, or None when none can be built
within budget. Corrupt identities live in the pool like any other, so they recur across
datagrams and count against the kind’s cap instead of appearing as fresh one-offs.
Sourcepub fn has_non_utf8(&self) -> bool
pub fn has_non_utf8(&self) -> bool
Whether this identity carries an invalid UTF-8 byte.
Sourcepub fn floor(&self) -> usize
pub fn floor(&self) -> usize
Bytes every render of this identity must spend, whatever the per-occurrence payload.
Sourcepub fn render_wellformed_within(
&self,
rng: &mut (impl Rng + ?Sized),
out: &mut Vec<u8>,
budget: usize,
) -> Option<usize>
pub fn render_wellformed_within( &self, rng: &mut (impl Rng + ?Sized), out: &mut Vec<u8>, budget: usize, ) -> Option<usize>
Render one datagram line the Agent forwards within budget, or None when this context has no
forwardable rendering that fits. The budget is a construction input to each attempt rather than
a filter on the result, and an exhausted attempt count yields nothing rather than a line
carrying an identity the pool never issued.
Trait Implementations§
impl Eq for Context
impl StructuralPartialEq for Context
Auto Trait Implementations§
impl Freeze for Context
impl RefUnwindSafe for Context
impl Send for Context
impl Sync for Context
impl Unpin for Context
impl UnwindSafe for Context
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§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.