deployangel 0.1.6 → 0.1.7

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: 95e80de544815ec904e01198f948c81c722ddadb005f6e87761827ac1cb3a362
4
- data.tar.gz: 6175861126a88ed4bc09bdaf600c03e1ce5cd88fa3361c53d7c761ff7a066b38
3
+ metadata.gz: 5250331c4f5a2c2715d94bbbfc62f61daae1f58a744e1430a231a23077a7c540
4
+ data.tar.gz: 8db08acb92e1b8923038e2f726481197eb082e308d1f59a6e18911a04d6c3301
5
5
  SHA512:
6
- metadata.gz: 9d20de4305540d12d4b24223c7f4eda020b0855b8205cbeac03c51bf8befc701cb783a1e4600c3781b7d15b906a739aa63988bacc4864bc15a286e32c0138405
7
- data.tar.gz: 38682cdc5941ad48af3ed324356d5bf71309bc5fe2c41fd0c582198ce0315c1863575f5896b13516b634cf6d56e69aee1124a3491c2fa4aae28c49f4b6a77a59
6
+ metadata.gz: '0548b47a265acf82aa9cb67e566142ec4e4e648af0e828217066f8104bc24bf305fd397a1bdb2741de7bf919e10e0d8e4d76fcdd2d9e865e0aaf46ebca226acd'
7
+ data.tar.gz: e622c67f73c8475ff52dd8628e296de2950dce36b7a83e447d23e3a523fdf950a13801ee654972e2c60d176f8c6ddfd7230bec31159cc604b77782bb4a4757a6
data/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.1.7 (2026-10-04)
4
+
5
+ - Health checks from OkComputer, health_check, and rails-healthcheck are left
6
+ out like Rails' own, wherever they're mounted.
7
+ - `config.ignored_routes` leaves out other routes, such as a health check
8
+ served by your own controller: `[ "GET /healthz" ]`. HEAD requests to a
9
+ listed GET route are left out too, and listed routes aren't sent in the
10
+ route table, so DeployAngel never expects them to run.
11
+
3
12
  ## 0.1.6 (2026-10-04)
4
13
 
5
14
  - Requests to Rails' health check (`rails/health#show`, at `/up` by default)
data/README.md CHANGED
@@ -111,6 +111,19 @@ DeployAngel.configure do |config|
111
111
  end
112
112
  ```
113
113
 
114
+ Health checks aren't recorded: load balancers and uptime monitors call them
115
+ all the time and they always answer fast, so they would make your app look
116
+ busier and healthier than its real pages. The agent recognizes Rails' own
117
+ (`/up`), OkComputer, health_check, and rails-healthcheck, wherever they're
118
+ mounted. If your health check is your own controller, list its route the way
119
+ the dashboard shows it. HEAD requests to it are left out too:
120
+
121
+ ```ruby
122
+ DeployAngel.configure do |config|
123
+ config.ignored_routes = [ "GET /healthz" ]
124
+ end
125
+ ```
126
+
114
127
  `DEPLOYANGEL_ENABLED=true|false` forces reporting on or off in any environment.
115
128
  `DEPLOYANGEL_URL` overrides the API endpoint (default `https://api.deployangel.com`).
116
129
 
@@ -11,7 +11,7 @@ module DeployAngel
11
11
 
12
12
  attr_accessor :token, :endpoint, :enabled, :environments, :release_version, :revision,
13
13
  :flush_interval, :open_timeout, :read_timeout, :max_queued_payloads, :max_routes, :logger,
14
- :file_digests, :critical_flows
14
+ :file_digests, :critical_flows, :ignored_routes
15
15
 
16
16
  def initialize(env = ENV)
17
17
  @token = env["DEPLOYANGEL_TOKEN"]
@@ -28,6 +28,8 @@ module DeployAngel
28
28
  @logger = Logger.new($stderr, level: Logger::WARN, progname: "deployangel")
