prometheus-client-mmap 0.10.0 → 0.14.0
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 +4 -4
- data/ext/fast_mmaped_file/fast_mmaped_file.c +5 -8
- data/ext/fast_mmaped_file/file_parsing.c +2 -2
- data/ext/fast_mmaped_file/file_parsing.h +1 -0
- data/ext/fast_mmaped_file/file_reading.c +2 -2
- data/ext/fast_mmaped_file/mmap.c +3 -15
- data/ext/fast_mmaped_file/rendering.c +2 -1
- data/ext/fast_mmaped_file/utils.c +2 -3
- data/ext/fast_mmaped_file/utils.h +1 -0
- data/ext/fast_mmaped_file/value_access.c +2 -4
- data/ext/fast_mmaped_file/value_access.h +1 -0
- data/lib/fast_mmaped_file.bundle +0 -0
- data/lib/prometheus/client/gauge.rb +4 -0
- data/lib/prometheus/client/mmaped_dict.rb +4 -0
- data/lib/prometheus/client/mmaped_value.rb +4 -0
- data/lib/prometheus/client/push.rb +40 -17
- data/lib/prometheus/client/simple_value.rb +4 -0
- data/lib/prometheus/client/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5bf5a74fabdf7eb344213edc641c57dab7c97bcaad23f5ba45883837f01c9d27
|
4
|
+
data.tar.gz: 9c86ca31dd3e32812a8ce97c13d1f3674f59169b50f0f46b762bf295b8ed33c0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e3f14c13416a92d5dc621f1d10ad3a5477dd7ee8169613bbf68b5281490c6f8d44af6ac8964c25aaa5847f938196936e0008d655a5bfbad2503295961a05b41a
|
7
|
+
data.tar.gz: f119065ea9ac2bef25cdc1ae92ba784cf0486c32639b47874db815fde359166900ce67adf35d7e003a66d0993fe913afbbfc6fa1f0b7abed48a60a346d5ea52e
|
@@ -1,20 +1,17 @@
|
|
1
1
|
#include <errno.h>
|
2
|
+
#include <hashmap.h>
|
3
|
+
#include <jsmn.h>
|
2
4
|
#include <ruby.h>
|
3
5
|
#include <ruby/intern.h>
|
4
|
-
|
5
6
|
#include <sys/mman.h>
|
6
7
|
|
7
|
-
#include <hashmap.h>
|
8
|
-
#include <jsmn.h>
|
9
|
-
|
10
|
-
#include "globals.h"
|
11
|
-
#include "utils.h"
|
12
|
-
#include "value_access.h"
|
13
|
-
|
14
8
|
#include "file_parsing.h"
|
15
9
|
#include "file_reading.h"
|
10
|
+
#include "globals.h"
|
16
11
|
#include "mmap.h"
|
17
12
|
#include "rendering.h"
|
13
|
+
#include "utils.h"
|
14
|
+
#include "value_access.h"
|
18
15
|
|
19
16
|
VALUE MMAPED_FILE = Qnil;
|
20
17
|
|
data/ext/fast_mmaped_file/mmap.c
CHANGED
@@ -1,11 +1,11 @@
|
|
1
|
+
#include "mmap.h"
|
2
|
+
|
1
3
|
#include <errno.h>
|
2
4
|
#include <fcntl.h>
|
3
|
-
#include <ruby.h>
|
4
5
|
#include <ruby/util.h>
|
5
6
|
#include <sys/mman.h>
|
6
7
|
|
7
8
|
#include "file_format.h"
|
8
|
-
#include "mmap.h"
|
9
9
|
#include "utils.h"
|
10
10
|
|
11
11
|
#if 0
|
@@ -42,12 +42,8 @@ static VALUE mm_str(VALUE obj, int modify) {
|
|
42
42
|
GET_MMAP(obj, i_mm, modify & ~MM_ORIGIN);
|
43
43
|
if (modify & MM_MODIFY) {
|
44
44
|
if (i_mm->t->flag & MM_FROZEN) rb_error_frozen("mmap");
|
45
|
-
if (!OBJ_TAINTED(ret) && rb_safe_level() >= 4) rb_raise(rb_eSecurityError, "Insecure: can't modify mmap");
|
46
45
|
}
|
47
46
|
ret = rb_obj_alloc(rb_cString);
|
48
|
-
if (rb_obj_tainted(obj)) {
|
49
|
-
OBJ_TAINT(ret);
|
50
|
-
}
|
51
47
|
RSTRING(ret)->as.heap.ptr = i_mm->t->addr;
|
52
48
|
RSTRING(ret)->as.heap.aux.capa = i_mm->t->len;
|
53
49
|
RSTRING(ret)->as.heap.len = i_mm->t->real;
|
@@ -216,13 +212,6 @@ VALUE mm_init(VALUE obj, VALUE fname) {
|
|
216
212
|
SafeStringValue(fname);
|
217
213
|
path = StringValuePtr(fname);
|
218
214
|
|
219
|
-
{
|
220
|
-
if (rb_safe_level() > 0 && OBJ_TAINTED(fname)) {
|
221
|
-
rb_raise(rb_eSecurityError, "Insecure operation");
|
222
|
-
}
|
223
|
-
rb_secure(1);
|
224
|
-
}
|
225
|
-
|
226
215
|
vscope = MAP_SHARED;
|
227
216
|
size = 0;
|
228
217
|
perm = 0666;
|
@@ -257,7 +246,7 @@ VALUE mm_init(VALUE obj, VALUE fname) {
|
|
257
246
|
|
258
247
|
if (reserve_mmap_file_bytes(fd, reserve_size) != 0) {
|
259
248
|
close(fd);
|
260
|
-
rb_raise(rb_eIOError, "Can't reserve %zu bytes for memory-mapped file", reserve_size);
|
249
|
+
rb_raise(rb_eIOError, "Can't reserve %zu bytes for memory-mapped file in %s", reserve_size, path);
|
261
250
|
}
|
262
251
|
|
263
252
|
addr = mmap(0, size, pmode, vscope, fd, offset);
|
@@ -280,7 +269,6 @@ VALUE mm_init(VALUE obj, VALUE fname) {
|
|
280
269
|
if (smode == O_WRONLY) {
|
281
270
|
i_mm->t->flag |= MM_FIXED;
|
282
271
|
}
|
283
|
-
OBJ_TAINT(obj);
|
284
272
|
return obj;
|
285
273
|
}
|
286
274
|
|
@@ -1,15 +1,13 @@
|
|
1
|
-
#include
|
2
|
-
#include <ruby/intern.h>
|
1
|
+
#include "value_access.h"
|
3
2
|
|
4
3
|
#include <errno.h>
|
5
4
|
#include <fcntl.h>
|
5
|
+
#include <ruby/intern.h>
|
6
6
|
#include <sys/mman.h>
|
7
7
|
#include <unistd.h>
|
8
8
|
|
9
9
|
#include "file_format.h"
|
10
10
|
#include "mmap.h"
|
11
|
-
#include "value_access.h"
|
12
|
-
|
13
11
|
#include "utils.h"
|
14
12
|
|
15
13
|
static void close_file(mm_ipc *i_mm) {
|
data/lib/fast_mmaped_file.bundle
CHANGED
Binary file
|
@@ -1,7 +1,9 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
|
3
|
+
require 'thread'
|
3
4
|
require 'net/http'
|
4
5
|
require 'uri'
|
6
|
+
require 'erb'
|
5
7
|
|
6
8
|
require 'prometheus/client'
|
7
9
|
require 'prometheus/client/formats/text'
|
@@ -13,31 +15,45 @@ module Prometheus
|
|
13
15
|
# Pushgateway.
|
14
16
|
class Push
|
15
17
|
DEFAULT_GATEWAY = 'http://localhost:9091'.freeze
|
16
|
-
PATH = '/metrics/
|
17
|
-
INSTANCE_PATH = '/metrics/
|
18
|
-
|
18
|
+
PATH = '/metrics/job/%s'.freeze
|
19
|
+
INSTANCE_PATH = '/metrics/job/%s/instance/%s'.freeze
|
20
|
+
SUPPORTED_SCHEMES = %w(http https).freeze
|
19
21
|
|
20
22
|
attr_reader :job, :instance, :gateway, :path
|
21
23
|
|
22
|
-
def initialize(job
|
24
|
+
def initialize(job:, instance: nil, gateway: DEFAULT_GATEWAY, **kwargs)
|
25
|
+
raise ArgumentError, "job cannot be nil" if job.nil?
|
26
|
+
raise ArgumentError, "job cannot be empty" if job.empty?
|
27
|
+
|
28
|
+
@mutex = Mutex.new
|
23
29
|
@job = job
|
24
30
|
@instance = instance
|
25
31
|
@gateway = gateway || DEFAULT_GATEWAY
|
26
|
-
@uri = parse(@gateway)
|
27
32
|
@path = build_path(job, instance)
|
33
|
+
@uri = parse("#{@gateway}#{@path}")
|
34
|
+
|
28
35
|
@http = Net::HTTP.new(@uri.host, @uri.port)
|
36
|
+
@http.use_ssl = (@uri.scheme == 'https')
|
37
|
+
@http.open_timeout = kwargs[:open_timeout] if kwargs[:open_timeout]
|
38
|
+
@http.read_timeout = kwargs[:read_timeout] if kwargs[:read_timeout]
|
29
39
|
end
|
30
40
|
|
31
41
|
def add(registry)
|
32
|
-
|
42
|
+
synchronize do
|
43
|
+
request(Net::HTTP::Post, registry)
|
44
|
+
end
|
33
45
|
end
|
34
46
|
|
35
47
|
def replace(registry)
|
36
|
-
|
48
|
+
synchronize do
|
49
|
+
request(Net::HTTP::Put, registry)
|
50
|
+
end
|
37
51
|
end
|
38
52
|
|
39
53
|
def delete
|
40
|
-
|
54
|
+
synchronize do
|
55
|
+
request(Net::HTTP::Delete)
|
56
|
+
end
|
41
57
|
end
|
42
58
|
|
43
59
|
private
|
@@ -45,27 +61,34 @@ module Prometheus
|
|
45
61
|
def parse(url)
|
46
62
|
uri = URI.parse(url)
|
47
63
|
|
48
|
-
|
49
|
-
uri
|
50
|
-
else
|
64
|
+
unless SUPPORTED_SCHEMES.include?(uri.scheme)
|
51
65
|
raise ArgumentError, 'only HTTP gateway URLs are supported currently.'
|
52
66
|
end
|
67
|
+
|
68
|
+
uri
|
53
69
|
rescue URI::InvalidURIError => e
|
54
70
|
raise ArgumentError, "#{url} is not a valid URL: #{e}"
|
55
71
|
end
|
56
72
|
|
57
73
|
def build_path(job, instance)
|
58
|
-
if instance
|
59
|
-
format(INSTANCE_PATH,
|
74
|
+
if instance && !instance.empty?
|
75
|
+
format(INSTANCE_PATH, ERB::Util::url_encode(job), ERB::Util::url_encode(instance))
|
60
76
|
else
|
61
|
-
format(PATH,
|
77
|
+
format(PATH, ERB::Util::url_encode(job))
|
62
78
|
end
|
63
79
|
end
|
64
80
|
|
65
|
-
def request(
|
66
|
-
|
81
|
+
def request(req_class, registry = nil)
|
82
|
+
req = req_class.new(@uri)
|
83
|
+
req.content_type = Formats::Text::CONTENT_TYPE
|
84
|
+
req.basic_auth(@uri.user, @uri.password) if @uri.user
|
85
|
+
req.body = Formats::Text.marshal(registry) if registry
|
86
|
+
|
87
|
+
@http.request(req)
|
88
|
+
end
|
67
89
|
|
68
|
-
|
90
|
+
def synchronize
|
91
|
+
@mutex.synchronize { yield }
|
69
92
|
end
|
70
93
|
end
|
71
94
|
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: 0.14.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tobias Schmidt
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2021-08-25 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: fuzzbert
|
@@ -181,7 +181,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
181
181
|
- !ruby/object:Gem::Version
|
182
182
|
version: '0'
|
183
183
|
requirements: []
|
184
|
-
rubygems_version: 3.
|
184
|
+
rubygems_version: 3.1.4
|
185
185
|
signing_key:
|
186
186
|
specification_version: 4
|
187
187
|
summary: A suite of instrumentation metric primitivesthat can be exposed through a
|