class Azu::PerformanceMetrics

Overview

Performance metrics collection and analysis system Tracks request processing times, memory usage, component lifecycle, and error rates

Defined in:

azu/performance_metrics.cr

Constructors

Class Method Summary

Instance Method Summary

Constructor Detail

def self.new(enabled : Bool = true) #

[View source]

Class Method Detail

def self.current_memory_usage : Int64 #

Get current memory usage


[View source]
def self.time_cache_operation(metrics : PerformanceMetrics, key : String, operation : String, store_type : String, key_size : Int32 = 0, value_size : Int32 | Nil = nil, ttl : Time::Span | Nil = nil, &) #

Helper method to time and record cache operations


[View source]

Instance Method Detail

def aggregate_stats(since : Time | Nil = nil) : AggregatedStats #

Get aggregated statistics


[View source]
def cache_operation_breakdown(since : Time | Nil = nil) : Hash(String, Hash(String, Float64)) #

Get cache operation breakdown by operation type


[View source]
def cache_stats(store_type : String | Nil = nil, since : Time | Nil = nil) : Hash(String, Float64) #

Get cache statistics


[View source]
def clear #

Clear all metrics


[View source]
def component_stats(component_type : String | Nil = nil, since : Time | Nil = nil) : Hash(String, Float64) #

Get component statistics


[View source]
def enabled : Bool #

[View source]
def enabled=(enabled : Bool) #

Enable/disable metrics collection


[View source]
def endpoint_stats(endpoint : String, since : Time | Nil = nil) : Hash(String, Float64) #

Get endpoint-specific statistics


[View source]
def recent_caches(limit : Int32 = 100) : Array(CacheMetric) #

Get recent cache metrics


[View source]
def recent_components(limit : Int32 = 100) : Array(ComponentMetric) #

Get recent component metrics


[View source]
def recent_requests(limit : Int32 = 100) : Array(RequestMetric) #

Get recent request metrics


[View source]
def record_cache(key : String, operation : String, store_type : String, processing_time : Float64, hit : Bool | Nil = nil, key_size : Int32 = 0, value_size : Int32 | Nil = nil, ttl : Time::Span | Nil = nil, error : String | Nil = nil) #

Record a cache operation metric


[View source]
def record_component(component_id : String, component_type : String, event : String, processing_time : Float64 | Nil = nil, memory_before : Int64 | Nil = nil, memory_after : Int64 | Nil = nil, age_at_event : Time::Span | Nil = nil) #

Record a component lifecycle metric


[View source]
def record_request(endpoint : String, method : String, path : String, processing_time : Float64, memory_before : Int64, memory_after : Int64, status_code : Int32, request_id : String | Nil = nil) #

Record a request metric


[View source]
def start_time : Time #

[View source]
def to_json(io : IO) : Nil #

Export metrics to JSON


[View source]