29
29
  @file_digests = parse_boolean(env["DEPLOYANGEL_FILE_DIGESTS"]) != false
30
30
  @critical_flows = {}
31
+ # Route keys as the dashboard shows them, such as "GET /healthz".
32
+ @ignored_routes = []
31
33
  end
32
34
 
33
35
  # Reports only with a token. By default only in the listed
@@ -39,6 +41,14 @@ module DeployAngel
39
41
  environments.include?(environment.to_s)
40
42
  end
41
43
 
44
+ # Whether requests to a route are left out. Rails answers HEAD with the
45
+ # GET route, so ignoring "GET /healthz" ignores "HEAD /healthz" too.
46
+ def ignored_route?(key)
47
+ return false if ignored_routes.empty?
48
+
49
+ ignored_routes.include?(key) || ignored_routes.include?(key.sub(/\AHEAD /, "GET "))
50
+ end
51
+
42
52
  private
43
53
  def parse_boolean(value)
44
54
  return nil if value.nil? || value.strip.empty?
@@ -7,10 +7,12 @@ module DeployAngel
7
7
  # never the raw path, which keeps IDs out of route keys.
8
8
  class Http
9
9
  FORMAT_SUFFIX = "(.:format)"
10
- # Rails' health check (/up by default). Load balancers and uptime
11
- # monitors call it all the time and it always answers fast, so
12
- # counting it would make any app look busy and healthy.
13
- HEALTH_CHECK_CONTROLLER = "rails/health"
10
+ # Health checks: Rails' own (/up by default), OkComputer, health_check,
11
+ # and rails-healthcheck, wherever they're mounted. Load balancers and
12
+ # uptime monitors call them all the time and they answer fast, so
13
+ # counting them would make any app look busy and healthy. Others can
14
+ # be left out with config.ignored_routes.
15
+ HEALTH_CHECK_CONTROLLERS = %w[rails/health ok_computer/ok_computer health_check/health_check healthcheck/healthchecks].freeze
14
16
 
15
17
  def initialize(app)
16
18
  @app = app
@@ -35,9 +37,10 @@ module DeployAngel
35
37
 
36
38
  private
37
39
  def record(env, status, started, unhandled:, exception: nil)
38
- return if env["action_dispatch.request.path_parameters"]&.dig(:controller) == HEALTH_CHECK_CONTROLLER
40
+ return if HEALTH_CHECK_CONTROLLERS.include?(env["action_dispatch.request.path_parameters"]&.dig(:controller))
39
41
 
40
42
  route = route_key(env)
43
+ return if route && DeployAngel.configuration.ignored_route?(route)
41
44
  # Unrouted successes are static files and similar; unrouted
42
45
  # errors (such as routing 404s) still count.
43
46
  return if route.nil? && status.to_i < 400
@@ -40,12 +40,13 @@ module DeployAngel
40
40
  @app.routes.routes.flat_map do |route|
41
41
  controller = route.defaults[:controller]
42
42
  next [] if controller.nil? || controller.start_with?("rails/", "active_storage/", "action_mailbox/")
43
+ next [] if Http::HEALTH_CHECK_CONTROLLERS.include?(controller)
43
44
 
44
45
  path = route.path.spec.to_s.delete_suffix(FORMAT_SUFFIX)
45
46
  route.verb.to_s.split("|").reject(&:empty?).map do |verb|
46
47
  { "key" => "#{verb} #{path}", "controller" => controller, "action" => route.defaults[:action].to_s }
47
48
  end
48
- end.uniq { |route| route["key"] }
49
+ end.uniq { |route| route["key"] }.reject { |route| @config.ignored_route?(route["key"]) }
49
50
  rescue StandardError
50
51
  []
51
52
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module DeployAngel
4
- VERSION = "0.1.6"
4
+ VERSION = "0.1.7"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: deployangel
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 0.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jordan Owens