pghero 3.3.2 → 3.3.4

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: 2fa38fa0cc98e7f066698e558c6a6bc59cdc60ed5fd2ecbafe43f9f46918c8a2
4
- data.tar.gz: 41510ad944cbd565c62aa02d6996af86ce4764e10cfbd09d1109ee12b2534fae
3
+ metadata.gz: 2332e2a4f7b9bd25d972ec1f06635dfc43676412c5be4147e3a7e3dc8effa213
4
+ data.tar.gz: 1a24e423a0d8749d69eb938eaa27db1beed974d1a058e6ae6331badeae9c4d59
5
5
  SHA512:
6
- metadata.gz: dfeb7118ad7d5b2b0170b6e82ef03595725085de2e93e4c6a05eb16a3d7288b4475fe33dc0e86bbbd6f17d4e5bf50df391ce8772a57c0aec77656e822244b264
7
- data.tar.gz: 24f21e42883c5148bff431dda7dba11701e109347fc2ee173288cb3378ccf41354c3111074fba46a556b2a280d476caca9b20ba48b3b4b8bae1dee884f738c62
6
+ metadata.gz: b19ca11ceee2f44bbcdec49e14f0653df6efc740e4fbd710700a03254ac8d40db84690409a731c06359d547934d401615925e88df317ccae4137eecefcfe8ddf
7
+ data.tar.gz: b6c0069a0e34ecd66d359aff9226fe678ccc15d55b1ad0e70f421a7fa9b9a2113d7eb31cc30d69364489fa1e10e2b5d6d0e48ada03d15e79aff5ba9dda350659
data/CHANGELOG.md CHANGED
@@ -1,3 +1,11 @@
1
+ ## 3.3.4 (2023-09-05)
2
+
3
+ - Fixed support for aliases in config file
4
+
5
+ ## 3.3.3 (2023-04-18)
6
+
7
+ - Fixed error with system stats for Azure Database
8
+
1
9
  ## 3.3.2 (2023-04-12)
2
10
 
3
11
  - Fixed error with suggested indexes and empty statements
@@ -248,9 +248,16 @@ module PgHero
248
248
  stats =
249
249
  case @database.system_stats_provider
250
250
  when :azure
251
- [
252
- {name: "IO Consumption", data: @database.azure_stats("io_consumption_percent", **system_params), library: chart_library_options}
253
- ]
251
+ if @database.send(:azure_flexible_server?)
252
+ [
253
+ {name: "Read IOPS", data: @database.read_iops_stats(**system_params).map { |k, v| [k, v ? v.round : v] }, library: chart_library_options},
254
+ {name: "Write IOPS", data: @database.write_iops_stats(**system_params).map { |k, v| [k, v ? v.round : v] }, library: chart_library_options}
255
+ ]
256
+ else
257
+ [
258
+ {name: "IO Consumption", data: @database.azure_stats("io_consumption_percent", **system_params), library: chart_library_options}
259
+ ]
260
+ end
254
261
  when :gcp
255
262
  [
256
263
  {name: "Read Ops", data: @database.read_iops_stats(**system_params).map { |k, v| [k, v ? v.round : v] }, library: chart_library_options},
@@ -102,7 +102,8 @@ module PgHero
102
102
  end
103
103
 
104
104
  client = Azure::Monitor::Profiles::Latest::Mgmt::Client.new
105
- timespan = "#{start_time.iso8601}/#{end_time.iso8601}"
105
+ # call utc to convert +00:00 to Z
106
+ timespan = "#{start_time.utc.iso8601}/#{end_time.utc.iso8601}"
106
107
  results = client.metrics.list(
107
108
  azure_resource_id,
108
109
  metricnames: metric_name,
@@ -269,12 +270,13 @@ module PgHero
269
270
  used = azure_stats("storage_used", **options)
270
271
  free_space(quota, used)
271
272
  else
272
- # no read_iops, write_iops
273
- # could add io_consumption_percent
273
+ replication_lag_stat = azure_flexible_server? ? "physical_replication_delay_in_seconds" : "pg_replica_log_delay_in_seconds"
274
274
  metrics = {
275
275
  cpu: "cpu_percent",
276
276
  connections: "active_connections",
277
- replication_lag: "pg_replica_log_delay_in_seconds"
277
+ replication_lag: replication_lag_stat,
278
+ read_iops: "read_iops", # flexible server only
279
+ write_iops: "write_iops" # flexible server only
278
280
  }
279
281
  raise Error, "Metric not supported" unless metrics[metric_key]
280
282
  azure_stats(metrics[metric_key], **options)
@@ -284,6 +286,10 @@ module PgHero
284
286
  end
285
287
  end
286
288
 
289
+ def azure_flexible_server?
290
+ azure_resource_id.include?("/Microsoft.DBforPostgreSQL/flexibleServers/")
291
+ end
292
+
287
293
  # only use data points included in both series
288
294
  # this also eliminates need to align Time.now
289
295
  def free_space(quota, used)
@@ -1,3 +1,3 @@
1
1
  module PgHero
2
- VERSION = "3.3.2"
2
+ VERSION = "3.3.4"
3
3
  end
data/lib/pghero.rb CHANGED
@@ -121,7 +121,7 @@ module PgHero
121
121
 
122
122
  config_file_exists = File.exist?(path)
123
123
 
124
- config = YAML.safe_load(ERB.new(File.read(path)).result) if config_file_exists
124
+ config = YAML.safe_load(ERB.new(File.read(path)).result, aliases: true) if config_file_exists
125
125
  config ||= {}
126
126
 
127
127
  @file_config =
@@ -151,7 +151,7 @@ module PgHero
151
151
 
152
152
  if databases.empty?
153
153
  databases["primary"] = {
154
- "url" => ENV["PGHERO_DATABASE_URL"] || connection_config(ActiveRecord::Base)
154
+ "url" => ENV["PGHERO_DATABASE_URL"] || default_connection_config
155
155
  }
156
156
  end
157
157
 
@@ -168,6 +168,11 @@ module PgHero
168
168
  }
169
169
  end
170
170
 
171
+ # private
172
+ def default_connection_config
173
+ connection_config(ActiveRecord::Base) if ActiveRecord::VERSION::STRING.to_f < 7.1
174
+ end
175
+
171
176
  # ensure we only have one copy of databases
172
177
  # so there's only one connection pool per database
173
178
  def databases
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pghero
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.3.2
4
+ version: 3.3.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Kane
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-04-13 00:00:00.000000000 Z
11
+ date: 2023-09-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord