class

Azu::PerformanceMetrics

Inherits Reference < Object

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

Constructors

new(enabled : Bool = true)
Source

Class methods

current_memory_usage

Get current memory usage

Source
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

Source

Instance methods

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

Get aggregated statistics

Source
cache_operation_breakdown(since : Time | Nil = nil) : Hash(String, Hash(String, Float64))

Get cache operation breakdown by operation type

Source
cache_stats(store_type : String | Nil = nil, since : Time | Nil = nil) : Hash(String, Float64)

Get cache statistics

Source
clear

Clear all metrics

Source
component_stats(component_type : String | Nil = nil, since : Time | Nil = nil) : Hash(String, Float64)

Get component statistics

Source
enabled
Source
enabled=(enabled : Bool)

Enable/disable metrics collection

Source
endpoint_stats(endpoint : String, since : Time | Nil = nil) : Hash(String, Float64)

Get endpoint-specific statistics

Source
recent_caches(limit : Int32 = 100) : Array(CacheMetric)

Get recent cache metrics

Source
recent_components(limit : Int32 = 100) : Array(ComponentMetric)

Get recent component metrics

Source
recent_requests(limit : Int32 = 100) : Array(RequestMetric)

Get recent request metrics

Source
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

Source
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

Source
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

Source
start_time
Source
to_json(io : IO) : Nil

Export metrics to JSON

Source

Nested types