iron_trail 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3e922d927b8d15e66a500efdb61b10b6c46bdfef803a4c5b9073f6bd08514a93
4
- data.tar.gz: db70caa06c04c8ec6efaea449613419162a6a84d1a677d86a92e8fa7b8570c26
3
+ metadata.gz: e0eaa9c2070ae46d7386af196b943c47c495fba0485bc1b1956691e182ad099e
4
+ data.tar.gz: 732e39b8d5edba42b54a0f6bc67f6389d89fe1d037930c10dc4dff72a1afeb18
5
5
  SHA512:
6
- metadata.gz: 8f8d1e73e606dabb8fca56e17ef4e5eaacbb935e28153ece111469b2c25b1bb193c94a2d5745eb0d27734ebe0a641e53df5c238d03a74526fa6df5ecc8dbafea
7
- data.tar.gz: 065f9432f14e29f63e6c26ae5fbbf2800ed285c5af9bca9376871acc5a65d14efdc4951bcfd2bcdfb83c8b5498b4adb47d810ac9eb83cbab1deb3328f61038ab
6
+ metadata.gz: 21577368bee6f5560d27488a4bfbc3cd064bdca3869a8538002838e10f64bcaf6c20f7ec2a0a1ce56d5690b9959adbe780e6b4d7b41e59af1a78f281f1ef413a
7
+ data.tar.gz: 7e6b3c94d40059c22aa929efb07f93fdcef8abc1ffc6ef63dfe10c7d862c31d39880cc1175ad953231675bb2dd644e23d7a0b2ba1e426544af330309c77e26bb
@@ -56,11 +56,32 @@ module IronTrail
56
56
  connection.execute(query)
57
57
  end
58
58
 
59
+ # Counting rows in Postgres is known to be a slow operation for large tables.
60
+ # Because of this, avoid using this for monitoring new errors. Instead,
61
+ # use the trigger_errors_metrics method.
59
62
  def trigger_errors_count
60
63
  stmt = 'SELECT COUNT(*) AS c FROM "irontrail_trigger_errors"'
61
64
  connection.execute(stmt).first['c']
62
65
  end
63
66
 
67
+ # This returns metrics intended to be used for monitoring. One can send
68
+ # these values to something like a Prometheus deployment and add monitoring
69
+ # on top of it.
70
+ # It should be much faster to run than trigger_errors_count.
71
+ #
72
+ # If the irontrail_trigger_errors table is empty, the resulting values
73
+ # will all be zero and never nil. This is so that data in a monitoring setup
74
+ # can tell apart a failure from a no-data scenario.
75
+ def trigger_errors_metrics
76
+ stmt = 'SELECT MAX(created_at) maxdate, MAX(id) AS maxid FROM "irontrail_trigger_errors"'
77
+ res = connection.execute(stmt).first
78
+
79
+ {
80
+ max_created_at: (res && res['maxdate'] && res['maxdate'].to_i) || 0,
81
+ max_id: (res && res['maxid']) || 0,
82
+ }
83
+ end
84
+
64
85
  def collect_all_tables(schema: 'public')
65
86
  # query pg_class rather than information schema because this way
66
87
  # we can get only regular tables and ignore partitions.
@@ -1,5 +1,5 @@
1
1
  # frozen_literal_string: true
2
2
 
3
3
  module IronTrail
4
- VERSION = '0.1.0'
4
+ VERSION = '0.1.1'
5
5
  end
data/lib/iron_trail.rb CHANGED
@@ -52,17 +52,6 @@ module IronTrail
52
52
  config.enable
53
53
  end
54
54
 
55
- # def test_mode!
56
- # if [ENV['RAILS_ENV'], ENV['RACK_ENV']].include?('production')
57
- # raise "IronTrail test mode cannot be enabled in production!"
58
- # end
59
- # @test_mode = true
60
- # end
61
- #
62
- # def test_mode?
63
- # @test_mode
64
- # end
65
-
66
55
  def ignore_table?(name)
67
56
  (OWN_TABLES + (config.ignored_tables || [])).include?(name)
68
57
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: iron_trail
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - André Diego Piske
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2025-01-29 00:00:00.000000000 Z
10
+ date: 2025-02-04 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: rails
@@ -153,7 +153,13 @@ files:
153
153
  homepage: https://github.com/trusted/iron_trail
154
154
  licenses:
155
155
  - MIT
156
- metadata: {}
156
+ metadata:
157
+ bug_tracker_uri: https://github.com/trusted/iron_trail/issues
158
+ changelog_uri: https://github.com/trusted/iron_trail/blob/main/CHANGELOG.md
159
+ documentation_uri: https://github.com/trusted/iron_trail/blob/main/README.md
160
+ homepage_uri: https://github.com/trusted/iron_trail
161
+ source_code_uri: https://github.com/trusted/iron_trail
162
+ wiki_uri: https://github.com/trusted/iron_trail/wiki
157
163
  rdoc_options: []
158
164
  require_paths:
159
165
  - lib