prometheus-client-mmap 0.7.0.beta17 → 0.7.0.beta18

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
  SHA1:
3
- metadata.gz: a830232952d5753fc160f570cc962602f35b219b
4
- data.tar.gz: 33183db099150ced78e22ff071cbde0730a1f993
3
+ metadata.gz: 125465cb67bfcdcce578b05e2533264d5a6f16bf
4
+ data.tar.gz: 8251ad819a49074395451366c33ed4e2e28c7efd
5
5
  SHA512:
6
- metadata.gz: f2f6b8fba44ce2760d0dd44a271718024b622cb21387590316c2de0590b895d4ce120c86b2e98ada39ceb2e3c3eb7fccacc96ceeb867ab21de4364e5db92faaa
7
- data.tar.gz: c024e67d7f75e52a45b00791a481bb2ee5f99aa5f4b52b73b27f4e57ee54ae25cae35e3f6c6ebab84ceb4da0532cbddf921f551f18e5161489e483659e8df70c
6
+ metadata.gz: e1e6d918da65e60683c55306e74869a5b166ed21a8ba0b0512b11d9f1c817d625541300d06668e294bb99cdf5b3a6feacb24e990e6bf97249c1eadcb7d65fdf0
7
+ data.tar.gz: 50f9b80b2f9d2861e18105c6037cac59e8b282aaed402f571d4a75cbc43b2a1221b7c9ac1f6e8eadadefa189b502e4bc3697bd3c1fee6abbfcc98e6ac2f3a698
@@ -29,14 +29,10 @@ module Prometheus
29
29
  end
30
30
 
31
31
  def ensure_process_exclusive_file(file_prefix = 'mmaped_file')
32
- path = nil
33
- filename_number = 0
34
- until path && Helper::MmapedFile.lock_to_process(path)
35
- filename = "#{file_prefix}_#{Prometheus::Client.pid}-#{filename_number}.db"
36
- path = File.join(Prometheus::Client.configuration.multiprocess_files_dir, filename)
37
- filename_number += 1
38
- end
39
- path
32
+ (0..Float::INFINITY).lazy
33
+ .map { |f_num| "#{file_prefix}_#{Prometheus::Client.pid}-#{f_num}.db" }
34
+ .map { |filename| File.join(Prometheus::Client.configuration.multiprocess_files_dir, filename) }
35
+ .find { |path| Helper::MmapedFile.lock_to_process(path) }
40
36
  end
41
37
 
42
38
  def open_process_exclusive_file(file_prefix = 'mmaped_file')
@@ -102,10 +98,6 @@ module Prometheus
102
98
  self.pid = 0
103
99
  end
104
100
 
105
- def initial_mmap_file_size
106
- Prometheus::Client.configuration.initial_mmap_file_size
107
- end
108
-
109
101
  def entries
110
102
  return Enumerator.new {} if used.zero?
111
103
 
@@ -118,10 +110,11 @@ module Prometheus
118
110
  encoded_len, = data.unpack('l')
119
111
  padding_len = 8 - (encoded_len + 4) % 8
120
112
  value_offset = 4 + encoded_len + padding_len
113
+ pos += value_offset
121
114
 
122
- yielder.yield data, encoded_len, value_offset
115
+ yielder.yield data, encoded_len, value_offset, pos
123
116
 
124
- pos += value_offset + 8
117
+ pos += 8
125
118
  end
126
119
  end
127
120
  end
@@ -150,6 +143,10 @@ module Prometheus
150
143
 
151
144
  private
152
145
 
146
+ def initial_mmap_file_size
147
+ Prometheus::Client.configuration.initial_mmap_file_size
148
+ end
149
+
153
150
  def pid_alive?(pid)
154
151
  begin
155
152
  Process.getpgid(pid)
@@ -26,7 +26,7 @@ module Prometheus
26
26
  @used = @m.used
27
27
 
28
28
  @positions = {}
29
- read_all_positions.each do |key, _, pos|
29
+ read_all_positions.each do |key, pos|
30
30
  @positions[key] = pos
31
31
  end
32
32
  rescue StandardError => e
@@ -37,7 +37,7 @@ module Prometheus
37
37
  def self.read_all_values(f)
38
38
  m = Helper::MmapedFile.open(f)
39
39
 
40
- m.entries.map do |data, encoded_len, value_offset|
40
+ m.entries.map do |data, encoded_len, value_offset, _|
41
41
  encoded, value = data.unpack(format('@4A%d@%dd', encoded_len, value_offset))
42
42
  [encoded, value]
43
43
  end
@@ -73,10 +73,6 @@ module Prometheus
73
73
  Prometheus::Client.logger.warn("munmap raised error #{e}")
74
74
  end
75
75
 
76
- def initial_mmap_file_size
77
- Prometheus::Client.configuration.initial_mmap_file_size
78
- end
79
-
80
76
  private
81
77
 
82
78
  # Initialize a value. Lock must be held by caller.
@@ -89,11 +85,11 @@ module Prometheus
89
85
  @positions[key] = @used - 8
90
86
  end
91
87
 
92
- # Yield (key, value, pos). No locking is performed.
88
+ # Yield (key, pos). No locking is performed.
93
89
  def read_all_positions
94
- @m.entries.map do |data, encoded_len, value_offset|
90
+ @m.entries.map do |data, encoded_len, _, absolute_pos|
95
91
  encoded, = data.unpack(format('@4A%d', encoded_len))
96
- [encoded, value_offset]
92
+ [encoded, absolute_pos]
97
93
  end
98
94
  end
99
95
  end
@@ -4,9 +4,8 @@ module Prometheus
4
4
  module Unicorn
5
5
  def self.worker_pid_provider
6
6
  wid = worker_id
7
- wid = Process.pid if wid.nil?
8
7
  if wid.nil?
9
- "process_pid_#{Process.pid}"
8
+ "process_id_#{Process.pid}"
10
9
  else
11
10
  "worker_id_#{wid}"
12
11
  end
@@ -1,5 +1,5 @@
1
1
  module Prometheus
2
2
  module Client
3
- VERSION = '0.7.0.beta17'
3
+ VERSION = '0.7.0.beta18'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: prometheus-client-mmap
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0.beta17
4
+ version: 0.7.0.beta18
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tobias Schmidt
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-10-12 00:00:00.000000000 Z
11
+ date: 2017-10-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mmap2