Skip to main content

SetMetricDetail

Struct SetMetricDetail 

Source
pub struct SetMetricDetail {
    pub client_id: String,
    pub detail: Option<i32>,
    pub ttl_seconds: Option<u32>,
    pub clear: Option<bool>,
    pub reason: Option<String>,
    pub peer_pid: Option<i32>,
    pub peer_session_ulid: Option<String>,
}
Expand description

Apply, renew, or release a runtime cardinality lease on the metrics drain.

Leasing model: sozu top (and any future TUI client) leases a higher MetricDetail for the duration of an interactive session. The worker’s effective detail is max(configured, max(active leases)), where configured is MetricsConfig.detail from the static configuration. Multiple clients can lease independently; the worker keeps a client_id- keyed table and uses the maximum across active entries.

Lifecycle:

  1. Apply: send SetMetricDetail{ client_id, detail, ttl_seconds, reason }. The worker stores (client_id) -> (detail, expires_at = now + ttl). If a lease for client_id already exists, it is REPLACED (acts as a renewal). The renewer client is expected to re-send every ttl/2.
  2. Expire: leases self-expire server-side at expires_at. The worker’s janitor (5s polled tick at the top of notify) prunes expired leases and recomputes effective. Crash safety: a dead client is forgotten.
  3. Clear: send SetMetricDetail{ client_id, clear: true } for explicit revocation. client_id must match the leased entry; mismatched IDs are silently ignored (other clients’ leases are not affected).

§Audit

Every operator-initiated effective-level transition emits an EventKind::METRIC_DETAIL_CHANGED event on SubscribeEvents with the previous and new effective levels and the requesting client_id plus optional reason text. Renewal-no-op (same effective level) is NOT emitted.

Emitter scope: operator-initiated transitions emit METRIC_DETAIL_CHANGED via the master-side audit log. Worker-local transitions — the polled janitor expiring a lease, or a worker-local clear/apply after a master fan-out — are not yet surfaced; follow-up tracked separately.

§Backwards compatibility

Workers that pre-date this verb cannot decode SetMetricDetail and return WorkerResponse::error("unknown request type") which folds into the standard fan-out error tally (extras.fanout.workers_err); operators see “succeeded with errors” rather than a dedicated capability-skip list. Production deployments keep master + workers in sync via the UpgradeMain hot-upgrade flow, so this mixed-version state is transient. The master itself also leases (mirroring the symmetric setup_metrics path) so the audit log has a single canonical row when an operator flips detail across the fleet.

Fields§

§client_id: String

Stable identifier for the leasing client (sozu top uses top:<pid>:<random>). Required so multiple TUIs / scrapers / other tooling can lease independently.

§detail: Option<i32>

Target detail for the lease. Required when clear is false/absent.

§ttl_seconds: Option<u32>

Time-to-live for the lease in seconds. The worker rejects (FAILURE) values larger than 300s to bound the worst-case effect of a stuck renewer. Defaults server-side to 60s when absent (the master treats 0 as “use default” and emits a warning).

§clear: Option<bool>

When true, releases the lease for client_id instead of applying. detail and ttl_seconds are ignored when clear is true.

§reason: Option<String>

Optional human-readable provenance for the audit log (e.g. "sozu top --detail backend", "prometheus-scraper:sozu-1").

§peer_pid: Option<i32>

Master-populated peer binding. These fields are NOT set by clients — the master fills them in bin/src/command/requests.rs::worker_request from the connecting ClientSession (actor_pid + session_ulid) before forwarding to workers. The worker stores the binding alongside the lease and rejects subsequent clear requests whose binding does not match the apply-time binding. Prevents one same-UID operator from accidentally (or deliberately) clearing another operator’s lease by guessing the client_id format. A None value means “binding not available” — the worker accepts any matching client_id clear, preserving compat with pre-binding callers and with platforms whose unix socket peer credentials are unavailable.

