activerabbit-ai 0.4.4 → 0.4.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 86853d97a830e8d411ba9052ff231b29a2cddb526799e6b5c89e848ce026c7b2
4
- data.tar.gz: 1faeb9a59503089d03b0ecda80fab72cd8028b3bfd49f4da5c5d25ff9cfb3139
3
+ metadata.gz: e2afb9bf892d3e3a7e83a65e224c791855aa7d6e86feb476ee0f66c108f617cd
4
+ data.tar.gz: 20e74e7fa56e865bd707ccd852e62894fa73fc1d5ac2145d7d6a606dff351722
5
5
  SHA512:
6
- metadata.gz: 760d010f75113d98d6e2f83fd3768d37d7cf67e307c24418717caa8c07ea489337ed7923ef876ed7bb95e4556e6780466efaec374d2ffc62d00b7b16a37f6fda
7
- data.tar.gz: 441b28d1cc42c02a13c3efe4d387674932fceafca7c8571c6b24792ac69134338050ad030ebe65253ee48387e108b8b7d85014866bd42fed1e56f1c9fa356647
6
+ metadata.gz: 40e742a6578a155441efe51fd97de272e8bfc7fe2e024cc2abe17e29ac2ee664079c6eb3093ae0aa311dea8f5438c96b60d88ba0a50e2477fdc2cc01b7b32006
7
+ data.tar.gz: 55fe08ec494af877576561418a7d3c9b63fd0b0bd34d3c04c3e59d5cb39d3d032992369ac056dc6e2417e75bad363fb5ac1dce115d3150765be7870b7859c34b
@@ -12,23 +12,23 @@ module ActiveRabbit
12
12
 
13
13
  # Time-based deduplication: track errors with timestamps
14
14
  $reported_errors ||= {}
15
-
15
+
16
16
  # Generate a unique key for this error
17
17
  error_key = "#{exception.class.name}:#{exception.message}:#{exception.backtrace&.first}"
18
-
18
+
19
19
  # Get dedupe window from config (default 5 minutes, 0 = disabled)
20
- dedupe_window = defined?(ActiveRabbit::Client.configuration.dedupe_window) ?
20
+ dedupe_window = defined?(ActiveRabbit::Client.configuration.dedupe_window) ?
21
21
  ActiveRabbit::Client.configuration.dedupe_window : 300
22
-
22
+
23
23
  current_time = Time.now.to_i
24
24
  last_seen = $reported_errors[error_key]
25
-
25
+
26
26
  # Report if: never seen before, OR dedupe disabled (0), OR outside dedupe window
27
27
  should_report = last_seen.nil? || dedupe_window == 0 || (current_time - last_seen) > dedupe_window
28
-
28
+
29
29
  if should_report
30
30
  $reported_errors[error_key] = current_time
31
-
31
+
32
32
  # Clean old entries to prevent memory leak (keep last hour)
33
33
  $reported_errors.delete_if { |_, timestamp| current_time - timestamp > 3600 }
34
34
 
@@ -46,15 +46,18 @@ module ActiveRabbit
46
46
  setup_exception_tracking(app) if ActiveRabbit::Client.configured?
47
47
  end
48
48
 
49
- initializer "active_rabbit.subscribe_to_notifications" do |app|
50
- # Defer subscription until after application initializers (configuration complete)
49
+ initializer "active_rabbit.subscribe_to_notifications", after: :load_config_initializers do |app|
50
+ Rails.logger.info "[ActiveRabbit] Setting up performance notifications subscriptions"
51
+ # Subscribe regardless; each handler guards on configured?
52
+ subscribe_to_controller_events
53
+ subscribe_to_active_record_events
54
+ subscribe_to_action_view_events
55
+ subscribe_to_action_mailer_events if defined?(ActionMailer)
56
+ subscribe_to_exception_notifications
57
+ Rails.logger.info "[ActiveRabbit] Subscriptions setup complete"
58
+
59
+ # Defer complex subscriptions until after initialization
51
60
  app.config.after_initialize do
52
- # Subscribe regardless; each handler guards on configured?
53
- subscribe_to_controller_events
54
- subscribe_to_active_record_events
55
- subscribe_to_action_view_events
56
- subscribe_to_action_mailer_events if defined?(ActionMailer)
57
- subscribe_to_exception_notifications
58
61
 
59
62
  # Fallback: low-level rack.exception subscription (older Rails and deep middleware errors)
60
63
  ActiveSupport::Notifications.subscribe("rack.exception") do |*args|
@@ -387,10 +390,19 @@ module ActiveRabbit
387
390
  end
388
391
 
389
392
  def subscribe_to_controller_events
393
+ Rails.logger.info "[ActiveRabbit] Subscribing to controller events (configured=#{ActiveRabbit::Client.configured?})"
394
+
390
395
  ActiveSupport::Notifications.subscribe "process_action.action_controller" do |name, started, finished, unique_id, payload|
391
396
  begin
397
+ unless ActiveRabbit::Client.configured?
398
+ Rails.logger.debug "[ActiveRabbit] Skipping performance tracking - not configured"
399
+ return
400
+ end
401
+
392
402
  duration_ms = ((finished - started) * 1000).round(2)
393
403
 
404
+ Rails.logger.info "[ActiveRabbit] 📊 Controller action: #{payload[:controller]}##{payload[:action]} - #{duration_ms}ms"
405
+
394
406
  ActiveRabbit::Client.track_performance(
395
407
  "controller.action",
396
408
  duration_ms,
@@ -2,6 +2,6 @@
2
2
 
3
3
  module ActiveRabbit
4
4
  module Client
5
- VERSION = "0.4.4"
5
+ VERSION = "0.4.5"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activerabbit-ai
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.4
4
+ version: 0.4.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alex Shapalov
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2025-10-23 00:00:00.000000000 Z
11
+ date: 2025-10-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: concurrent-ruby