cmetrics 0.2.0.1 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/linux.yml +2 -2
- data/.github/workflows/macos.yml +2 -2
- data/.github/workflows/windows.yml +2 -2
- data/cmetrics-ruby.gemspec +1 -2
- data/ext/cmetrics/cmetrics_c.h +0 -3
- data/ext/cmetrics/cmetrics_counter.c +3 -19
- data/ext/cmetrics/cmetrics_gauge.c +3 -19
- data/ext/cmetrics/cmetrics_serde.c +2 -59
- data/ext/cmetrics/cmetrics_untyped.c +3 -19
- data/ext/cmetrics/extconf.rb +21 -3
- data/lib/cmetrics/version.rb +1 -1
- metadata +4 -18
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2886740550218bbb68b6248676ffefa606939d2c2f6fabb5043e9b08f2cb152f
|
4
|
+
data.tar.gz: 4b73350710d2c56349fdb83af9e45565e4e38cffb62f48344f25244c27688cce
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0e93ebcde84cfd9c2835f68516891f6616c3c77785b789d195c3bf0fe2d5b384314c700f34413f640680da91190cbe16f03961f540dd326515647dc754237265
|
7
|
+
data.tar.gz: b1c4c88fb1416047862f5d5027ce7c92bed28fe0e1172707fa3394af947cc320a64833ab9cbbcfa510ced7f14201ab4ea6b9958a16b5af9fd28a1be26bd00d98
|
data/.github/workflows/linux.yml
CHANGED
@@ -10,9 +10,9 @@ jobs:
|
|
10
10
|
- name: Set up Ruby
|
11
11
|
uses: ruby/setup-ruby@v1
|
12
12
|
with:
|
13
|
-
ruby-version:
|
13
|
+
ruby-version: 3.0.1
|
14
14
|
- name: Run the default task
|
15
15
|
run: |
|
16
|
-
gem install bundler -v 2.2.
|
16
|
+
gem install bundler -v 2.2.15
|
17
17
|
bundle install
|
18
18
|
bundle exec rake
|
data/.github/workflows/macos.yml
CHANGED
@@ -10,9 +10,9 @@ jobs:
|
|
10
10
|
- name: Set up Ruby
|
11
11
|
uses: ruby/setup-ruby@v1
|
12
12
|
with:
|
13
|
-
ruby-version:
|
13
|
+
ruby-version: 3.0.1
|
14
14
|
- name: Run the default task
|
15
15
|
run: |
|
16
|
-
gem install bundler -v 2.2.
|
16
|
+
gem install bundler -v 2.2.15
|
17
17
|
bundle install
|
18
18
|
bundle exec rake
|
@@ -10,9 +10,9 @@ jobs:
|
|
10
10
|
- name: Set up Ruby
|
11
11
|
uses: ruby/setup-ruby@v1
|
12
12
|
with:
|
13
|
-
ruby-version:
|
13
|
+
ruby-version: 3.0.1
|
14
14
|
- name: Run the default task
|
15
15
|
run: |
|
16
|
-
gem install bundler -v 2.2.
|
16
|
+
gem install bundler -v 2.2.15
|
17
17
|
ridk exec bundle install
|
18
18
|
ridk exec bundle exec rake
|
data/cmetrics-ruby.gemspec
CHANGED
@@ -29,7 +29,6 @@ Gem::Specification.new do |spec|
|
|
29
29
|
spec.add_development_dependency "rake", ">= 0"
|
30
30
|
spec.add_development_dependency "rake-compiler", "~> 1.0"
|
31
31
|
spec.add_development_dependency "rake-compiler-dock", "~> 1.0"
|
32
|
-
spec.add_development_dependency "msgpack", "~> 1.4.2"
|
33
32
|
|
34
|
-
spec.add_dependency 'mini_portile2', '~> 2.
|
33
|
+
spec.add_dependency 'mini_portile2', '~> 2.7'
|
35
34
|
end
|
data/ext/cmetrics/cmetrics_c.h
CHANGED
@@ -65,8 +65,5 @@ void Init_cmetrics_counter(VALUE rb_mCMetrics);
|
|
65
65
|
void Init_cmetrics_gauge(VALUE rb_mCMetrics);
|
66
66
|
void Init_cmetrics_serde(VALUE rb_mCMetrics);
|
67
67
|
void Init_cmetrics_untyped(VALUE rb_mCMetrics);
|
68
|
-
const struct CMetricsCounter *cmetrics_counter_get_ptr(VALUE rb_mCMetrics);
|
69
|
-
const struct CMetricsGauge *cmetrics_gauge_get_ptr(VALUE rb_mCMetrics);
|
70
|
-
const struct CMetricsUntyped *cmetrics_untyped_get_ptr(VALUE rb_mCMetrics);
|
71
68
|
|
72
69
|
#endif // _CMETRICS_C_H
|
@@ -34,32 +34,16 @@ static const rb_data_type_t rb_cmetrics_counter_type = { "cmetrics/counter",
|
|
34
34
|
RUBY_TYPED_FREE_IMMEDIATELY };
|
35
35
|
|
36
36
|
|
37
|
-
const struct CMetricsCounter *cmetrics_counter_get_ptr(VALUE self)
|
38
|
-
{
|
39
|
-
struct CMetricsCounter *cmetricsCounter = NULL;
|
40
|
-
|
41
|
-
TypedData_Get_Struct(
|
42
|
-
self, struct CMetricsCounter, &rb_cmetrics_counter_type, cmetricsCounter);
|
43
|
-
|
44
|
-
if (NIL_P(self)) {
|
45
|
-
rb_raise(rb_eRuntimeError, "Given CMetrics argument must not be nil");
|
46
|
-
}
|
47
|
-
if (!cmetricsCounter->counter) {
|
48
|
-
rb_raise(rb_eRuntimeError, "Create counter with CMetrics::Counter#create first.");
|
49
|
-
}
|
50
|
-
return cmetricsCounter;
|
51
|
-
}
|
52
|
-
|
53
37
|
static void
|
54
38
|
counter_free(void* ptr)
|
55
39
|
{
|
56
40
|
struct CMetricsCounter* cmetricsCounter = (struct CMetricsCounter*)ptr;
|
57
41
|
|
58
|
-
if (cmetricsCounter) {
|
59
|
-
if (cmetricsCounter->counter) {
|
42
|
+
if (!cmetricsCounter) {
|
43
|
+
if (!cmetricsCounter->counter) {
|
60
44
|
cmt_counter_destroy(cmetricsCounter->counter);
|
61
45
|
}
|
62
|
-
if (cmetricsCounter->instance) {
|
46
|
+
if (!cmetricsCounter->instance) {
|
63
47
|
cmt_destroy(cmetricsCounter->instance);
|
64
48
|
}
|
65
49
|
}
|
@@ -34,32 +34,16 @@ static const rb_data_type_t rb_cmetrics_gauge_type = { "cmetrics/gauge",
|
|
34
34
|
RUBY_TYPED_FREE_IMMEDIATELY };
|
35
35
|
|
36
36
|
|
37
|
-
const struct CMetricsGauge *cmetrics_gauge_get_ptr(VALUE self)
|
38
|
-
{
|
39
|
-
struct CMetricsGauge *cmetricsGauge = NULL;
|
40
|
-
|
41
|
-
TypedData_Get_Struct(
|
42
|
-
self, struct CMetricsGauge, &rb_cmetrics_gauge_type, cmetricsGauge);
|
43
|
-
|
44
|
-
if (NIL_P(self)) {
|
45
|
-
rb_raise(rb_eRuntimeError, "Given CMetrics argument must not be nil");
|
46
|
-
}
|
47
|
-
if (!cmetricsGauge->gauge) {
|
48
|
-
rb_raise(rb_eRuntimeError, "Create gauge with CMetrics::Gauge#create first.");
|
49
|
-
}
|
50
|
-
return cmetricsGauge;
|
51
|
-
}
|
52
|
-
|
53
37
|
static void
|
54
38
|
gauge_free(void* ptr)
|
55
39
|
{
|
56
40
|
struct CMetricsGauge* cmetricsGauge = (struct CMetricsGauge*)ptr;
|
57
41
|
|
58
|
-
if (cmetricsGauge) {
|
59
|
-
if (cmetricsGauge->gauge) {
|
42
|
+
if (!cmetricsGauge) {
|
43
|
+
if (!cmetricsGauge->gauge) {
|
60
44
|
cmt_gauge_destroy(cmetricsGauge->gauge);
|
61
45
|
}
|
62
|
-
if (cmetricsGauge->instance) {
|
46
|
+
if (!cmetricsGauge->instance) {
|
63
47
|
cmt_destroy(cmetricsGauge->instance);
|
64
48
|
}
|
65
49
|
}
|
@@ -20,14 +20,9 @@
|
|
20
20
|
#include "cmetrics_c.h"
|
21
21
|
#include <cmetrics/cmt_map.h>
|
22
22
|
#include <cmetrics/cmt_metric.h>
|
23
|
-
#include <cmetrics/cmt_cat.h>
|
24
23
|
|
25
24
|
VALUE rb_cSerde;
|
26
25
|
|
27
|
-
extern VALUE rb_cCounter;
|
28
|
-
extern VALUE rb_cGauge;
|
29
|
-
extern VALUE rb_cUntyped;
|
30
|
-
|
31
26
|
static void serde_free(void* ptr);
|
32
27
|
|
33
28
|
static const rb_data_type_t rb_cmetrics_serde_type = { "cmetrics/serde",
|
@@ -46,8 +41,8 @@ serde_free(void* ptr)
|
|
46
41
|
{
|
47
42
|
struct CMetricsSerde* cmetricsSerde = (struct CMetricsSerde*)ptr;
|
48
43
|
|
49
|
-
if (cmetricsSerde) {
|
50
|
-
if (cmetricsSerde->instance) {
|
44
|
+
if (!cmetricsSerde) {
|
45
|
+
if (!cmetricsSerde->instance) {
|
51
46
|
cmt_destroy(cmetricsSerde->instance);
|
52
47
|
}
|
53
48
|
}
|
@@ -173,41 +168,6 @@ rb_cmetrics_serde_from_msgpack_feed_each(VALUE self, VALUE rb_data)
|
|
173
168
|
}
|
174
169
|
}
|
175
170
|
|
176
|
-
static VALUE
|
177
|
-
rb_cmetrics_serde_concat_metric(VALUE self, VALUE rb_data)
|
178
|
-
{
|
179
|
-
struct CMetricsSerde* cmetricsSerde = NULL;
|
180
|
-
struct CMetricsCounter* cmetricsCounter = NULL;
|
181
|
-
struct CMetricsGauge* cmetricsGauge = NULL;
|
182
|
-
struct CMetricsUntyped* cmetricsUntyped = NULL;
|
183
|
-
|
184
|
-
TypedData_Get_Struct(
|
185
|
-
self, struct CMetricsSerde, &rb_cmetrics_serde_type, cmetricsSerde);
|
186
|
-
|
187
|
-
if (!NIL_P(rb_data)) {
|
188
|
-
if (cmetricsSerde->instance == NULL) {
|
189
|
-
cmetricsSerde->instance = cmt_create();
|
190
|
-
}
|
191
|
-
|
192
|
-
if (rb_obj_is_kind_of(rb_data, rb_cCounter)) {
|
193
|
-
cmetricsCounter = (struct CMetricsCounter *)cmetrics_counter_get_ptr(rb_data);
|
194
|
-
cmt_cat(cmetricsSerde->instance, cmetricsCounter->instance);
|
195
|
-
} else if (rb_obj_is_kind_of(rb_data, rb_cGauge)) {
|
196
|
-
cmetricsGauge = (struct CMetricsGauge *)cmetrics_gauge_get_ptr(rb_data);
|
197
|
-
cmt_cat(cmetricsSerde->instance, cmetricsGauge->instance);
|
198
|
-
} else if (rb_obj_is_kind_of(rb_data, rb_cUntyped)) {
|
199
|
-
cmetricsUntyped = (struct CMetricsUntyped *)cmetrics_untyped_get_ptr(rb_data);
|
200
|
-
cmt_cat(cmetricsSerde->instance, cmetricsUntyped->instance);
|
201
|
-
} else {
|
202
|
-
rb_raise(rb_eArgError, "specified type of instance is not supported.");
|
203
|
-
}
|
204
|
-
} else {
|
205
|
-
rb_raise(rb_eArgError, "nil is not valid value for concatenating");
|
206
|
-
}
|
207
|
-
|
208
|
-
return Qnil;
|
209
|
-
}
|
210
|
-
|
211
171
|
static VALUE
|
212
172
|
rb_cmetrics_serde_to_prometheus(VALUE self)
|
213
173
|
{
|
@@ -218,10 +178,6 @@ rb_cmetrics_serde_to_prometheus(VALUE self)
|
|
218
178
|
TypedData_Get_Struct(
|
219
179
|
self, struct CMetricsSerde, &rb_cmetrics_serde_type, cmetricsSerde);
|
220
180
|
|
221
|
-
if (cmetricsSerde->instance == NULL) {
|
222
|
-
rb_raise(rb_eRuntimeError, "Invalid cmt context");
|
223
|
-
}
|
224
|
-
|
225
181
|
prom = cmt_encode_prometheus_create(cmetricsSerde->instance, CMT_TRUE);
|
226
182
|
|
227
183
|
str = rb_str_new2(prom);
|
@@ -241,10 +197,6 @@ rb_cmetrics_serde_to_influx(VALUE self)
|
|
241
197
|
TypedData_Get_Struct(
|
242
198
|
self, struct CMetricsSerde, &rb_cmetrics_serde_type, cmetricsSerde);
|
243
199
|
|
244
|
-
if (cmetricsSerde->instance == NULL) {
|
245
|
-
rb_raise(rb_eRuntimeError, "Invalid cmt context");
|
246
|
-
}
|
247
|
-
|
248
200
|
prom = cmt_encode_influx_create(cmetricsSerde->instance);
|
249
201
|
|
250
202
|
str = rb_str_new2(prom);
|
@@ -264,10 +216,6 @@ rb_cmetrics_serde_to_msgpack(VALUE self)
|
|
264
216
|
TypedData_Get_Struct(
|
265
217
|
self, struct CMetricsSerde, &rb_cmetrics_serde_type, cmetricsSerde);
|
266
218
|
|
267
|
-
if (cmetricsSerde->instance == NULL) {
|
268
|
-
rb_raise(rb_eRuntimeError, "Invalid cmt context");
|
269
|
-
}
|
270
|
-
|
271
219
|
ret = cmt_encode_msgpack_create(cmetricsSerde->instance, &buffer, &buffer_size);
|
272
220
|
|
273
221
|
if (ret == 0) {
|
@@ -287,10 +235,6 @@ rb_cmetrics_serde_to_text(VALUE self)
|
|
287
235
|
TypedData_Get_Struct(
|
288
236
|
self, struct CMetricsSerde, &rb_cmetrics_serde_type, cmetricsSerde);
|
289
237
|
|
290
|
-
if (cmetricsSerde->instance == NULL) {
|
291
|
-
rb_raise(rb_eRuntimeError, "Invalid cmt context");
|
292
|
-
}
|
293
|
-
|
294
238
|
buffer = cmt_encode_text_create(cmetricsSerde->instance);
|
295
239
|
if (buffer == NULL) {
|
296
240
|
return Qnil;
|
@@ -455,7 +399,6 @@ void Init_cmetrics_serde(VALUE rb_mCMetrics)
|
|
455
399
|
rb_define_alloc_func(rb_cSerde, rb_cmetrics_serde_alloc);
|
456
400
|
|
457
401
|
rb_define_method(rb_cSerde, "initialize", rb_cmetrics_serde_initialize, 0);
|
458
|
-
rb_define_method(rb_cSerde, "concat", rb_cmetrics_serde_concat_metric, 1);
|
459
402
|
rb_define_method(rb_cSerde, "from_msgpack", rb_cmetrics_serde_from_msgpack, -1);
|
460
403
|
rb_define_method(rb_cSerde, "to_prometheus", rb_cmetrics_serde_to_prometheus, 0);
|
461
404
|
rb_define_method(rb_cSerde, "to_influx", rb_cmetrics_serde_to_influx, 0);
|
@@ -34,32 +34,16 @@ static const rb_data_type_t rb_cmetrics_untyped_type = { "cmetrics/untyped",
|
|
34
34
|
RUBY_TYPED_FREE_IMMEDIATELY };
|
35
35
|
|
36
36
|
|
37
|
-
const struct CMetricsUntyped *cmetrics_untyped_get_ptr(VALUE self)
|
38
|
-
{
|
39
|
-
struct CMetricsUntyped *cmetricsUntyped = NULL;
|
40
|
-
|
41
|
-
TypedData_Get_Struct(
|
42
|
-
self, struct CMetricsUntyped, &rb_cmetrics_untyped_type, cmetricsUntyped);
|
43
|
-
|
44
|
-
if (NIL_P(self)) {
|
45
|
-
rb_raise(rb_eRuntimeError, "Given CMetrics argument must not be nil");
|
46
|
-
}
|
47
|
-
if (!cmetricsUntyped->untyped) {
|
48
|
-
rb_raise(rb_eRuntimeError, "Create untyped with CMetrics::Untyped#create first.");
|
49
|
-
}
|
50
|
-
return cmetricsUntyped;
|
51
|
-
}
|
52
|
-
|
53
37
|
static void
|
54
38
|
untyped_free(void* ptr)
|
55
39
|
{
|
56
40
|
struct CMetricsUntyped* cmetricsUntyped = (struct CMetricsUntyped*)ptr;
|
57
41
|
|
58
|
-
if (cmetricsUntyped) {
|
59
|
-
if (cmetricsUntyped->untyped) {
|
42
|
+
if (!cmetricsUntyped) {
|
43
|
+
if (!cmetricsUntyped->untyped) {
|
60
44
|
cmt_untyped_destroy(cmetricsUntyped->untyped);
|
61
45
|
}
|
62
|
-
if (cmetricsUntyped->instance) {
|
46
|
+
if (!cmetricsUntyped->instance) {
|
63
47
|
cmt_destroy(cmetricsUntyped->instance);
|
64
48
|
}
|
65
49
|
}
|
data/ext/cmetrics/extconf.rb
CHANGED
@@ -13,17 +13,35 @@ def windows?
|
|
13
13
|
RUBY_PLATFORM =~ /mingw|mswin/
|
14
14
|
end
|
15
15
|
|
16
|
+
def determine_preferred_command(bin, default_bin)
|
17
|
+
printf "checking for whether %s or %s is usable... ", bin, default_bin
|
18
|
+
STDOUT.flush
|
19
|
+
bin += RbConfig::CONFIG['EXEEXT']
|
20
|
+
path = ENV['PATH'].split(RbConfig::CONFIG['PATH_SEPARATOR'])
|
21
|
+
for dir in path
|
22
|
+
file = File.join(dir, bin)
|
23
|
+
if FileTest.executable?(file)
|
24
|
+
printf "%s\n", bin
|
25
|
+
return bin
|
26
|
+
else
|
27
|
+
next
|
28
|
+
end
|
29
|
+
end
|
30
|
+
printf "%s\n", default_bin
|
31
|
+
return default_bin
|
32
|
+
end
|
33
|
+
|
16
34
|
class BuildCMetrics
|
17
35
|
|
18
36
|
attr_reader :recipe
|
19
37
|
|
20
|
-
def initialize(version=nil)
|
38
|
+
def initialize(version=nil, **kwargs)
|
21
39
|
@version = if version
|
22
40
|
version
|
23
41
|
else
|
24
42
|
"master".freeze
|
25
43
|
end
|
26
|
-
@recipe = MiniPortileCMake.new("cmetrics", @version)
|
44
|
+
@recipe = MiniPortileCMake.new("cmetrics", @version, **kwargs)
|
27
45
|
@checkpoint = ".#{@recipe.name}-#{@recipe.version}.installed"
|
28
46
|
@recipe.target = File.join(ROOT, "ports")
|
29
47
|
@recipe.files << {
|
@@ -52,7 +70,7 @@ class BuildCMetrics
|
|
52
70
|
end
|
53
71
|
end
|
54
72
|
|
55
|
-
cmetrics = BuildCMetrics.new("0.2.1")
|
73
|
+
cmetrics = BuildCMetrics.new("0.2.1", cmake_command: determine_preferred_command("cmake3", "cmake"))
|
56
74
|
cmetrics.build
|
57
75
|
|
58
76
|
libdir = RbConfig::CONFIG["libdir"]
|
data/lib/cmetrics/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cmetrics
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Hiroshi Hatake
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-09-
|
11
|
+
date: 2021-09-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -66,34 +66,20 @@ dependencies:
|
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '1.0'
|
69
|
-
- !ruby/object:Gem::Dependency
|
70
|
-
name: msgpack
|
71
|
-
requirement: !ruby/object:Gem::Requirement
|
72
|
-
requirements:
|
73
|
-
- - "~>"
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
version: 1.4.2
|
76
|
-
type: :development
|
77
|
-
prerelease: false
|
78
|
-
version_requirements: !ruby/object:Gem::Requirement
|
79
|
-
requirements:
|
80
|
-
- - "~>"
|
81
|
-
- !ruby/object:Gem::Version
|
82
|
-
version: 1.4.2
|
83
69
|
- !ruby/object:Gem::Dependency
|
84
70
|
name: mini_portile2
|
85
71
|
requirement: !ruby/object:Gem::Requirement
|
86
72
|
requirements:
|
87
73
|
- - "~>"
|
88
74
|
- !ruby/object:Gem::Version
|
89
|
-
version: '2.
|
75
|
+
version: '2.7'
|
90
76
|
type: :runtime
|
91
77
|
prerelease: false
|
92
78
|
version_requirements: !ruby/object:Gem::Requirement
|
93
79
|
requirements:
|
94
80
|
- - "~>"
|
95
81
|
- !ruby/object:Gem::Version
|
96
|
-
version: '2.
|
82
|
+
version: '2.7'
|
97
83
|
description: C binding for cmetric library.
|
98
84
|
email:
|
99
85
|
- cosmo0920.oucc@gmail.com
|