railwatch 1.0.0 → 1.1.1

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: 336bf2e2440f9d076539faaca52e7d04db59422aeb280250a4c4556e7c6562ea
4
- data.tar.gz: ea7b81637d1e104faa87e9ceb756cd1af43afb801108335674a508658b9adafa
3
+ metadata.gz: c905c857b9616e0eb4a38518afa97d787f0ee12eab644c950671278ec28ef0e3
4
+ data.tar.gz: 98e4c9103ac4231d2a676b55ceca51ff36d9c84c8570c97391c0eb4d07675b27
5
5
  SHA512:
6
- metadata.gz: 2223825b1e9287148a7a4a0707b786b6ac88a4859b1566f4630706b3dffd50b13ef19815e70ffba85aa5669c37925a20895af68e4377098fd51c6250a680431b
7
- data.tar.gz: 71d620559e2d9fd431ae93fd269bd4b573e13bf23295a4bb98cfa395f720ee3fa94bf0557fe562ae2e7e4492428b22ccdaf82c25c0082485ee2550cf82ee7c5c
6
+ metadata.gz: 1b31a6f1ae9843426a8480c3f6c9ee8551c886083d6643069cfbd35e5cc7275416fa047d06270d80ce8410619bf0b7431f5ebb0cf9204a59be50ce1f3a30fc08
7
+ data.tar.gz: ed4a1f14aef82b6586b8fd86cd86071b5741906de30f89e12f28327d9e9aeaac664fcbbfc6a2ae1d674ec2ee2599fbcd141fb86c30b44db58c84900f7d21b841
data/CHANGELOG.md CHANGED
@@ -6,6 +6,30 @@
6
6
  filled in by the release commit, which is also the only commit that
7
7
  touches lib/railwatch/version.rb and Gemfile.lock. See CONTRIBUTING.md. -->
8
8
 
9
+ ## 1.1.1 (2026-10-24)
10
+
11
+ - The browser client names the first page load after its Inertia
12
+ component again on inertia_rails 3.23+, which renders the page object as
13
+ `<script data-page="app" type="application/json">` instead of a
14
+ `data-page` attribute on `<div id="app">`. The client only read the
15
+ attribute, so every initial load (the only visits that carry LCP, CLS,
16
+ INP and TTFB) arrived with no component: per-page web vitals were empty.
17
+ Apps that copied the client (`app/frontend/lib/railwatch.ts`) need the
18
+ same change in their copy.
19
+
20
+ ## 1.1.0 (2026-10-22)
21
+
22
+ - A receiver that refuses the connection (nothing listening: a Railwatch
23
+ server restarting, or a deploy handing over to the next container) no
24
+ longer counts as backpressure. The retry ladder it starts used to double
25
+ the sampling divisor every flush tick, so the app's first requests after
26
+ the server came back were sampled out: a fresh app recorded 23-29 of 30
27
+ requests sent right after its embedded server was killed and restarted,
28
+ in every one of 10 runs. A timeout, a 5xx and a full buffer are still
29
+ pressure.
30
+ - `Configuration#local?` is gone. It was kept in 1.0.0 only for
31
+ railwatch-server 0.1.0; railwatch-server 0.1.1 no longer calls it.
32
+
9
33
  ## 1.0.0 (2026-10-22)
10
34
 
11
35
  - **Breaking: `railwatch` is the agent only.** It instruments the app and
@@ -659,13 +659,19 @@ function startVitals() {
659
659
  )
660
660
  }
661
661
 
662
- // The component the server rendered this page with, off the root element's
663
- // serialized page object. Inertia's own events take over from here.
662
+ // The component the server rendered this page with, off the serialized page
663
+ // object: inertia_rails 3.23+ renders it as <script data-page="app"
664
+ // type="application/json">, older ones as <div id="app" data-page="...">.
665
+ // Inertia's own events take over from here.
664
666
  function pageComponent(): string | undefined {
665
667
  try {
666
- const page = JSON.parse(
667
- document.getElementById("app")?.dataset.page ?? "{}",
668
- ) as { component?: string }
668
+ const script = document.querySelector(
669
+ 'script[data-page="app"][type="application/json"]',
670
+ )
671
+ const raw = script
672
+ ? script.textContent
673
+ : document.getElementById("app")?.dataset.page
674
+ const page = JSON.parse(raw ?? "{}") as { component?: string }
669
675
  return page.component
670
676
  } catch {
671
677
  // Not an Inertia-rendered page, or the payload moved. Report it anyway.
@@ -284,10 +284,6 @@ module Railwatch
284
284
  @enabled && token.present?
285
285
  end
286
286
 
287
- # Always false: there is no embedded transport any more. Only
288
- # railwatch-server 0.1.0 calls it.
289
- def local? = false
290
-
291
287
  # Both halves present. Read late (not at boot) so credentials set from an
292
288
  # initializer, an env var or the configure task all count.
293
289
  def http_basic_auth_configured?
@@ -72,6 +72,7 @@ module Railwatch
72
72
  @flush_requested = false
73
73
  @urgent_at = nil
74
74
  @retry_attempt = 0
75
+ @unreachable = false
75
76
  @retry_at = nil
76
77
  @retry_batch = nil
77
78
  # Ruby ivars hold object references atomically. The reporter is the
@@ -400,6 +401,7 @@ module Railwatch
400
401
  @backpressure_factor = MAX_BACKPRESSURE_FACTOR if @config.backpressure
401
402
  end
402
403
  @retry_attempt += 1
404
+ @unreachable = result.status.nil? && result.error.to_s.start_with?("Errno::ECONNREFUSED")
403
405
  if @retry_attempt > MAX_RETRY_ATTEMPTS
404
406
  @buffer.account_dropped(batch.records.size + batch.dropped,
405
407
  bytes: batch.bytes + batch.dropped_bytes)
@@ -506,6 +508,7 @@ module Railwatch
506
508
  @in_flight_dropped_bytes = 0
507
509
  @retry_attempt = 0
508
510
  @retry_at = nil
511
+ @unreachable = false
509
512
  end
510
513
  end
511
514
 
@@ -600,8 +603,14 @@ module Railwatch
600
603
 
601
604
  buffered, _, buffered_bytes, = @buffer.stats
602
605
  high_water = @config.backpressure_high_water
606
+ # A retry ladder is pressure when the receiver is struggling (a timeout,
607
+ # a 5xx). Not when nothing listens (ECONNREFUSED): that is a server
608
+ # restarting or a deploy handing over, back in a second or two, and
609
+ # sampling down meanwhile only lost the app's first requests after it.
610
+ # The buffer's high-water mark still bounds a receiver that stays away.
611
+ retrying = @retry_attempt.positive? && !@unreachable
603
612
  pressured = buffered >= @config.buffer_size * high_water ||
604
- buffered_bytes >= @config.buffer_bytes * high_water || @retry_attempt.positive?
613
+ buffered_bytes >= @config.buffer_bytes * high_water || retrying
605
614
  @backpressure_factor = if pressured
606
615
  [ @backpressure_factor * 2.0, MAX_BACKPRESSURE_FACTOR ].min
607
616
  else
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Railwatch
4
- VERSION = "1.0.0"
4
+ VERSION = "1.1.1"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: railwatch
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cole Robertson