§peer_session_ulid: Option<String>

Implementations§

Source§

impl SetMetricDetail

Source

pub fn detail(&self) -> MetricDetail

Returns the enum value of detail, or the default if the field is unset or set to an invalid enum value.

Source

pub fn set_detail(&mut self, value: MetricDetail)

Sets detail to the provided enum value.

Source

pub fn ttl_seconds(&self) -> u32

Returns the value of ttl_seconds, or the default value if ttl_seconds is unset.

Source

pub fn clear(&self) -> bool

Returns the value of clear, or the default value if clear is unset.

Source

pub fn reason(&self) -> &str

Returns the value of reason, or the default value if reason is unset.

Source

pub fn peer_pid(&self) -> i32

Returns the value of peer_pid, or the default value if peer_pid is unset.

Source

pub fn peer_session_ulid(&self) -> &str

Returns the value of peer_session_ulid, or the default value if peer_session_ulid is unset.

Trait Implementations§

Source§

impl Clone for SetMetricDetail

Source§

fn clone(&self) -> SetMetricDetail

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for SetMetricDetail

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for SetMetricDetail

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for SetMetricDetail

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Hash for SetMetricDetail

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl Message for SetMetricDetail

Source§

fn encoded_len(&self) -> usize

Returns the encoded length of the message without a length delimiter.
Source§

fn clear(&mut self)

Clears the message, resetting all fields to their default.
Source§

fn encode(&self, buf: &mut impl BufMut) -> Result<(), EncodeError>
where Self: Sized,

Encodes the message to a buffer. Read more
Source§

fn encode_to_vec(&self) -> Vec<u8>
where Self: Sized,

Encodes the message to a newly allocated buffer.
Source§

fn encode_length_delimited( &self, buf: &mut impl BufMut, ) -> Result<(), EncodeError>
where Self: Sized,

Encodes the message with a length-delimiter to a buffer. Read more
Source§

fn encode_length_delimited_to_vec(&self) -> Vec<u8>
where Self: Sized,

Encodes the message with a length-delimiter to a newly allocated buffer.
Source§

fn decode(buf: impl Buf) -> Result<Self, DecodeError>
where Self: Default,

Decodes an instance of the message from a buffer. Read more
Source§

fn decode_length_delimited(buf: impl Buf) -> Result<Self, DecodeError>
where Self: Default,

Decodes a length-delimited instance of the message from the buffer.
Source§

fn merge(&mut self, buf: impl Buf) -> Result<(), DecodeError>
where Self: Sized,

Decodes an instance of the message from a buffer, and merges it into self. Read more
Source§

fn merge_length_delimited(&mut self, buf: impl Buf) -> Result<(), DecodeError>
where Self: Sized,

Decodes a length-delimited instance of the message from buffer, and merges it into self.
Source§

impl Ord for SetMetricDetail

Source§

fn cmp(&self, other: &SetMetricDetail) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 (const: unstable) · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 (const: unstable) · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl PartialEq for SetMetricDetail

Source§

fn eq(&self, other: &SetMetricDetail) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialOrd for SetMetricDetail

Source§

fn partial_cmp(&self, other: &SetMetricDetail) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 (const: unstable) · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 (const: unstable) · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 (const: unstable) · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 (const: unstable) · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl Serialize for SetMetricDetail

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl Eq for SetMetricDetail

Source§

impl StructuralPartialEq for SetMetricDetail

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

Source§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

Source§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

Source§

fn implicit( self, class: Class, constructed: bool, tag: u32, ) -> TaggedParser<'a, Implicit, Self, E>

Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Comparable<K> for Q
where Q: Ord + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn compare(&self, key: &K) -> Ordering

Compare self to key and return their ordering.
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Reset for T
where T: Default + Clone,

Source§

fn reset(&mut self)

Source§

impl<T> Reset for T
where T: Default + Clone,

Source§

fn reset(&mut self)

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,