class
CQL::Performance::PerformanceMetrics
- CQL::Performance::PerformanceMetrics
- Reference
- Object
Overview
Comprehensive performance metrics collection Provides unified access to all performance data across modules
Included Modules
Defined in:
performance/performance_metrics.crConstant Summary
-
HEALTHY_SCORE =
80
Constructors
-
.from_components(profiler : QueryProfilerInterface | Nil = nil, detector : NPlusOneDetectorInterface | Nil = nil, cache : CQL::Cache::CacheInterface | Nil = nil, start_time : Time | Nil = nil, config : Config | Nil = nil, error_count : Int32 = 0, monitor : MonitorCounters = MonitorCounters.zero) : self
Create metrics from performance components
- .new(query_metrics : QueryMetrics, n_plus_one_metrics : NPlusOneMetrics, cache_metrics : CacheMetrics, system_metrics : SystemMetrics, health_metrics : HealthMetrics, top_queries : TopQueries, patterns : PerformancePatterns, issues : Array(Issue), collection_duration : Time::Span = Time::Span.zero, monitor : MonitorCounters = MonitorCounters.zero)
Class Method Summary
-
.calculate_performance_score(query_metrics : QueryMetrics) : Float64
Calculate performance score from query metrics (static method for external use)
-
.healthy?(profiler : QueryProfilerInterface | Nil = nil, detector : NPlusOneDetectorInterface | Nil = nil, cache : CQL::Cache::CacheInterface | Nil = nil) : Bool
Whether metrics built from these components would be
#healthy?, reading only what the health score needs: the profiler's statistics and slow queries and the detector's patterns. -
.to_json_any(value) : JSON::Any
Helper method to convert values to JSON::Any recursively
Instance Method Summary
- #cache_metrics : CacheMetrics
-
#calculate_performance_score : Float64
Calculate overall performance score (0-100) Higher scores indicate better performance
- #collection_duration : Time::Span
-
#critical_issues : Array(Issue)
Get critical issues only
- #health_metrics : HealthMetrics
-
#healthy? : Bool
Check if performance is healthy
-
#high_priority_issues : Array(Issue)
Get high priority issues
- #issues : Array(Issue)
-
#issues_by_severity(severity : Symbol) : Array(Issue)
Get issues by severity
-
#issues_by_type(type : Symbol) : Array(Issue)
Get issues by type
- #monitor : MonitorCounters
-
#most_frequent_queries(limit : Int32 = 10) : Array(NamedTuple(sql: String, count: Int64, avg_time: Time::Span))
Get most frequent queries
- #n_plus_one_metrics : NPlusOneMetrics
-
#n_plus_one_patterns_by_severity(severity : Symbol) : Array(NPlusOnePattern)
Get N+1 patterns by severity
- #patterns : PerformancePatterns
-
#query_metrics : QueryMetrics
Main metrics collection
-
#slowest_queries(limit : Int32 = 10) : Array(QueryData)
Get slowest queries with details
-
#summary : Hash(String, String | Int64 | Float64)
Get summary metrics for quick overview
- #system_metrics : SystemMetrics
- #timestamp : Time
-
#to_h : Hash(String, JSON::Any)
Export all metrics as a comprehensive hash
-
#to_json : String
Export as JSON
- #top_queries : TopQueries
Instance methods inherited from module CQL::Performance::TimingUtils
categorize_duration(duration : Time::Span, slow_threshold : Time::Span = 100.milliseconds, very_slow_threshold : Time::Span = 1.second) : Symbol
categorize_duration,
format_duration(duration : Time::Span) : String
format_duration,
measure_execution(&)
measure_execution
Constructor Detail
Create metrics from performance components
Class Method Detail
Calculate performance score from query metrics (static method for external use)
Whether metrics built from these components would be #healthy?, reading only what the health score needs: the
profiler's statistics and slow queries and the detector's patterns.
Instance Method Detail
Calculate overall performance score (0-100) Higher scores indicate better performance
Get most frequent queries
Get N+1 patterns by severity
Get slowest queries with details