class CQL::Performance::Monitor

Overview

Monitor with dependency injection

Included Modules

Defined in:

performance/monitor.cr

Constant Summary

Log = ::Log.for(self)

Constructors

Instance Method Summary

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

def self.new(config : Config = Config.from_env, profiler : QueryProfilerInterface | Nil = nil, detector : NPlusOneDetectorInterface | Nil = nil, sql_formatter : SQLFormatter | Nil = nil, report_generator : UnifiedReportGenerator | Nil = nil) #

[View source]

Instance Method Detail

def clear #

Clear all data


[View source]
def close : Nil #

Stops the async queue, skipping the statements it still holds; #record is synchronous afterwards.


[View source]
def configure(&) #

Configuration


[View source]
def counters : MonitorCounters #

What the monitor itself observed since it was built or last cleared; overhead is estimated from one statement in 64 and pool_wait counts a wait under 1 µs (a free connection) as zero.


[View source]
def critical_issues : Array(Issue) #

Get critical issues


[View source]
def detector : NPlusOneDetectorInterface | Nil #

[View source]
def enabled? : Bool #

Check if monitoring is enabled


[View source]
def end_relation_loading #

[View source]
def error_count : Int32 #

[View source]
def flush(timeout : Time::Span | Nil = nil) : Bool #

True once every statement recorded before it was handled, at once when recording is synchronous; false on timeout.


[View source]
def generate_report(format : String | Nil = nil) : String #

Report generation


[View source]
def healthy? : Bool #

Same answer as metrics.healthy?, without building the rest of the metrics


[View source]
def high_priority_issues : Array(Issue) #

Get high priority issues


[View source]
def metrics : PerformanceMetrics #

Get comprehensive performance metrics


[View source]
def metrics_summary : Hash(String, String | Int64 | Float64) #

Get metrics summary


[View source]
def monitor_query(sql : String, params : Array(DB::Any) = [] of DB::Any, &) #

Main monitoring methods


[View source]
def profiler : QueryProfilerInterface | Nil #

Component access


[View source]
def record(event : CQL::Telemetry::QueryEvent, params : Array(DB::Any)) : Nil #

Records a statement CQL::Execution.run has already timed, on the async queue's fiber when monitoring is async.


[View source]
def start_relation_loading(relation_name : String, parent_model : String) #

Relation loading hooks


[View source]
def track(sql : String, params : Array(DB::Any) = [] of DB::Any, &) #

API - just wrap the query


[View source]
def with_context(context : String, &) #

Context management


[View source]