dead_bro 0.2.36 → 0.2.37

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: 7f33da7799522248140cc65b3637ae2a1dede4295b3696370bd3aabea0d09c7b
4
- data.tar.gz: 376071ecd3eafe0e41695246074ccea3b3a2c479532d08eb24d46fa0d471c94e
3
+ metadata.gz: 85f75545759422dfd14db796ac17035d9d6722e8e68e9c31e9ef0382358e93f8
4
+ data.tar.gz: beed782f1043421e364b1548db3dcd29dd1389d54d46440c2ff65aaf81a4b6af
5
5
  SHA512:
6
- metadata.gz: ba9539bb294999bcd1d3b1f4bed9bc7612d4b9f3e66fe92769de92a0b50d8991ffadf2daf6e418b3951fcda7b8e1ae9afa5b6980c4de7af49d982ccd07aff6f2
7
- data.tar.gz: 1e9abbd0ef17016ea6f639fa60d6d18edc0b481cdeec3d6495f52f5ae31e73a413db0bb7e7607b274a344d8ab1b33dda098dca608c617a024622aff3796fc8e0
6
+ metadata.gz: 1dd65b6b589c013f24d18a548491aa6203c990cf0522c23c0e9000939898aed0e6927a26793c1a8eb80e4fe96e7a9c72176436f2cf8d3ae84848562b2fb82c2d
7
+ data.tar.gz: c0c020935c96898d9c54bd1b9f39ee77bf7040b8ad0cf2a9d51487af14199dca91b46e6b89b66e99c73cce470452136cb71d49ae2535f725b05edcd8b1511bdc
data/CHANGELOG.md CHANGED
@@ -1,5 +1,16 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.2.37] - 2026-10-26
4
+
5
+ ### Fixed
6
+ - **`sql_count` stopped at 100 on any page that ran more queries.** It was never a query count: the subscriber read `ActiveRecord::Base.connection.query_cache.size`, the number of distinct SELECTs in the query cache — an LRU capped at 100 entries since Rails 7.1. An N+1 page that ran 188 queries reported "SQL Count 100" and "100 calls/request". `sql_count` is now the sum of the per-statement aggregate counts the SQL subscriber already keeps (every query, not only the first `MAX_TRACKED_QUERIES`), with query-cache hits included the way Rails counts them in its `(N queries, M cached)` log line. The old lookup also leased a database connection on requests that ran no SQL; nothing in the subscriber touches `ActiveRecord::Base.connection` any more.
7
+ - Background jobs sent no `sql_count` at all, so the dashboard showed 0 database calls for every job; job payloads now carry the same count.
8
+
9
+ ### Added
10
+ - `sql_cached_count` on request and job payloads: how many of `sql_count` were answered by the query cache.
11
+
12
+ ## [0.2.36] - 2026-10-25
13
+
3
14
  ### Added
4
15
  - **`gc_pressure` now says whether the window's GC had finished.** `gc_state_at_end` is the GC's phase when a request or job window closes — `"none"`, `"marking"` or `"sweeping"`, from `GC.latest_gc_info(:state)` — sent with the other memory-tracking fields. Ruby marks and sweeps in steps between allocations, so a GC counted in the window is often still running when it closes, and until it finishes `heap_live_slots_growth` still counts garbage it hasn't freed. The dashboard uses it so a sample measured mid-GC isn't flagged as a possible leak. It's a single-key read; no hash is built.
5
16
 
@@ -141,6 +141,8 @@ module DeadBro
141
141
  gc_pressure: gc_pressure,
142
142
  ar_instantiation_count: ar_instantiation_count,
143
143
  status: has_error ? "failed" : "completed",
144
+ sql_count: DeadBro::Subscriber.sql_count(sql_queries),
145
+ sql_cached_count: DeadBro::Subscriber.sql_cached_count(sql_queries),
144
146
  sql_queries: sql_queries,
145
147
  transaction_events: transaction_events,
146
148
  rails_env: DeadBro.env,
@@ -166,7 +166,8 @@ module DeadBro
166
166
  db_runtime_ms: data[:db_runtime],
167
167
  memory_usage: memory_usage_mb,
168
168
  gc_stats: end_gc_stats,
169
- sql_count: sql_count(data),
169
+ sql_count: sql_count(sql_queries),
170
+ sql_cached_count: sql_cached_count(sql_queries),
170
171
  sql_queries: sql_queries,
171
172
  transaction_events: transaction_events,
172
173
  http_outgoing: Thread.current[:dead_bro_http_events] || [],
@@ -472,20 +473,24 @@ module DeadBro
472
473
  {}
473
474
  end
474
475
 
475
- def self.sql_count(data)
476
- # Count SQL queries from the payload if available
477
- if data[:sql_count]
478
- data[:sql_count]
479
- elsif defined?(ActiveRecord) && ActiveRecord::Base.connection
480
- # Try to get from ActiveRecord connection
481
- begin
482
- ActiveRecord::Base.connection.query_cache.size
483
- rescue
484
- 0
485
- end
486
- else
487
- 0
488
- end
476
+ # Number of SQL statements run during the request, query-cache hits included
477
+ # (the same count as Rails' "ActiveRecord: …ms (N queries, M cached)" log
478
+ # line). Summed from SqlSubscriber.stop_request_tracking's per-statement
479
+ # aggregates, which count every query — the raw query list stops at
480
+ # MAX_TRACKED_QUERIES. This used to read
481
+ # ActiveRecord::Base.connection.query_cache.size: the number of distinct
482
+ # cached SELECTs, an LRU capped at 100 since Rails 7.1, so every N+1 page
483
+ # reported "100" — and it leased a DB connection on requests with no SQL.
484
+ def self.sql_count(sql_queries)
485
+ Array(sql_queries).sum { |agg| agg[:count].to_i }
486
+ rescue
487
+ 0
488
+ end
489
+
490
+ # How many of sql_count were answered by the query cache, sent separately so
491
+ # the dashboard can tell repeated cache hits from database round trips.
492
+ def self.sql_cached_count(sql_queries)
493
+ Array(sql_queries).sum { |agg| agg[:cached_count].to_i }
489
494
  rescue
490
495
  0
491
496
  end
@@ -1,6 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module DeadBro
4
- VERSION = "0.2.36"
4
+ VERSION = "0.2.37"
5
5
  end
6
-
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dead_bro
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.36
4
+ version: 0.2.37
5
5
  platform: ruby
6
6
  authors:
7
7
  - Emanuel Comsa