pub struct ZLayerMetrics {Show 17 fields
pub services_total: Gauge,
pub service_replicas: GaugeVec,
pub service_health: GaugeVec,
pub scale_events_total: CounterVec,
pub scale_up_total: Counter,
pub scale_down_total: Counter,
pub requests_total: CounterVec,
pub request_duration_seconds: HistogramVec,
pub raft_is_leader: Gauge,
pub raft_term: Gauge,
pub raft_commit_index: Gauge,
pub uptime_seconds: Gauge,
pub gpu_utilization: GaugeVec,
pub gpu_memory_used: GaugeVec,
pub gpu_memory_total: GaugeVec,
pub gpu_temperature: GaugeVec,
pub gpu_power: GaugeVec,
/* private fields */
}Expand description
ZLayer metrics collection
Pre-defined metrics for the ZLayer system.
Fields§
§services_total: GaugeTotal number of registered services
service_replicas: GaugeVecCurrent replica count per service
service_health: GaugeVecService health status (0=unknown, 1=healthy, 2=degraded, 3=unhealthy)
scale_events_total: CounterVecTotal scaling events by service and direction
scale_up_total: CounterTotal scale up events
scale_down_total: CounterTotal scale down events
requests_total: CounterVecTotal HTTP requests by method, path, and status
request_duration_seconds: HistogramVecHTTP request duration in seconds
raft_is_leader: GaugeWhether this node is the Raft leader (1) or not (0)
raft_term: GaugeCurrent Raft term
raft_commit_index: GaugeCurrent Raft commit index
uptime_seconds: GaugeTime since the service started in seconds
gpu_utilization: GaugeVecGPU utilization percentage per GPU index and node
gpu_memory_used: GaugeVecGPU memory used in bytes per GPU index and node
gpu_memory_total: GaugeVecGPU total memory in bytes per GPU index and node
gpu_temperature: GaugeVecGPU temperature in celsius per GPU index and node
gpu_power: GaugeVecGPU power draw in watts per GPU index and node
Implementations§
Source§impl ZLayerMetrics
impl ZLayerMetrics
Sourcepub fn new() -> Result<Self>
pub fn new() -> Result<Self>
Create a new metrics collection
§Errors
Returns an error if Prometheus metric creation or registration fails.
Sourcepub fn record_scale_event(&self, service: &str, direction: &str)
pub fn record_scale_event(&self, service: &str, direction: &str)
Record a scale event
Sourcepub fn set_replicas(&self, service: &str, count: u32)
pub fn set_replicas(&self, service: &str, count: u32)
Update service replica count
Sourcepub fn set_health(&self, service: &str, health: HealthStatus)
pub fn set_health(&self, service: &str, health: HealthStatus)
Update service health status
Sourcepub fn record_request(
&self,
method: &str,
path: &str,
status: u16,
duration_secs: f64,
)
pub fn record_request( &self, method: &str, path: &str, status: u16, duration_secs: f64, )
Record an HTTP request
Sourcepub fn set_raft_leader(&self, is_leader: bool)
pub fn set_raft_leader(&self, is_leader: bool)
Update Raft leader status
Sourcepub fn set_raft_term(&self, term: u64)
pub fn set_raft_term(&self, term: u64)
Update Raft term
Sourcepub fn set_raft_commit_index(&self, index: u64)
pub fn set_raft_commit_index(&self, index: u64)
Update Raft commit index
Sourcepub fn set_uptime(&self, seconds: f64)
pub fn set_uptime(&self, seconds: f64)
Update uptime
Sourcepub fn set_gpu_utilization(&self, gpu_index: u32, node: &str, percent: f64)
pub fn set_gpu_utilization(&self, gpu_index: u32, node: &str, percent: f64)
Update GPU utilization percentage
Sourcepub fn set_gpu_memory_used(&self, gpu_index: u32, node: &str, bytes: u64)
pub fn set_gpu_memory_used(&self, gpu_index: u32, node: &str, bytes: u64)
Update GPU memory used in bytes
Sourcepub fn set_gpu_memory_total(&self, gpu_index: u32, node: &str, bytes: u64)
pub fn set_gpu_memory_total(&self, gpu_index: u32, node: &str, bytes: u64)
Update GPU total memory in bytes
Sourcepub fn set_gpu_temperature(&self, gpu_index: u32, node: &str, celsius: f64)
pub fn set_gpu_temperature(&self, gpu_index: u32, node: &str, celsius: f64)
Update GPU temperature in celsius
Sourcepub fn set_gpu_power(&self, gpu_index: u32, node: &str, watts: f64)
pub fn set_gpu_power(&self, gpu_index: u32, node: &str, watts: f64)
Update GPU power draw in watts
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ZLayerMetrics
impl !RefUnwindSafe for ZLayerMetrics
impl Send for ZLayerMetrics
impl Sync for ZLayerMetrics
impl Unpin for ZLayerMetrics
impl UnsafeUnpin for ZLayerMetrics
impl !UnwindSafe for ZLayerMetrics
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> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request