prometheus-client-mmap 0.28.0-x86_64-darwin → 1.0.0-x86_64-darwin
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 -1
- data/README.md +2 -30
- data/ext/fast_mmaped_file_rs/extconf.rb +1 -3
- data/ext/fast_mmaped_file_rs/src/error.rs +8 -0
- data/ext/fast_mmaped_file_rs/src/mmap/inner.rs +38 -23
- data/ext/fast_mmaped_file_rs/src/mmap.rs +71 -8
- data/lib/2.7/fast_mmaped_file_rs.bundle +0 -0
- data/lib/3.0/fast_mmaped_file_rs.bundle +0 -0
- data/lib/3.1/fast_mmaped_file_rs.bundle +0 -0
- data/lib/3.2/fast_mmaped_file_rs.bundle +0 -0
- data/lib/prometheus/client/configuration.rb +1 -2
- data/lib/prometheus/client/formats/text.rb +1 -12
- data/lib/prometheus/client/helper/mmaped_file.rb +3 -14
- data/lib/prometheus/client/rack/exporter.rb +1 -3
- data/lib/prometheus/client/version.rb +1 -1
- metadata +4 -46
- 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 -438
- 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/lib/2.7/fast_mmaped_file.bundle +0 -0
- data/lib/3.0/fast_mmaped_file.bundle +0 -0
- data/lib/3.1/fast_mmaped_file.bundle +0 -0
- data/lib/3.2/fast_mmaped_file.bundle +0 -0
- data/lib/prometheus/client/helper/loader.rb +0 -44
- 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
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 91aa44db80dc2fa0f04ffc719b48eaa9bf65e1928a03d26a66ec2c7b04be600e
|
4
|
+
data.tar.gz: 38de09bc8554792142e589122924f5a21e0e29d900cc4cbc72f08554b3005a0d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 29d7e3eea461653d8b16ee5357315ac2c2907cad7da59a03be680aa13053ea68a7ff40b1519777b79b44fb16051d83cfb6ab9098c178181823456c4761df3029
|
7
|
+
data.tar.gz: 604cb6fdce1c3d459070cfe64f69c214921bb0d9f94b552b441c71cf52e51d32a9ee11203a50663637e03235cdc1fd7c279462c9fc375162970d8fe653994081
|
data/.tool-versions
CHANGED
@@ -1 +1 @@
|
|
1
|
-
rust 1.
|
1
|
+
rust 1.73.0
|
data/README.md
CHANGED
@@ -53,19 +53,9 @@ http_requests.increment
|
|
53
53
|
|
54
54
|
## Rust extension
|
55
55
|
|
56
|
-
|
56
|
+
This gem now uses a rewritten Rust extension instead of C.
|
57
57
|
implementation that reads the metric files and outputs the multiprocess
|
58
|
-
metrics to text.
|
59
|
-
be built automatically. The `use_rust` keyword argument can be used:
|
60
|
-
|
61
|
-
```ruby
|
62
|
-
puts Prometheus::Client::Formats::Text.marshal_multiprocess(use_rust: true)
|
63
|
-
```
|
64
|
-
|
65
|
-
Starting with v0.26.0, `use_rust` defaults to `true`.
|
66
|
-
|
67
|
-
Note that this parameter will likely be deprecated and removed once the Rust
|
68
|
-
extension becomes the only supported mode.
|
58
|
+
metrics to text. This implementation is significantly faster than the C extension.
|
69
59
|
|
70
60
|
### Rack middleware
|
71
61
|
|
@@ -219,24 +209,6 @@ Set `prometheus_multiproc_dir` environment variable to the path where you want m
|
|
219
209
|
prometheus_multiproc_dir=/tmp
|
220
210
|
```
|
221
211
|
|
222
|
-
### Multiprocess metrics via Rust extension
|
223
|
-
|
224
|
-
By default, the Rust extension will be used to read and write multiprocess
|
225
|
-
metrics if the `fast_mmaped_file_rs` extension is available. This should
|
226
|
-
be significantly faster than the C extension.
|
227
|
-
|
228
|
-
If the environment variable `prometheus_rust_multiprocess_metrics=false`
|
229
|
-
is set or if the `rust_multiprocess_metrics` configuration setting is
|
230
|
-
`false` , the C extension will be used.
|
231
|
-
|
232
|
-
### Read and write metrics via Rust extension
|
233
|
-
|
234
|
-
By default, the Rust extension will be used to read and write metrics
|
235
|
-
from the mmaped file if the `fast_mmaped_file_rs` extension is available.
|
236
|
-
|
237
|
-
To use the C extension, set the environment variable
|
238
|
-
`prometheus_rust_mmaped_file=false`.
|
239
|
-
|
240
212
|
## Pitfalls
|
241
213
|
|
242
214
|
### PID cardinality
|
@@ -100,6 +100,13 @@ pub enum MmapError {
|
|
100
100
|
/// No mmap open.
|
101
101
|
#[error("unmapped file")]
|
102
102
|
UnmappedFile,
|
103
|
+
/// File length changed by another process.
|
104
|
+
#[error("size of {path} {len} does not match previous size {expected_len}. Another process may have modified it.")]
|
105
|
+
UnexpectedFileLength {
|
106
|
+
path: String,
|
107
|
+
len: usize,
|
108
|
+
expected_len: usize,
|
109
|
+
},
|
103
110
|
/// A custom error message with `strerror(3)` appended.
|
104
111
|
#[error("{0}")]
|
105
112
|
WithErrno(String),
|
@@ -162,6 +169,7 @@ impl MmapError {
|
|
162
169
|
MmapError::Other(_) => RubyError::Arg,
|
163
170
|
MmapError::PromParsing(_) => RubyError::PromParsing,
|
164
171
|
MmapError::UnmappedFile => RubyError::Io,
|
172
|
+
MmapError::UnexpectedFileLength { .. } => RubyError::Runtime,
|
165
173
|
MmapError::WithErrno(_) => RubyError::Io,
|
166
174
|
}
|
167
175
|
}
|
@@ -5,7 +5,7 @@ use std::fs::File;
|
|
5
5
|
use std::mem::size_of;
|
6
6
|
use std::ops::Range;
|
7
7
|
use std::os::unix::prelude::{AsRawFd, RawFd};
|
8
|
-
use std::path::PathBuf;
|
8
|
+
use std::path::{Path, PathBuf};
|
9
9
|
|
10
10
|
use crate::error::{MmapError, RubyError};
|
11
11
|
use crate::raw_entry::RawEntry;
|
@@ -34,6 +34,8 @@ pub(super) struct InnerMmap {
|
|
34
34
|
///
|
35
35
|
/// Equivalent to `i_mm->t->real` in the C implementation.
|
36
36
|
len: usize,
|
37
|
+
/// The length of the file being mmapped at the time of mapping.
|
38
|
+
file_len: usize,
|
37
39
|
}
|
38
40
|
|
39
41
|
impl InnerMmap {
|
@@ -41,19 +43,12 @@ impl InnerMmap {
|
|
41
43
|
/// Use when mmapping a file for the first time. When re-mapping a file
|
42
44
|
/// after expanding it the `reestablish` function should be used.
|
43
45
|
pub fn new(path: PathBuf, file: File) -> Result<Self> {
|
44
|
-
let
|
45
|
-
MmapError::legacy(
|
46
|
-
format!("Can't stat {}: {e}", path.display()),
|
47
|
-
RubyError::Arg,
|
48
|
-
)
|
49
|
-
})?;
|
50
|
-
|
51
|
-
let file_size = util::cast_chk::<_, usize>(stat.len(), "file length")?;
|
46
|
+
let initial_file_len = get_file_len(&path, &file)?;
|
52
47
|
|
53
48
|
// We need to ensure the underlying file descriptor is at least a page size.
|
54
49
|
// Otherwise, we could get a SIGBUS error if mmap() attempts to read or write
|
55
50
|
// past the file.
|
56
|
-
let reserve_size = Self::next_page_boundary(
|
51
|
+
let reserve_size = Self::next_page_boundary(initial_file_len)?;
|
57
52
|
|
58
53
|
// Cast: no-op.
|
59
54
|
Self::reserve_mmap_file_bytes(file.as_raw_fd(), reserve_size as off_t).map_err(|e| {
|
@@ -67,21 +62,23 @@ impl InnerMmap {
|
|
67
62
|
})?;
|
68
63
|
|
69
64
|
// Ensure we always have space for the header.
|
70
|
-
let map_len =
|
65
|
+
let map_len = initial_file_len.max(HEADER_SIZE);
|
71
66
|
|
72
67
|
// SAFETY: There is the possibility of UB if the file is modified outside of
|
73
68
|
// this program.
|
74
69
|
let map = unsafe { MmapOptions::new().len(map_len).map_mut(&file) }.map_err(|e| {
|
75
70
|
MmapError::legacy(format!("mmap failed ({}): {e}", errno()), RubyError::Arg)
|
76
71
|
})?;
|
72
|
+
let file_len = util::cast_chk::<_, usize>(reserve_size, "file length")?;
|
77
73
|
|
78
|
-
let len =
|
74
|
+
let len = initial_file_len;
|
79
75
|
|
80
76
|
Ok(Self {
|
81
77
|
file,
|
82
78
|
path,
|
83
79
|
map,
|
84
80
|
len,
|
81
|
+
file_len,
|
85
82
|
})
|
86
83
|
}
|
87
84
|
|
@@ -97,12 +94,14 @@ impl InnerMmap {
|
|
97
94
|
// to the old length at this point if closing the file. Matching C implementation
|
98
95
|
// for now.
|
99
96
|
let len = map_len;
|
97
|
+
let file_len = get_file_len(&path, &file)?;
|
100
98
|
|
101
99
|
Ok(Self {
|
102
100
|
file,
|
103
101
|
path,
|
104
102
|
map,
|
105
103
|
len,
|
104
|
+
file_len,
|
106
105
|
})
|
107
106
|
}
|
108
107
|
|
@@ -186,7 +185,7 @@ impl InnerMmap {
|
|
186
185
|
self.len
|
187
186
|
}
|
188
187
|
|
189
|
-
/// The total length in bytes of the mmapped file.
|
188
|
+
/// The total length in bytes of the mmapped region of the file.
|
190
189
|
///
|
191
190
|
/// Equivalent to `i_mm->t->len` in the C implementation.
|
192
191
|
#[inline]
|
@@ -194,6 +193,21 @@ impl InnerMmap {
|
|
194
193
|
self.map.len()
|
195
194
|
}
|
196
195
|
|
196
|
+
/// `stat` the mmapped file and return its length.
|
197
|
+
pub fn check_file_len(&self) -> Result<usize> {
|
198
|
+
get_file_len(&self.path, &self.file)
|
199
|
+
}
|
200
|
+
|
201
|
+
/// The length of the file at the time it was mmapped.
|
202
|
+
pub fn file_len(&self) -> usize {
|
203
|
+
self.file_len
|
204
|
+
}
|
205
|
+
|
206
|
+
/// The path of the mmapped file.
|
207
|
+
pub fn path(&self) -> String {
|
208
|
+
self.path.to_string_lossy().to_string()
|
209
|
+
}
|
210
|
+
|
197
211
|
/// Update the length of the mmap considered to be written.
|
198
212
|
pub fn set_len(&mut self, len: usize) {
|
199
213
|
self.len = len;
|
@@ -224,16 +238,6 @@ impl InnerMmap {
|
|
224
238
|
}
|
225
239
|
}
|
226
240
|
|
227
|
-
/// Truncate the mmapped file to the end of the metrics data.
|
228
|
-
pub fn truncate_file(&mut self) -> Result<()> {
|
229
|
-
// CAST: no-op on 64-bit, widening on 32-bit.
|
230
|
-
let trunc_len = self.len as u64;
|
231
|
-
|
232
|
-
self.file
|
233
|
-
.set_len(trunc_len)
|
234
|
-
.map_err(|e| MmapError::legacy(format!("truncate: {e}"), RubyError::Type))
|
235
|
-
}
|
236
|
-
|
237
241
|
/// Load the `used` header containing the size of the metrics data written.
|
238
242
|
pub fn load_used(&self) -> Result<u32> {
|
239
243
|
match read_u32(self.map.as_ref(), 0) {
|
@@ -322,6 +326,17 @@ impl InnerMmap {
|
|
322
326
|
}
|
323
327
|
}
|
324
328
|
|
329
|
+
fn get_file_len(path: &Path, file: &File) -> Result<usize> {
|
330
|
+
let stat = file.metadata().map_err(|e| {
|
331
|
+
MmapError::legacy(
|
332
|
+
format!("Can't stat {}: {e}", path.display()),
|
333
|
+
RubyError::Arg,
|
334
|
+
)
|
335
|
+
})?;
|
336
|
+
|
337
|
+
util::cast_chk::<_, usize>(stat.len(), "file length")
|
338
|
+
}
|
339
|
+
|
325
340
|
#[cfg(test)]
|
326
341
|
mod test {
|
327
342
|
use nix::unistd::{self, SysconfVar};
|
@@ -225,9 +225,6 @@ impl MmapedFile {
|
|
225
225
|
let rs_self = &*rb_self;
|
226
226
|
|
227
227
|
rs_self.inner_mut(|inner| {
|
228
|
-
// truncate file to actual used size
|
229
|
-
inner.truncate_file()?;
|
230
|
-
|
231
228
|
// We are about to release the backing mmap for Ruby's String
|
232
229
|
// objects. If Ruby attempts to read from them the program will
|
233
230
|
// segfault. We update the length of all Strings to zero so Ruby
|
@@ -444,17 +441,49 @@ impl MmapedFile {
|
|
444
441
|
}
|
445
442
|
|
446
443
|
/// Check that the mmap is large enough to contain the value to be added,
|
447
|
-
/// and expand it to fit if necessary.
|
444
|
+
/// and expand it to fit if necessary. Will return an error if the file
|
445
|
+
/// has been resized by another process.
|
448
446
|
fn check_expand(&self, rb_self: Obj<Self>, key_len: usize) -> magnus::error::Result<()> {
|
449
447
|
// CAST: no-op on 32-bit, widening on 64-bit.
|
450
448
|
let used = self.inner(|inner| inner.load_used())? as usize;
|
451
449
|
let entry_len = RawEntry::calc_total_len(key_len)?;
|
450
|
+
let required_len = used.add_chk(entry_len)?;
|
451
|
+
let mut target_cap = self.capacity();
|
452
452
|
|
453
|
+
let mut needs_resize = false;
|
453
454
|
// We need the mmapped region to contain at least one byte beyond the
|
454
|
-
// written data to create a NUL-
|
455
|
-
// new length does not exactly match
|
456
|
-
|
457
|
-
|
455
|
+
// written data to create a NUL-terminated C string. Validate that
|
456
|
+
// new length does not exactly match the length of the mmap.
|
457
|
+
if target_cap <= required_len {
|
458
|
+
needs_resize = true;
|
459
|
+
target_cap = required_len + 1;
|
460
|
+
}
|
461
|
+
|
462
|
+
let (current_file_len, original_file_len) =
|
463
|
+
self.inner(|inner| Ok((inner.check_file_len()?, inner.file_len())))?;
|
464
|
+
|
465
|
+
let file_modified = current_file_len != original_file_len;
|
466
|
+
if file_modified {
|
467
|
+
// Ensure our new capacity is at least as large as the actual file.
|
468
|
+
// Erroring out without first resizing the mmap would leave us stuck
|
469
|
+
// in a bad state.
|
470
|
+
target_cap = current_file_len
|
471
|
+
}
|
472
|
+
|
473
|
+
if needs_resize {
|
474
|
+
self.expand_to_fit(rb_self, target_cap)?;
|
475
|
+
}
|
476
|
+
|
477
|
+
if file_modified {
|
478
|
+
// Return an error so the caller is alerted that there were concurrent writes to the
|
479
|
+
// file.
|
480
|
+
let path = self.inner(|inner| Ok(inner.path()))?;
|
481
|
+
return Err(MmapError::UnexpectedFileLength {
|
482
|
+
path,
|
483
|
+
len: current_file_len,
|
484
|
+
expected_len: original_file_len,
|
485
|
+
}
|
486
|
+
.into());
|
458
487
|
}
|
459
488
|
|
460
489
|
Ok(())
|
@@ -655,6 +684,7 @@ mod test {
|
|
655
684
|
use super::*;
|
656
685
|
use crate::raw_entry::RawEntry;
|
657
686
|
use crate::testhelper::TestFile;
|
687
|
+
use std::os::unix::prelude::AsRawFd;
|
658
688
|
|
659
689
|
/// Create a wrapped MmapedFile object.
|
660
690
|
fn create_obj() -> Obj<MmapedFile> {
|
@@ -884,4 +914,37 @@ mod test {
|
|
884
914
|
// Validate that we have expanded the mmap, ensuring a trailing NUL.
|
885
915
|
assert!(rs_self.capacity() > current_cap);
|
886
916
|
}
|
917
|
+
|
918
|
+
#[test]
|
919
|
+
fn test_detect_external_resize() {
|
920
|
+
let _cleanup = unsafe { magnus::embed::init() };
|
921
|
+
let ruby = magnus::Ruby::get().unwrap();
|
922
|
+
crate::init(&ruby).unwrap();
|
923
|
+
|
924
|
+
let TestFile {
|
925
|
+
file,
|
926
|
+
path,
|
927
|
+
dir: _dir,
|
928
|
+
} = TestFile::new(&[0u8; 8]);
|
929
|
+
|
930
|
+
let path_str = path.display().to_string();
|
931
|
+
let rpath = RString::new(&path_str);
|
932
|
+
|
933
|
+
// Object created successfully
|
934
|
+
let result: std::result::Result<Obj<MmapedFile>, Error> =
|
935
|
+
eval!("FastMmapedFileRs.new(path)", path = rpath);
|
936
|
+
assert!(result.is_ok());
|
937
|
+
let obj = result.unwrap();
|
938
|
+
|
939
|
+
let rs_self = &*obj;
|
940
|
+
|
941
|
+
let file_len = 1 << 32;
|
942
|
+
nix::unistd::ftruncate(file.as_raw_fd(), file_len).unwrap();
|
943
|
+
|
944
|
+
// We error when the file is externally modified.
|
945
|
+
assert!(rs_self.check_expand(obj, 512).is_err());
|
946
|
+
|
947
|
+
// We updated the object to use the new size.
|
948
|
+
assert_eq!(rs_self.capacity(), file_len as usize);
|
949
|
+
}
|
887
950
|
}
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -7,14 +7,13 @@ require 'tmpdir'
|
|
7
7
|
module Prometheus
|
8
8
|
module Client
|
9
9
|
class Configuration
|
10
|
-
attr_accessor :value_class, :multiprocess_files_dir, :initial_mmap_file_size, :logger, :pid_provider
|
10
|
+
attr_accessor :value_class, :multiprocess_files_dir, :initial_mmap_file_size, :logger, :pid_provider
|
11
11
|
|
12
12
|
def initialize
|
13
13
|
@value_class = ::Prometheus::Client::MmapedValue
|
14
14
|
@initial_mmap_file_size = ::Prometheus::Client::PageSize.page_size(fallback_page_size: 4096)
|
15
15
|
@logger = Logger.new($stdout)
|
16
16
|
@pid_provider = Process.method(:pid)
|
17
|
-
@rust_multiprocess_metrics = ENV.fetch('prometheus_rust_multiprocess_metrics', 'true') == 'true'
|
18
17
|
@multiprocess_files_dir = ENV.fetch('prometheus_multiproc_dir') do
|
19
18
|
Dir.mktmpdir("prometheus-mmap")
|
20
19
|
end
|
@@ -1,6 +1,5 @@
|
|
1
1
|
require 'prometheus/client/uses_value_type'
|
2
2
|
require 'prometheus/client/helper/json_parser'
|
3
|
-
require 'prometheus/client/helper/loader'
|
4
3
|
require 'prometheus/client/helper/plain_file'
|
5
4
|
require 'prometheus/client/helper/metrics_processing'
|
6
5
|
require 'prometheus/client/helper/metrics_representation'
|
@@ -27,22 +26,12 @@ module Prometheus
|
|
27
26
|
Helper::MetricsRepresentation.to_text(metrics)
|
28
27
|
end
|
29
28
|
|
30
|
-
def marshal_multiprocess(path = Prometheus::Client.configuration.multiprocess_files_dir
|
29
|
+
def marshal_multiprocess(path = Prometheus::Client.configuration.multiprocess_files_dir)
|
31
30
|
file_list = Dir.glob(File.join(path, '*.db')).sort
|
32
31
|
.map {|f| Helper::PlainFile.new(f) }
|
33
32
|
.map {|f| [f.filepath, f.multiprocess_mode.to_sym, f.type.to_sym, f.pid] }
|
34
33
|
|
35
|
-
if use_rust && Prometheus::Client::Helper::Loader.rust_impl_available?
|
36
34
|
FastMmapedFileRs.to_metrics(file_list.to_a)
|
37
|
-
else
|
38
|
-
FastMmapedFile.to_metrics(file_list.to_a)
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
def rust_impl_available?
|
43
|
-
return @rust_available unless @rust_available.nil?
|
44
|
-
|
45
|
-
check_for_rust
|
46
35
|
end
|
47
36
|
|
48
37
|
private
|
@@ -1,29 +1,18 @@
|
|
1
1
|
require 'prometheus/client/helper/entry_parser'
|
2
2
|
require 'prometheus/client/helper/file_locker'
|
3
|
-
require 'prometheus/client/helper/loader'
|
4
3
|
|
5
4
|
# load precompiled extension if available
|
6
5
|
begin
|
7
6
|
ruby_version = /(\d+\.\d+)/.match(RUBY_VERSION)
|
8
|
-
require_relative "../../../#{ruby_version}/
|
7
|
+
require_relative "../../../#{ruby_version}/fast_mmaped_file_rs"
|
9
8
|
rescue LoadError
|
10
|
-
require '
|
9
|
+
require 'fast_mmaped_file_rs'
|
11
10
|
end
|
12
11
|
|
13
12
|
module Prometheus
|
14
13
|
module Client
|
15
14
|
module Helper
|
16
|
-
|
17
|
-
if (ENV.fetch('prometheus_rust_mmaped_file', 'true') == "true" &&
|
18
|
-
Prometheus::Client::Helper::Loader.rust_impl_available?)
|
19
|
-
class MmapedFile < FastMmapedFileRs
|
20
|
-
end
|
21
|
-
else
|
22
|
-
class MmapedFile < FastMmapedFile
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
class MmapedFile
|
15
|
+
class MmapedFile < FastMmapedFileRs
|
27
16
|
include EntryParser
|
28
17
|
|
29
18
|
attr_reader :filepath, :size
|
@@ -62,10 +62,8 @@ module Prometheus
|
|
62
62
|
end
|
63
63
|
|
64
64
|
def respond_with(format)
|
65
|
-
rust_enabled = Prometheus::Client.configuration.rust_multiprocess_metrics
|
66
|
-
|
67
65
|
response = if Prometheus::Client.configuration.value_class.multiprocess
|
68
|
-
format.marshal_multiprocess
|
66
|
+
format.marshal_multiprocess
|
69
67
|
else
|
70
68
|
format.marshal
|
71
69
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: prometheus-client-mmap
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: x86_64-darwin
|
6
6
|
authors:
|
7
7
|
- Tobias Schmidt
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2023-
|
14
|
+
date: 2023-11-15 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: rb_sys
|
@@ -129,23 +129,6 @@ extra_rdoc_files: []
|
|
129
129
|
files:
|
130
130
|
- ".tool-versions"
|
131
131
|
- README.md
|
132
|
-
- ext/fast_mmaped_file/extconf.rb
|
133
|
-
- ext/fast_mmaped_file/fast_mmaped_file.c
|
134
|
-
- ext/fast_mmaped_file/file_format.c
|
135
|
-
- ext/fast_mmaped_file/file_format.h
|
136
|
-
- ext/fast_mmaped_file/file_parsing.c
|
137
|
-
- ext/fast_mmaped_file/file_parsing.h
|
138
|
-
- ext/fast_mmaped_file/file_reading.c
|
139
|
-
- ext/fast_mmaped_file/file_reading.h
|
140
|
-
- ext/fast_mmaped_file/globals.h
|
141
|
-
- ext/fast_mmaped_file/mmap.c
|
142
|
-
- ext/fast_mmaped_file/mmap.h
|
143
|
-
- ext/fast_mmaped_file/rendering.c
|
144
|
-
- ext/fast_mmaped_file/rendering.h
|
145
|
-
- ext/fast_mmaped_file/utils.c
|
146
|
-
- ext/fast_mmaped_file/utils.h
|
147
|
-
- ext/fast_mmaped_file/value_access.c
|
148
|
-
- ext/fast_mmaped_file/value_access.h
|
149
132
|
- ext/fast_mmaped_file_rs/.cargo/config.toml
|
150
133
|
- ext/fast_mmaped_file_rs/Cargo.lock
|
151
134
|
- ext/fast_mmaped_file_rs/Cargo.toml
|
@@ -163,13 +146,9 @@ files:
|
|
163
146
|
- ext/fast_mmaped_file_rs/src/raw_entry.rs
|
164
147
|
- ext/fast_mmaped_file_rs/src/testhelper.rs
|
165
148
|
- ext/fast_mmaped_file_rs/src/util.rs
|
166
|
-
- lib/2.7/fast_mmaped_file.bundle
|
167
149
|
- lib/2.7/fast_mmaped_file_rs.bundle
|
168
|
-
- lib/3.0/fast_mmaped_file.bundle
|
169
150
|
- lib/3.0/fast_mmaped_file_rs.bundle
|
170
|
-
- lib/3.1/fast_mmaped_file.bundle
|
171
151
|
- lib/3.1/fast_mmaped_file_rs.bundle
|
172
|
-
- lib/3.2/fast_mmaped_file.bundle
|
173
152
|
- lib/3.2/fast_mmaped_file_rs.bundle
|
174
153
|
- lib/prometheus.rb
|
175
154
|
- lib/prometheus/client.rb
|
@@ -180,7 +159,6 @@ files:
|
|
180
159
|
- lib/prometheus/client/helper/entry_parser.rb
|
181
160
|
- lib/prometheus/client/helper/file_locker.rb
|
182
161
|
- lib/prometheus/client/helper/json_parser.rb
|
183
|
-
- lib/prometheus/client/helper/loader.rb
|
184
162
|
- lib/prometheus/client/helper/metrics_processing.rb
|
185
163
|
- lib/prometheus/client/helper/metrics_representation.rb
|
186
164
|
- lib/prometheus/client/helper/mmaped_file.rb
|
@@ -201,26 +179,6 @@ files:
|
|
201
179
|
- lib/prometheus/client/support/unicorn.rb
|
202
180
|
- lib/prometheus/client/uses_value_type.rb
|
203
181
|
- lib/prometheus/client/version.rb
|
204
|
-
- vendor/c/hashmap/.gitignore
|
205
|
-
- vendor/c/hashmap/LICENSE
|
206
|
-
- vendor/c/hashmap/README.md
|
207
|
-
- vendor/c/hashmap/_config.yml
|
208
|
-
- vendor/c/hashmap/src/hashmap.c
|
209
|
-
- vendor/c/hashmap/src/hashmap.h
|
210
|
-
- vendor/c/hashmap/test/Makefile
|
211
|
-
- vendor/c/hashmap/test/hashmap_test.c
|
212
|
-
- vendor/c/jsmn/.travis.yml
|
213
|
-
- vendor/c/jsmn/LICENSE
|
214
|
-
- vendor/c/jsmn/Makefile
|
215
|
-
- vendor/c/jsmn/README.md
|
216
|
-
- vendor/c/jsmn/example/jsondump.c
|
217
|
-
- vendor/c/jsmn/example/simple.c
|
218
|
-
- vendor/c/jsmn/jsmn.c
|
219
|
-
- vendor/c/jsmn/jsmn.h
|
220
|
-
- vendor/c/jsmn/library.json
|
221
|
-
- vendor/c/jsmn/test/test.h
|
222
|
-
- vendor/c/jsmn/test/tests.c
|
223
|
-
- vendor/c/jsmn/test/testutil.h
|
224
182
|
homepage: https://gitlab.com/gitlab-org/prometheus-client-mmap
|
225
183
|
licenses:
|
226
184
|
- Apache-2.0
|
@@ -246,6 +204,6 @@ requirements: []
|
|
246
204
|
rubygems_version: 3.4.4
|
247
205
|
signing_key:
|
248
206
|
specification_version: 4
|
249
|
-
summary: A suite of instrumentation metric
|
250
|
-
web services interface.
|
207
|
+
summary: A suite of instrumentation metric primitives that can be exposed through
|
208
|
+
a web services interface.
|
251
209
|
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')
|