Class: SolidObserver::Queries::TraceQuery

Inherits:
Object
  • Object
show all
Defined in:
lib/solid_observer/queries/trace_query.rb

Defined Under Namespace

Classes: Result

Constant Summary collapse

DEFAULT_LIMIT =
100
CABLE_CAP =
50
COMPONENT_PRIORITY =
{queue: 0, cache: 1, cable: 2}.freeze
COMPONENT_CONFIG =
{
  queue: {
    enabled: :solid_queue_enabled?,
    model: :QueueEvent,
    columns: [:recorded_at, :event_type, :job_class, :queue_name, :duration, :id]
  },
  cache: {
    enabled: :solid_cache_enabled?,
    model: :CacheEvent,
    columns: [:recorded_at, :event_type, :hit, :error_class, :duration, :id]
  },
  cable: {
    enabled: :solid_cable_enabled?,
    model: :CableEvent,
    columns: [:recorded_at, :event_type, :channel_class, :broadcasting_digest, :error_class, :duration, :id]
  }
}.freeze
CONNECTION_ERRORS =
[
  ActiveRecord::ConnectionNotEstablished,
  ActiveRecord::StatementInvalid,
  *([PG::ConnectionBad] if defined?(PG::ConnectionBad)),
  *([Mysql2::Error::ConnectionError] if defined?(Mysql2::Error::ConnectionError)),
  *([Trilogy::Error] if defined?(Trilogy::Error)),
  *([SQLite3::CantOpenException] if defined?(SQLite3::CantOpenException))
].freeze

Instance Method Summary collapse

Instance Method Details

#call(correlation_id:, limit: DEFAULT_LIMIT) ⇒ Object



40
41
42
43
44
45
# File 'lib/solid_observer/queries/trace_query.rb', line 40

def call(correlation_id:, limit: DEFAULT_LIMIT)
  rows, unavailable = gather_rows(correlation_id)
  effective_limit = limit.to_i
  effective_limit = DEFAULT_LIMIT unless effective_limit.positive?
  Result.new(rows: process_rows(rows, effective_limit), unavailable_components: unavailable)
end