pgdexter 0.4.0 → 0.4.2

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: 62ad383008579d8dbe952b3f96c827e01aa198c0eb74b3b884188472459b34b8
4
- data.tar.gz: b77596742f0e13bb058354edcd901d1e93ec94f61bf6a695957c51fe9c7e41dc
3
+ metadata.gz: 8e8097505929a24e8c038c7fe69ac667faaa05008a3aa94971501fc4b9f15157
4
+ data.tar.gz: a08bf061493ed984103ce768af1347d81250c51b4f068f69d3688a1e4fd25514
5
5
  SHA512:
6
- metadata.gz: 1b5f18ce901729f9e22d4222b0ba7ee498be18edb7897221c28069f8beceb65058342c47e9211ce94814d04b380387b95506722b1568a1d44b4d3c8386beeb17
7
- data.tar.gz: fa51ae2cde49dfcf9fc181a30bda4941c2ea01f1186fdd6a8cd002059a71c4b3341686cd62f2d1366874c941b92db1a4f74a6abd272baa66063907602e1376c5
6
+ metadata.gz: 9c2d99ecbd5fd68e460f25982fe31d1149d9682a7065cfb674d24785f78138ab04d94bcdbf3b81f2d8065468f6531bbaea1e0593bd8fd7ab4dcdb2b061276c1e
7
+ data.tar.gz: 0e55cc589470760d317e3ba0e895d7ce5e24cd79517cf02c59aaba1caf36eb1f9785725eedc61e7402d480a61870828aaf2b33683f8ca58223f380d518c7df9c
data/CHANGELOG.md CHANGED
@@ -1,3 +1,11 @@
1
+ ## 0.4.2 (2023-01-29)
2
+
3
+ - Fixed `--pg-stat-statements` option for Postgres 13+
4
+
5
+ ## 0.4.1 (2022-10-15)
6
+
7
+ - Added support for `json` format
8
+
1
9
  ## 0.4.0 (2022-07-27)
2
10
 
3
11
  - Added support for pg_query 2
data/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  The automatic indexer for Postgres
4
4
 
