postgres-vacuum-monitor 0.9.0 → 0.10.0

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: 4382d19c2d29b384cf066212c3b0611e42e6c229fe545222c24490d4df8cdc50
4
- data.tar.gz: 6f0636e2f3bfea67bfde5c92c5e373c23870582e748248fc338a3f1b50c8488d
3
+ metadata.gz: 2ab4f56ed45e6863e0d69c3c2657fed7183f1fcf1d077bfc1baa00fa1022c794
4
+ data.tar.gz: bf88a041ad9ac3ea4f28f5ad8b02b5d1831020a578dc5acfafb72eae5e8690c5
5
5
  SHA512:
6
- metadata.gz: 46159ba1e63c96ccfa8c672e61b9312655417202f7197c4acd841781f03d309fedefb1096477be5228a060433dcbe6a506883c0d538ab3a4f14c08e24525ea0f
7
- data.tar.gz: e964d5f157117ba0a926b654fd882dd9f8d24a18e51c8cc4683e4079de9661e17a7a4d2edcaafa54246249b5b3d6f3e06aa6564ca63a04a52dca098f9c120f0d
6
+ metadata.gz: c2faf27d466c5a623cd177fa76e372b6caafb708f31ff12c6398b77eeff54230abdb5c7fa15ecdae740a882659b8a1bd77138f3529efc4a9562237954f98277a
7
+ data.tar.gz: 4e5cc971b6c0a841c868f90b754d46304117cf739f588ed68fea454628e1d621ac0412234012a46d2518761c0575be89bd1ad4045726bc5a74a38ca031303de2
data/.gitignore CHANGED
@@ -9,5 +9,5 @@
9
9
  *.iml
10
10
  .idea/
11
11
  Gemfile.lock
12
- log/*.log
13
12
  gemfiles/*.gemfile.lock
13
+ log/
@@ -1,7 +1,8 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 2.5.6
4
- - 2.6.3
3
+ - 2.5.8
4
+ - 2.6.6
5
+ - 2.7.1
5
6
  gemfile:
6
7
  - gemfiles/activerecord_5.gemfile
7
8
  - gemfiles/activerecord_6.gemfile
@@ -1,6 +1,9 @@
1
1
  # postgres-vacuum-monitor
2
2
 
3
- ## v.0.8.0
3
+ ## v.10.0
4
+ - Add events for connection idle time and state.
5
+
6
+ ## v.0.9.0
4
7
  - Add the application name in the event.
5
8
 
6
9
  ## v.0.8.0
@@ -6,6 +6,8 @@ module Postgres
6
6
  AUTOVACUUM_LAGGING_EVENT = 'AutoVacuumLagging'.freeze
7
7
  LONG_TRANSACTIONS = 'LongTransactions'.freeze
8
8
  BLOCKED_QUERIES = 'BlockedQueries'.freeze
9
+ CONNECTION_STATE = 'ConnectionState'.freeze
10
+ CONNECTION_IDLE_TIME = 'ConnectionIdleTime'.freeze
9
11
 
10
12
  def perform(*)
11
13
  with_each_db_name_and_connection do |name, connection|
@@ -47,6 +49,20 @@ module Postgres
47
49
  current_statement_in_blocking_process: row['current_statement_in_blocking_process']
48
50
  )
49
51
  end
52
+
53
+ connection.execute(Postgres::Vacuum::Monitor::Query.connection_state).each do |row|
54
+ reporter_class.report_event(CONNECTION_STATE, database_name: name, state: row['state'], connection_count: row['connection_count'])
55
+ end
56
+
57
+ connection.execute(Postgres::Vacuum::Monitor::Query.connection_idle_time).each do |row|
58
+ reporter_class.report_event(
59
+ CONNECTION_IDLE_TIME,
60
+ database_name: name,
61
+ max: row['max'],
62
+ median: row['median'],
63
+ percentile_90: row['percentile_90']
64
+ )
65
+ end
50
66
  end
51
67
 
52
68
  true
@@ -97,6 +97,28 @@ module Postgres
97
97
  WHERE NOT blocked_locks.GRANTED;
98
98
  SQL
99
99
  end
100
+
101
+ def connection_state
102
+ <<-SQL
103
+ SELECT
104
+ state, count(*) as connection_count
105
+ FROM pg_stat_activity
106
+ GROUP BY state
107
+ ORDER BY count DESC;
108
+ SQL
109
+ end
110
+
111
+ def connection_idle_time
112
+ <<-SQL
113
+ SELECT
114
+ max(EXTRACT(EPOCH FROM (CURRENT_TIMESTAMP - state_change))) as max,
115
+ percentile_cont(0.5) within GROUP (ORDER BY EXTRACT(EPOCH FROM (CURRENT_TIMESTAMP - state_change)) DESC) AS median,
116
+ percentile_cont(0.9) within GROUP (ORDER BY EXTRACT(EPOCH FROM (CURRENT_TIMESTAMP - state_change)) DESC) AS percentile_90
117
+ FROM pg_stat_activity
118
+ WHERE state = 'idle'
119
+ LIMIT 1000;
120
+ SQL
121
+ end
100
122
  end
101
123
  end
102
124
  end
@@ -1,7 +1,7 @@
1
1
  module Postgres
2
2
  module Vacuum
3
3
  module Monitor
4
- VERSION = '0.9.0'.freeze
4
+ VERSION = '0.10.0'.freeze
5
5
  end
6
6
  end
7
7
  end
@@ -24,7 +24,7 @@ Gem::Specification.new do |spec|
24
24
 
25
25
  spec.add_development_dependency 'appraisal'
26
26
  spec.add_development_dependency 'bundler'
27
- spec.add_development_dependency 'coveralls'
27
+ spec.add_development_dependency 'coveralls_reborn', '>= 0.18.0'
28
28
  spec.add_development_dependency 'database_cleaner'
29
29
  spec.add_development_dependency 'rake', '~> 10.0'
30
30
  spec.add_development_dependency 'rspec', '~> 3.2'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: postgres-vacuum-monitor
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.0
4
+ version: 0.10.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Fernando Garces
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-02-26 00:00:00.000000000 Z
11
+ date: 2020-10-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: appraisal
@@ -39,19 +39,19 @@ dependencies:
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
- name: coveralls
42
+ name: coveralls_reborn
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - ">="
46
46
  - !ruby/object:Gem::Version
47
- version: '0'
47
+ version: 0.18.0
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - ">="
53
53
  - !ruby/object:Gem::Version
54
- version: '0'
54
+ version: 0.18.0
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: database_cleaner
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -180,7 +180,7 @@ files:
180
180
  homepage: https://github.com/salsify/postgres-vacuum-monitor
181
181
  licenses: []
182
182
  metadata: {}
183
- post_install_message:
183
+ post_install_message:
184
184
  rdoc_options: []
185
185
  require_paths:
186
186
  - lib
@@ -195,8 +195,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
195
195
  - !ruby/object:Gem::Version
196
196
  version: '0'
197
197
  requirements: []
198
- rubygems_version: 3.0.4
199
- signing_key:
198
+ rubygems_version: 3.1.2
199
+ signing_key:
200
200
  specification_version: 4
201
201
  summary: Simple stats collector for postgres auto vacuumer.
202
202
  test_files: []