pgq_prometheus 0.2.2 → 0.2.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: c50481a86da83ef0d570c77a11d24caef01d0053e5414769ef2db57d6ce633b0
4
- data.tar.gz: 1afe0060aa7fc70d8183b234e583cceac4cf7e9b9a938ed8f77a7caaa9fbad01
3
+ metadata.gz: 468cc359aeaedd54778017df1fb7a64e25219bd4f55f0c7e3250bcc214710895
4
+ data.tar.gz: 23d04244e7d7312a13a0ca17c11eed0c936a125f7358f90269f9f724a4bec74d
5
5
  SHA512:
6
- metadata.gz: 988676417dfad5594adf5d356b3dccc5d5a9a4f4197b9b97b65bbe1fdb45a768120ef6cc5ce4ec81d9b09866c9ef0807114321f3c9ae7ce164ab550e868d82a2
7
- data.tar.gz: 33d063934622c01cd674a957a09001e5428025159e14d7e15e41dce6472d6f992dcee6203c1288a4ba391f3234bf2bc42245429a20dafece24738108a9506cf8
6
+ metadata.gz: 4f8aeb11b67078828815e0632c9a8084886fefd187056f95d8d8b3f955cc97df3cc137768d2eedb3c2b56b825d73dbe53d5004408c0f3968dde476539e04782f
7
+ data.tar.gz: 4eb3946315b5d77c4563624eccb808729b506ce3eadc56e99bf2a153b8fb8b4c12c38d22e4b720d1f94d986bdbd58d701b872b847f5058fd8a527180edae8ca7
@@ -26,14 +26,11 @@ module PgqPrometheus
26
26
  def metrics
27
27
  return [] if @data.length == 0
28
28
 
29
+ @observers.each_value(&:reset!)
29
30
  metrics = {}
30
31
 
31
32
  @data.map do |obj|
32
- labels = {}
33
- # labels are passed by PgqPrometheus::Processor
34
- labels.merge!(obj['metric_labels']) if obj['metric_labels']
35
- # custom_labels are passed by PrometheusExporter::Client
36
- labels.merge!(obj['custom_labels']) if obj['custom_labels']
33
+ labels = gather_labels(obj)
37
34
 
38
35
  @observers.each do |name, observer|
39
36
  name = name.to_s
@@ -55,5 +52,16 @@ module PgqPrometheus
55
52
  @data.delete_if { |m| m['created_at'] + MAX_METRIC_AGE < now }
56
53
  @data << obj
57
54
  end
55
+
56
+ private
57
+
58
+ def gather_labels(obj)
59
+ labels = {}
60
+ # labels are passed by PgqPrometheus::Processor
61
+ labels.merge!(obj['metric_labels']) if obj['metric_labels']
62
+ # custom_labels are passed by PrometheusExporter::Client
63
+ labels.merge!(obj['custom_labels']) if obj['custom_labels']
64
+ labels.to_h { |key, value| [key.to_s, value.to_s] }
65
+ end
58
66
  end
59
67
  end
@@ -63,9 +63,16 @@ module PgqPrometheus
63
63
  sql = model_class.send :sanitize_sql_array, bindings.unshift(sql) unless bindings.empty?
64
64
  result = model_class.connection.select_all(sql)
65
65
  result.map do |row|
66
- row.map { |k, v| [k.to_sym, result.column_types[k].deserialize(v)] }.to_h
66
+ row.map { |k, v| [k.to_sym, deserialize_value(result, k, v)] }.to_h
67
67
  end
68
68
  end
69
+
70
+ def deserialize_value(result, key, value)
71
+ pg_type = result.column_types[key]
72
+ return value if pg_type.nil?
73
+
74
+ pg_type.deserialize(value)
75
+ end
69
76
  end
70
77
  end
71
78
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module PgqPrometheus
4
- VERSION = '0.2.2'
4
+ VERSION = '0.2.4'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pgq_prometheus
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Denis Talakevich
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-06-09 00:00:00.000000000 Z
11
+ date: 2025-04-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: prometheus_exporter
@@ -69,7 +69,7 @@ metadata:
69
69
  homepage_uri: https://github.com/didww/pgq_prometheus
70
70
  source_code_uri: https://github.com/didww/pgq_prometheus
71
71
  changelog_uri: https://github.com/didww/pgq_prometheus
72
- post_install_message:
72
+ post_install_message:
73
73
  rdoc_options: []
74
74
  require_paths:
75
75
  - lib
@@ -84,8 +84,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
84
84
  - !ruby/object:Gem::Version
85
85
  version: '0'
86
86
  requirements: []
87
- rubygems_version: 3.1.2
88
- signing_key:
87
+ rubygems_version: 3.5.6
88
+ signing_key:
89
89
  specification_version: 4
90
90
  summary: Prometheus metrics for PGQ postgres extension
91
91
  test_files: []