5
- [Read about how it works](https://ankane.org/introducing-dexter)
5
+ [Read about how it works](https://ankane.org/introducing-dexter) or [watch the talk](https://www.youtube.com/watch?v=Mni_1yTaNbE)
6
6
 
7
7
  [![Build Status](https://github.com/ankane/dexter/workflows/build/badge.svg?branch=master)](https://github.com/ankane/dexter/actions)
8
8
 
@@ -190,11 +190,13 @@ dexter --log-sql --log-level debug2
190
190
 
191
191
  ## Hosted Postgres
192
192
 
193
- Some hosted providers like Amazon RDS and Heroku do not support the HypoPG extension, which Dexter needs to run. See [how to use Dexter](guides/Hosted-Postgres.md) in these cases. To request the extension:
193
+ The `hypopg` extension, which Dexter needs to run, is available on [these providers](https://github.com/ankane/dexter/issues/44).
194
+
195
+ For other providers, see [this guide](guides/Hosted-Postgres.md). To request a new extension:
194
196
 
195
197
  - Amazon RDS - follow the instructions on [this page](https://aws.amazon.com/rds/postgresql/faqs/)
196
- - Google Cloud SQL - star the [feature request](https://issuetracker.google.com/issues/69250435)
197
- - DigitalOcean Managed Databases - follow the instructions on [this page](https://docs.digitalocean.com/products/databases/postgresql/details/supported-extensions/#supported-extensions)
198
+ - Google Cloud SQL - vote or comment on [this page](https://issuetracker.google.com/issues/69250435)
199
+ - DigitalOcean Managed Databases - vote or comment on [this page](https://ideas.digitalocean.com/app-framework-services/p/support-hypopg-for-postgres)
198
200
 
199
201
  ## Additional Installation Methods
200
202
 
@@ -212,7 +214,7 @@ And run it with:
212
214
  docker run -ti ankane/dexter <connection-options>
213
215
  ```
214
216
 
215
- On Mac and Windows, use `host.docker.internal` as the database hostname for databases on your local machine.
217
+ For databases on the host machine, use `host.docker.internal` as the hostname (on Linux, this requires Docker 20.04 and `--add-host=host.docker.internal:host-gateway`).
216
218
 
217
219
  ### Homebrew
218
220
 
@@ -620,6 +620,7 @@ module Dexter
620
620
  end
621
621
 
622
622
  def stat_statements
623
+ total_time = server_version_num >= 130000 ? "(total_plan_time + total_exec_time)" : "total_time"
623
624
  result = execute <<-SQL
624
625
  SELECT
625
626
  DISTINCT query
@@ -629,7 +630,7 @@ module Dexter
629
630
  pg_database ON pg_database.oid = pg_stat_statements.dbid
630
631
  WHERE
631
632
  datname = current_database()
632
- AND total_time >= #{@min_time * 60000}
633
+ AND #{total_time} >= #{@min_time * 60000}
633
634
  AND calls >= #{@min_calls}
634
635
  ORDER BY
635
636
  1
@@ -0,0 +1,23 @@
1
+ require "json"
2
+
3
+ module Dexter
4
+ class JsonLogParser < LogParser
5
+ FIRST_LINE_REGEX = /\A.+/
6
+
7
+ def perform
8
+ @logfile.each_line do |line|
9
+ row = JSON.parse(line.chomp)
10
+ if (m = REGEX.match(row["message"]))
11
+ # replace first line with match
12
+ # needed for multiline queries
13
+ active_line = row["message"].sub(FIRST_LINE_REGEX, m[3])
14
+
15
+ add_parameters(active_line, row["detail"]) if row["detail"]
16
+ process_entry(active_line, m[1].to_f)
17
+ end
18
+ end
19
+ rescue JSON::ParserError => e
20
+ raise Dexter::Abort, "ERROR: #{e.message}"
21
+ end
22
+ end
23
+ end
@@ -13,6 +13,8 @@ module Dexter
13
13
  PgStatActivityParser.new(@indexer, @collector)
14
14
  elsif options[:input_format] == "csv"
15
15
  CsvLogParser.new(logfile, @collector)
16
+ elsif options[:input_format] == "json"
17
+ JsonLogParser.new(logfile, @collector)
16
18
  elsif options[:input_format] == "sql"
17
19
  SqlLogParser.new(logfile, @collector)
18
20
  else
@@ -1,3 +1,3 @@
1
1
  module Dexter
2
- VERSION = "0.4.0"
2
+ VERSION = "0.4.2"
3
3
  end
data/lib/dexter.rb CHANGED
@@ -16,6 +16,7 @@ require "dexter/collector"
16
16
  require "dexter/indexer"
17
17
  require "dexter/log_parser"
18
18
  require "dexter/csv_log_parser"
19
+ require "dexter/json_log_parser"
19
20
  require "dexter/pg_stat_activity_parser"
20
21
  require "dexter/sql_log_parser"
21
22
  require "dexter/processor"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pgdexter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Kane
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-07-28 00:00:00.000000000 Z
11
+ date: 2023-01-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: slop
@@ -68,6 +68,7 @@ files:
68
68
  - lib/dexter/collector.rb
69
69
  - lib/dexter/csv_log_parser.rb
70
70
  - lib/dexter/indexer.rb
71
+ - lib/dexter/json_log_parser.rb
71
72
  - lib/dexter/log_parser.rb
72
73
  - lib/dexter/logging.rb
73
74
  - lib/dexter/pg_stat_activity_parser.rb
@@ -94,7 +95,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
94
95
  - !ruby/object:Gem::Version
95
96
  version: '0'
96
97
  requirements: []
97
- rubygems_version: 3.3.7
98
+ rubygems_version: 3.4.1
98
99
  signing_key:
99
100
  specification_version: 4
100
101
  summary: The automatic indexer for Postgres