prometheus-client-mmap 0.21.0-x86_64-linux-musl → 1.2.1-x86_64-linux-musl
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.tool-versions +1 -0
- data/README.md +32 -17
- data/ext/fast_mmaped_file_rs/Cargo.toml +14 -9
- data/ext/fast_mmaped_file_rs/build.rs +5 -0
- data/ext/fast_mmaped_file_rs/extconf.rb +1 -3
- data/ext/fast_mmaped_file_rs/src/error.rs +2 -2
- data/ext/fast_mmaped_file_rs/src/file_entry.rs +222 -17
- data/ext/fast_mmaped_file_rs/src/file_info.rs +56 -6
- data/ext/fast_mmaped_file_rs/src/lib.rs +0 -1
- data/ext/fast_mmaped_file_rs/src/map.rs +12 -12
- data/ext/fast_mmaped_file_rs/src/mmap/inner.rs +704 -0
- data/ext/fast_mmaped_file_rs/src/mmap.rs +765 -25
- data/ext/fast_mmaped_file_rs/src/raw_entry.rs +1 -1
- data/ext/fast_mmaped_file_rs/src/testhelper.rs +1 -1
- data/lib/3.1/fast_mmaped_file_rs.so +0 -0
- data/lib/3.2/fast_mmaped_file_rs.so +0 -0
- data/lib/3.3/fast_mmaped_file_rs.so +0 -0
- data/lib/3.4/fast_mmaped_file_rs.so +0 -0
- data/lib/prometheus/client/formats/text.rb +1 -34
- data/lib/prometheus/client/helper/mmaped_file.rb +3 -3
- data/lib/prometheus/client/label_set_validator.rb +1 -2
- data/lib/prometheus/client/support/puma.rb +44 -0
- data/lib/prometheus/client/version.rb +1 -1
- metadata +67 -61
- data/ext/fast_mmaped_file/extconf.rb +0 -30
- data/ext/fast_mmaped_file/fast_mmaped_file.c +0 -122
- data/ext/fast_mmaped_file/file_format.c +0 -5
- data/ext/fast_mmaped_file/file_format.h +0 -11
- data/ext/fast_mmaped_file/file_parsing.c +0 -195
- data/ext/fast_mmaped_file/file_parsing.h +0 -27
- data/ext/fast_mmaped_file/file_reading.c +0 -102
- data/ext/fast_mmaped_file/file_reading.h +0 -30
- data/ext/fast_mmaped_file/globals.h +0 -14
- data/ext/fast_mmaped_file/mmap.c +0 -427
- data/ext/fast_mmaped_file/mmap.h +0 -61
- data/ext/fast_mmaped_file/rendering.c +0 -199
- data/ext/fast_mmaped_file/rendering.h +0 -8
- data/ext/fast_mmaped_file/utils.c +0 -56
- data/ext/fast_mmaped_file/utils.h +0 -22
- data/ext/fast_mmaped_file/value_access.c +0 -242
- data/ext/fast_mmaped_file/value_access.h +0 -15
- data/ext/fast_mmaped_file_rs/.cargo/config.toml +0 -23
- data/ext/fast_mmaped_file_rs/Cargo.lock +0 -790
- data/ext/fast_mmaped_file_rs/src/parser.rs +0 -346
- data/lib/2.7/fast_mmaped_file.so +0 -0
- data/lib/2.7/fast_mmaped_file_rs.so +0 -0
- data/lib/3.0/fast_mmaped_file.so +0 -0
- data/lib/3.0/fast_mmaped_file_rs.so +0 -0
- data/lib/3.1/fast_mmaped_file.so +0 -0
- data/lib/3.2/fast_mmaped_file.so +0 -0
- data/vendor/c/hashmap/.gitignore +0 -52
- data/vendor/c/hashmap/LICENSE +0 -21
- data/vendor/c/hashmap/README.md +0 -90
- data/vendor/c/hashmap/_config.yml +0 -1
- data/vendor/c/hashmap/src/hashmap.c +0 -692
- data/vendor/c/hashmap/src/hashmap.h +0 -267
- data/vendor/c/hashmap/test/Makefile +0 -22
- data/vendor/c/hashmap/test/hashmap_test.c +0 -608
- data/vendor/c/jsmn/.travis.yml +0 -4
- data/vendor/c/jsmn/LICENSE +0 -20
- data/vendor/c/jsmn/Makefile +0 -41
- data/vendor/c/jsmn/README.md +0 -168
- data/vendor/c/jsmn/example/jsondump.c +0 -126
- data/vendor/c/jsmn/example/simple.c +0 -76
- data/vendor/c/jsmn/jsmn.c +0 -314
- data/vendor/c/jsmn/jsmn.h +0 -76
- data/vendor/c/jsmn/library.json +0 -16
- data/vendor/c/jsmn/test/test.h +0 -27
- data/vendor/c/jsmn/test/tests.c +0 -407
- data/vendor/c/jsmn/test/testutil.h +0 -94
@@ -6,7 +6,7 @@ use crate::util::CheckedOps;
|
|
6
6
|
use crate::Result;
|
7
7
|
|
8
8
|
/// The logic to save a `MetricsEntry`, or parse one from a byte slice.
|
9
|
-
#[derive(PartialEq, Clone, Debug)]
|
9
|
+
#[derive(PartialEq, Eq, Clone, Debug)]
|
10
10
|
pub struct RawEntry<'a> {
|
11
11
|
bytes: &'a [u8],
|
12
12
|
encoded_len: usize,
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -26,49 +26,16 @@ module Prometheus
|
|
26
26
|
Helper::MetricsRepresentation.to_text(metrics)
|
27
27
|
end
|
28
28
|
|
29
|
-
def marshal_multiprocess(path = Prometheus::Client.configuration.multiprocess_files_dir
|
29
|
+
def marshal_multiprocess(path = Prometheus::Client.configuration.multiprocess_files_dir)
|
30
30
|
file_list = Dir.glob(File.join(path, '*.db')).sort
|
31
31
|
.map {|f| Helper::PlainFile.new(f) }
|
32
32
|
.map {|f| [f.filepath, f.multiprocess_mode.to_sym, f.type.to_sym, f.pid] }
|
33
33
|
|
34
|
-
if use_rust && rust_impl_available?
|
35
34
|
FastMmapedFileRs.to_metrics(file_list.to_a)
|
36
|
-
else
|
37
|
-
FastMmapedFile.to_metrics(file_list.to_a)
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
def rust_impl_available?
|
42
|
-
return @rust_available unless @rust_available.nil?
|
43
|
-
|
44
|
-
check_for_rust
|
45
35
|
end
|
46
36
|
|
47
37
|
private
|
48
38
|
|
49
|
-
def load_rust_extension
|
50
|
-
begin
|
51
|
-
ruby_version = /(\d+\.\d+)/.match(RUBY_VERSION)
|
52
|
-
require_relative "../../../#{ruby_version}/fast_mmaped_file_rs"
|
53
|
-
rescue LoadError
|
54
|
-
require 'fast_mmaped_file_rs'
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
def check_for_rust
|
59
|
-
# This will be evaluated on each invocation even with `||=` if
|
60
|
-
# `@rust_available` if false. Running a `require` statement is slow,
|
61
|
-
# so the `rust_impl_available?` method memoizes the result, external
|
62
|
-
# callers can only trigger this method a single time.
|
63
|
-
@rust_available = begin
|
64
|
-
load_rust_extension
|
65
|
-
true
|
66
|
-
rescue LoadError
|
67
|
-
Prometheus::Client.logger.info('FastMmapedFileRs unavailable')
|
68
|
-
false
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
72
39
|
def load_metrics(path)
|
73
40
|
metrics = {}
|
74
41
|
Dir.glob(File.join(path, '*.db')).sort.each do |f|
|
@@ -4,15 +4,15 @@ require 'prometheus/client/helper/file_locker'
|
|
4
4
|
# load precompiled extension if available
|
5
5
|
begin
|
6
6
|
ruby_version = /(\d+\.\d+)/.match(RUBY_VERSION)
|
7
|
-
require_relative "../../../#{ruby_version}/
|
7
|
+
require_relative "../../../#{ruby_version}/fast_mmaped_file_rs"
|
8
8
|
rescue LoadError
|
9
|
-
require '
|
9
|
+
require 'fast_mmaped_file_rs'
|
10
10
|
end
|
11
11
|
|
12
12
|
module Prometheus
|
13
13
|
module Client
|
14
14
|
module Helper
|
15
|
-
class MmapedFile <
|
15
|
+
class MmapedFile < FastMmapedFileRs
|
16
16
|
include EntryParser
|
17
17
|
|
18
18
|
attr_reader :filepath, :size
|
@@ -5,8 +5,7 @@ module Prometheus
|
|
5
5
|
# LabelSetValidator ensures that all used label sets comply with the
|
6
6
|
# Prometheus specification.
|
7
7
|
class LabelSetValidator
|
8
|
-
|
9
|
-
RESERVED_LABELS = [:job, :instance].freeze
|
8
|
+
RESERVED_LABELS = [].freeze
|
10
9
|
|
11
10
|
class LabelSetError < StandardError; end
|
12
11
|
class InvalidLabelSetError < LabelSetError; end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
module Prometheus
|
2
|
+
module Client
|
3
|
+
module Support
|
4
|
+
module Puma
|
5
|
+
extend self
|
6
|
+
|
7
|
+
def worker_pid_provider
|
8
|
+
wid = worker_id
|
9
|
+
if wid = worker_id
|
10
|
+
wid
|
11
|
+
else
|
12
|
+
"process_id_#{Process.pid}"
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
def object_based_worker_id
|
19
|
+
return unless defined?(::Puma::Cluster::Worker)
|
20
|
+
|
21
|
+
workers = ObjectSpace.each_object(::Puma::Cluster::Worker)
|
22
|
+
return if workers.nil?
|
23
|
+
|
24
|
+
workers_first = workers.first
|
25
|
+
workers_first.index unless workers_first.nil?
|
26
|
+
end
|
27
|
+
|
28
|
+
def program_name
|
29
|
+
$PROGRAM_NAME
|
30
|
+
end
|
31
|
+
|
32
|
+
def worker_id
|
33
|
+
if matchdata = program_name.match(/puma.*cluster worker ([0-9]+):/)
|
34
|
+
"puma_#{matchdata[1]}"
|
35
|
+
elsif object_worker_id = object_based_worker_id
|
36
|
+
"puma_#{object_worker_id}"
|
37
|
+
elsif program_name.include?('puma')
|
38
|
+
'puma_master'
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
metadata
CHANGED
@@ -1,15 +1,17 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: prometheus-client-mmap
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 1.2.1
|
5
5
|
platform: x86_64-linux-musl
|
6
6
|
authors:
|
7
7
|
- Tobias Schmidt
|
8
8
|
- Paweł Chojnacki
|
9
|
+
- Stan Hu
|
10
|
+
- Will Chandler
|
9
11
|
autorequire:
|
10
12
|
bindir: bin
|
11
13
|
cert_chain: []
|
12
|
-
date:
|
14
|
+
date: 2024-12-29 00:00:00.000000000 Z
|
13
15
|
dependencies:
|
14
16
|
- !ruby/object:Gem::Dependency
|
15
17
|
name: rb_sys
|
@@ -17,14 +19,42 @@ dependencies:
|
|
17
19
|
requirements:
|
18
20
|
- - "~>"
|
19
21
|
- !ruby/object:Gem::Version
|
20
|
-
version:
|
22
|
+
version: 0.9.86
|
21
23
|
type: :runtime
|
22
24
|
prerelease: false
|
23
25
|
version_requirements: !ruby/object:Gem::Requirement
|
24
26
|
requirements:
|
25
27
|
- - "~>"
|
26
28
|
- !ruby/object:Gem::Version
|
27
|
-
version:
|
29
|
+
version: 0.9.86
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: base64
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
requirements:
|
34
|
+
- - ">="
|
35
|
+
- !ruby/object:Gem::Version
|
36
|
+
version: '0'
|
37
|
+
type: :runtime
|
38
|
+
prerelease: false
|
39
|
+
version_requirements: !ruby/object:Gem::Requirement
|
40
|
+
requirements:
|
41
|
+
- - ">="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '0'
|
44
|
+
- !ruby/object:Gem::Dependency
|
45
|
+
name: bigdecimal
|
46
|
+
requirement: !ruby/object:Gem::Requirement
|
47
|
+
requirements:
|
48
|
+
- - ">="
|
49
|
+
- !ruby/object:Gem::Version
|
50
|
+
version: '0'
|
51
|
+
type: :runtime
|
52
|
+
prerelease: false
|
53
|
+
version_requirements: !ruby/object:Gem::Requirement
|
54
|
+
requirements:
|
55
|
+
- - ">="
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
version: '0'
|
28
58
|
- !ruby/object:Gem::Dependency
|
29
59
|
name: fuzzbert
|
30
60
|
requirement: !ruby/object:Gem::Requirement
|
@@ -79,72 +109,71 @@ dependencies:
|
|
79
109
|
requirements:
|
80
110
|
- - "~>"
|
81
111
|
- !ruby/object:Gem::Version
|
82
|
-
version: 1.2.
|
112
|
+
version: 1.2.7
|
83
113
|
type: :development
|
84
114
|
prerelease: false
|
85
115
|
version_requirements: !ruby/object:Gem::Requirement
|
86
116
|
requirements:
|
87
117
|
- - "~>"
|
88
118
|
- !ruby/object:Gem::Version
|
89
|
-
version: 1.2.
|
119
|
+
version: 1.2.7
|
90
120
|
- !ruby/object:Gem::Dependency
|
91
121
|
name: rake-compiler-dock
|
92
122
|
requirement: !ruby/object:Gem::Requirement
|
93
123
|
requirements:
|
94
124
|
- - "~>"
|
95
125
|
- !ruby/object:Gem::Version
|
96
|
-
version: 1.
|
126
|
+
version: 1.7.0
|
127
|
+
type: :development
|
128
|
+
prerelease: false
|
129
|
+
version_requirements: !ruby/object:Gem::Requirement
|
130
|
+
requirements:
|
131
|
+
- - "~>"
|
132
|
+
- !ruby/object:Gem::Version
|
133
|
+
version: 1.7.0
|
134
|
+
- !ruby/object:Gem::Dependency
|
135
|
+
name: rspec
|
136
|
+
requirement: !ruby/object:Gem::Requirement
|
137
|
+
requirements:
|
138
|
+
- - "~>"
|
139
|
+
- !ruby/object:Gem::Version
|
140
|
+
version: '3.2'
|
97
141
|
type: :development
|
98
142
|
prerelease: false
|
99
143
|
version_requirements: !ruby/object:Gem::Requirement
|
100
144
|
requirements:
|
101
145
|
- - "~>"
|
102
146
|
- !ruby/object:Gem::Version
|
103
|
-
version:
|
147
|
+
version: '3.2'
|
104
148
|
- !ruby/object:Gem::Dependency
|
105
149
|
name: ruby-prof
|
106
150
|
requirement: !ruby/object:Gem::Requirement
|
107
151
|
requirements:
|
108
152
|
- - "~>"
|
109
153
|
- !ruby/object:Gem::Version
|
110
|
-
version:
|
154
|
+
version: '1.7'
|
111
155
|
type: :development
|
112
156
|
prerelease: false
|
113
157
|
version_requirements: !ruby/object:Gem::Requirement
|
114
158
|
requirements:
|
115
159
|
- - "~>"
|
116
160
|
- !ruby/object:Gem::Version
|
117
|
-
version:
|
161
|
+
version: '1.7'
|
118
162
|
description:
|
119
163
|
email:
|
120
164
|
- ts@soundcloud.com
|
121
165
|
- pawel@gitlab.com
|
166
|
+
- stanhu@gmail.com
|
167
|
+
- wchandler@gitlab.com
|
122
168
|
executables: []
|
123
169
|
extensions: []
|
124
170
|
extra_rdoc_files: []
|
125
171
|
files:
|
172
|
+
- ".tool-versions"
|
126
173
|
- README.md
|
127
|
-
- ext/fast_mmaped_file/extconf.rb
|
128
|
-
- ext/fast_mmaped_file/fast_mmaped_file.c
|
129
|
-
- ext/fast_mmaped_file/file_format.c
|
130
|
-
- ext/fast_mmaped_file/file_format.h
|
131
|
-
- ext/fast_mmaped_file/file_parsing.c
|
132
|
-
- ext/fast_mmaped_file/file_parsing.h
|
133
|
-
- ext/fast_mmaped_file/file_reading.c
|
134
|
-
- ext/fast_mmaped_file/file_reading.h
|
135
|
-
- ext/fast_mmaped_file/globals.h
|
136
|
-
- ext/fast_mmaped_file/mmap.c
|
137
|
-
- ext/fast_mmaped_file/mmap.h
|
138
|
-
- ext/fast_mmaped_file/rendering.c
|
139
|
-
- ext/fast_mmaped_file/rendering.h
|
140
|
-
- ext/fast_mmaped_file/utils.c
|
141
|
-
- ext/fast_mmaped_file/utils.h
|
142
|
-
- ext/fast_mmaped_file/value_access.c
|
143
|
-
- ext/fast_mmaped_file/value_access.h
|
144
|
-
- ext/fast_mmaped_file_rs/.cargo/config.toml
|
145
|
-
- ext/fast_mmaped_file_rs/Cargo.lock
|
146
174
|
- ext/fast_mmaped_file_rs/Cargo.toml
|
147
175
|
- ext/fast_mmaped_file_rs/README.md
|
176
|
+
- ext/fast_mmaped_file_rs/build.rs
|
148
177
|
- ext/fast_mmaped_file_rs/extconf.rb
|
149
178
|
- ext/fast_mmaped_file_rs/src/error.rs
|
150
179
|
- ext/fast_mmaped_file_rs/src/file_entry.rs
|
@@ -153,18 +182,14 @@ files:
|
|
153
182
|
- ext/fast_mmaped_file_rs/src/macros.rs
|
154
183
|
- ext/fast_mmaped_file_rs/src/map.rs
|
155
184
|
- ext/fast_mmaped_file_rs/src/mmap.rs
|
156
|
-
- ext/fast_mmaped_file_rs/src/
|
185
|
+
- ext/fast_mmaped_file_rs/src/mmap/inner.rs
|
157
186
|
- ext/fast_mmaped_file_rs/src/raw_entry.rs
|
158
187
|
- ext/fast_mmaped_file_rs/src/testhelper.rs
|
159
188
|
- ext/fast_mmaped_file_rs/src/util.rs
|
160
|
-
- lib/2.7/fast_mmaped_file.so
|
161
|
-
- lib/2.7/fast_mmaped_file_rs.so
|
162
|
-
- lib/3.0/fast_mmaped_file.so
|
163
|
-
- lib/3.0/fast_mmaped_file_rs.so
|
164
|
-
- lib/3.1/fast_mmaped_file.so
|
165
189
|
- lib/3.1/fast_mmaped_file_rs.so
|
166
|
-
- lib/3.2/fast_mmaped_file.so
|
167
190
|
- lib/3.2/fast_mmaped_file_rs.so
|
191
|
+
- lib/3.3/fast_mmaped_file_rs.so
|
192
|
+
- lib/3.4/fast_mmaped_file_rs.so
|
168
193
|
- lib/prometheus.rb
|
169
194
|
- lib/prometheus/client.rb
|
170
195
|
- lib/prometheus/client/configuration.rb
|
@@ -190,29 +215,10 @@ files:
|
|
190
215
|
- lib/prometheus/client/registry.rb
|
191
216
|
- lib/prometheus/client/simple_value.rb
|
192
217
|
- lib/prometheus/client/summary.rb
|
218
|
+
- lib/prometheus/client/support/puma.rb
|
193
219
|
- lib/prometheus/client/support/unicorn.rb
|
194
220
|
- lib/prometheus/client/uses_value_type.rb
|
195
221
|
- lib/prometheus/client/version.rb
|
196
|
-
- vendor/c/hashmap/.gitignore
|
197
|
-
- vendor/c/hashmap/LICENSE
|
198
|
-
- vendor/c/hashmap/README.md
|
199
|
-
- vendor/c/hashmap/_config.yml
|
200
|
-
- vendor/c/hashmap/src/hashmap.c
|
201
|
-
- vendor/c/hashmap/src/hashmap.h
|
202
|
-
- vendor/c/hashmap/test/Makefile
|
203
|
-
- vendor/c/hashmap/test/hashmap_test.c
|
204
|
-
- vendor/c/jsmn/.travis.yml
|
205
|
-
- vendor/c/jsmn/LICENSE
|
206
|
-
- vendor/c/jsmn/Makefile
|
207
|
-
- vendor/c/jsmn/README.md
|
208
|
-
- vendor/c/jsmn/example/jsondump.c
|
209
|
-
- vendor/c/jsmn/example/simple.c
|
210
|
-
- vendor/c/jsmn/jsmn.c
|
211
|
-
- vendor/c/jsmn/jsmn.h
|
212
|
-
- vendor/c/jsmn/library.json
|
213
|
-
- vendor/c/jsmn/test/test.h
|
214
|
-
- vendor/c/jsmn/test/tests.c
|
215
|
-
- vendor/c/jsmn/test/testutil.h
|
216
222
|
homepage: https://gitlab.com/gitlab-org/prometheus-client-mmap
|
217
223
|
licenses:
|
218
224
|
- Apache-2.0
|
@@ -225,19 +231,19 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
225
231
|
requirements:
|
226
232
|
- - ">="
|
227
233
|
- !ruby/object:Gem::Version
|
228
|
-
version: '
|
234
|
+
version: '3.1'
|
229
235
|
- - "<"
|
230
236
|
- !ruby/object:Gem::Version
|
231
|
-
version: 3.
|
237
|
+
version: 3.5.dev
|
232
238
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
233
239
|
requirements:
|
234
240
|
- - ">="
|
235
241
|
- !ruby/object:Gem::Version
|
236
242
|
version: 3.3.22
|
237
243
|
requirements: []
|
238
|
-
rubygems_version: 3.
|
244
|
+
rubygems_version: 3.5.23
|
239
245
|
signing_key:
|
240
246
|
specification_version: 4
|
241
|
-
summary: A suite of instrumentation metric
|
242
|
-
web services interface.
|
247
|
+
summary: A suite of instrumentation metric primitives that can be exposed through
|
248
|
+
a web services interface.
|
243
249
|
test_files: []
|
@@ -1,30 +0,0 @@
|
|
1
|
-
require 'mkmf'
|
2
|
-
require 'fileutils'
|
3
|
-
|
4
|
-
$CFLAGS << ' -std=c99 -D_POSIX_C_SOURCE=200809L -Wall -Wextra'
|
5
|
-
|
6
|
-
if enable_config('fail-on-warning')
|
7
|
-
$CFLAGS << ' -Werror'
|
8
|
-
end
|
9
|
-
|
10
|
-
if enable_config('debug')
|
11
|
-
$CFLAGS << ' -O0 -g'
|
12
|
-
end
|
13
|
-
|
14
|
-
if enable_config('address-sanitizer')
|
15
|
-
$CFLAGS << ' -O -fsanitize=address -fno-omit-frame-pointer -g'
|
16
|
-
end
|
17
|
-
|
18
|
-
CONFIG['warnflags'].slice!(/ -Wdeclaration-after-statement/)
|
19
|
-
|
20
|
-
cwd = File.expand_path(File.dirname(__FILE__))
|
21
|
-
vendor_dir = File.join(cwd, '../../vendor/c')
|
22
|
-
src_dir = File.join(cwd, '../../ext/fast_mmaped_file')
|
23
|
-
|
24
|
-
src_files = %W[#{vendor_dir}/jsmn/jsmn.c #{vendor_dir}/hashmap/src/hashmap.c]
|
25
|
-
FileUtils.cp(src_files, src_dir)
|
26
|
-
|
27
|
-
$INCFLAGS << " -I#{vendor_dir}/jsmn -I#{vendor_dir}/hashmap/src"
|
28
|
-
|
29
|
-
dir_config('fast_mmaped_file')
|
30
|
-
create_makefile('fast_mmaped_file')
|
@@ -1,122 +0,0 @@
|
|
1
|
-
#include <errno.h>
|
2
|
-
#include <hashmap.h>
|
3
|
-
#include <jsmn.h>
|
4
|
-
#include <ruby.h>
|
5
|
-
#include <ruby/intern.h>
|
6
|
-
#include <sys/mman.h>
|
7
|
-
|
8
|
-
#include "file_parsing.h"
|
9
|
-
#include "file_reading.h"
|
10
|
-
#include "globals.h"
|
11
|
-
#include "mmap.h"
|
12
|
-
#include "rendering.h"
|
13
|
-
#include "utils.h"
|
14
|
-
#include "value_access.h"
|
15
|
-
|
16
|
-
VALUE MMAPED_FILE = Qnil;
|
17
|
-
|
18
|
-
ID sym_min;
|
19
|
-
ID sym_max;
|
20
|
-
ID sym_livesum;
|
21
|
-
ID sym_gauge;
|
22
|
-
ID sym_pid;
|
23
|
-
ID sym_samples;
|
24
|
-
|
25
|
-
VALUE prom_eParsingError;
|
26
|
-
|
27
|
-
int aggregate_files(struct hashmap *map, VALUE list_of_files) {
|
28
|
-
buffer_t reading_buffer;
|
29
|
-
memset(&reading_buffer, 0, sizeof(buffer_t));
|
30
|
-
|
31
|
-
for (int i = 0; i < RARRAY_LEN(list_of_files); i++) {
|
32
|
-
VALUE params = RARRAY_PTR(list_of_files)[i];
|
33
|
-
file_t file;
|
34
|
-
|
35
|
-
if (!file_open_from_params(&file, params)) {
|
36
|
-
buffer_dispose(&reading_buffer);
|
37
|
-
return 0;
|
38
|
-
}
|
39
|
-
|
40
|
-
if (!read_from_file(&file, &reading_buffer)) {
|
41
|
-
buffer_dispose(&reading_buffer);
|
42
|
-
file_close(&file);
|
43
|
-
return 0;
|
44
|
-
}
|
45
|
-
|
46
|
-
if (!process_buffer(&file, &reading_buffer, map)) {
|
47
|
-
buffer_dispose(&reading_buffer);
|
48
|
-
file_close(&file);
|
49
|
-
return 0;
|
50
|
-
}
|
51
|
-
|
52
|
-
if (!file_close(&file)) {
|
53
|
-
buffer_dispose(&reading_buffer);
|
54
|
-
return 0;
|
55
|
-
}
|
56
|
-
}
|
57
|
-
|
58
|
-
buffer_dispose(&reading_buffer);
|
59
|
-
return 1;
|
60
|
-
}
|
61
|
-
|
62
|
-
VALUE method_to_metrics(VALUE UNUSED(self), VALUE file_list) {
|
63
|
-
struct hashmap map;
|
64
|
-
hashmap_setup(&map);
|
65
|
-
|
66
|
-
if (!aggregate_files(&map, file_list)) { // all entries in map are now copies that need to be disposed
|
67
|
-
hashmap_destroy(&map);
|
68
|
-
raise_last_exception();
|
69
|
-
return Qnil;
|
70
|
-
}
|
71
|
-
|
72
|
-
entry_t **sorted_entries;
|
73
|
-
|
74
|
-
if (!sort_map_entries(&map, &sorted_entries)) {
|
75
|
-
hashmap_destroy(&map);
|
76
|
-
|
77
|
-
raise_last_exception();
|
78
|
-
return Qnil;
|
79
|
-
}
|
80
|
-
|
81
|
-
VALUE rv = rb_str_new("", 0);
|
82
|
-
if (!entries_to_string(rv, sorted_entries, hashmap_size(&map))) {
|
83
|
-
free(sorted_entries);
|
84
|
-
hashmap_destroy(&map);
|
85
|
-
|
86
|
-
raise_last_exception();
|
87
|
-
return Qnil;
|
88
|
-
}
|
89
|
-
|
90
|
-
RB_GC_GUARD(file_list); // ensure file list is not GCed before this point
|
91
|
-
free(sorted_entries);
|
92
|
-
hashmap_destroy(&map);
|
93
|
-
return rv;
|
94
|
-
}
|
95
|
-
|
96
|
-
void Init_fast_mmaped_file() {
|
97
|
-
sym_gauge = rb_intern("gauge");
|
98
|
-
sym_min = rb_intern("min");
|
99
|
-
sym_max = rb_intern("max");
|
100
|
-
sym_livesum = rb_intern("livesum");
|
101
|
-
sym_pid = rb_intern("pid");
|
102
|
-
sym_samples = rb_intern("samples");
|
103
|
-
|
104
|
-
prom_eParsingError = rb_define_class("PrometheusParsingError", rb_eRuntimeError);
|
105
|
-
|
106
|
-
MMAPED_FILE = rb_define_class("FastMmapedFile", rb_cObject);
|
107
|
-
rb_define_const(MMAPED_FILE, "MAP_SHARED", INT2FIX(MAP_SHARED));
|
108
|
-
|
109
|
-
rb_define_singleton_method(MMAPED_FILE, "to_metrics", method_to_metrics, 1);
|
110
|
-
|
111
|
-
rb_define_alloc_func(MMAPED_FILE, mm_s_alloc);
|
112
|
-
rb_define_singleton_method(MMAPED_FILE, "new", mm_s_new, -1);
|
113
|
-
rb_define_method(MMAPED_FILE, "initialize", mm_init, 1);
|
114
|
-
rb_define_method(MMAPED_FILE, "slice", mm_aref_m, -1);
|
115
|
-
rb_define_method(MMAPED_FILE, "sync", mm_msync, -1);
|
116
|
-
rb_define_method(MMAPED_FILE, "munmap", mm_unmap, 0);
|
117
|
-
|
118
|
-
rb_define_method(MMAPED_FILE, "used", method_load_used, 0);
|
119
|
-
rb_define_method(MMAPED_FILE, "used=", method_save_used, 1);
|
120
|
-
rb_define_method(MMAPED_FILE, "fetch_entry", method_fetch_entry, 3);
|
121
|
-
rb_define_method(MMAPED_FILE, "upsert_entry", method_upsert_entry, 3);
|
122
|
-
}
|