Class: RailsAiContext::Introspectors::ObservabilityIntrospector

Inherits:
Object
  • Object
show all
Defined in:
lib/rails_ai_context/introspectors/observability_introspector.rb

Overview

Captures the Rails observability surface: ActiveSupport::Notifications subscribers, LogSubscriber registrations, Server-Timing middleware, the Rails 8.1 structured event reporter, and the well-known Rails event-name catalog. Covers RAILS_NERVOUS_SYSTEM.md §34 (Observability) and §38 (AS::Notifications event catalog).

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ ObservabilityIntrospector

Returns a new instance of ObservabilityIntrospector.



13
14
15
# File 'lib/rails_ai_context/introspectors/observability_introspector.rb', line 13

def initialize(app)
  @app = app
end

Instance Attribute Details

#appObject (readonly)

Returns the value of attribute app.



11
12
13
# File 'lib/rails_ai_context/introspectors/observability_introspector.rb', line 11

def app
  @app
end

Instance Method Details

#callObject



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/rails_ai_context/introspectors/observability_introspector.rb', line 17

def call
  {
    log_subscribers: extract_log_subscribers,
    notification_subscribers: extract_notification_subscribers,
    server_timing: detect_server_timing,
    event_reporter: detect_event_reporter,
    log_level: app.config.log_level.to_s,
    log_tags: Array(app.config.log_tags).map(&:to_s),
    colorize_logging: !!app.config.colorize_logging,
    known_events: KNOWN_EVENTS
  }
rescue => e
  $stderr.puts "[rails-ai-context] ObservabilityIntrospector#call failed: #{e.message}" if ENV["DEBUG"]
  { error: e.message }
end