metrics 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/lib/metrics/backend/console.rb +17 -4
- data/lib/metrics/backend/test.rb +55 -3
- data/lib/metrics/provider.rb +0 -1
- data/lib/metrics/version.rb +1 -1
- data.tar.gz.sig +0 -0
- metadata +3 -3
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ca751f7a0f0ce3c575014f236d8f34738723c6b64933c1fac259f9c19b13c460
|
4
|
+
data.tar.gz: 0e9b3b2a695ec555416b20d969968079943730723411076081c6e5447af632aa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ce75234031de1b6382ddb86311ea33afa4c1924f9ed14a233ff010a4a6acaf2de09a95aeda229462def77eb84d3cc831da1f3ca52e5c1d7a4376a65fb95485ad
|
7
|
+
data.tar.gz: 1392e8e3f39e800dc33b63e9e30a1ca9c15da3b03d2ed04f01393db8a07582f32afd6e15c3c203d0d0cf9a35afabdc1ca966c0ee299be4d571b134b96b20b29f
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
@@ -24,17 +24,30 @@ require 'console'
|
|
24
24
|
|
25
25
|
module Metrics
|
26
26
|
module Backend
|
27
|
+
module Register
|
28
|
+
def metric_register(name, type, **options)
|
29
|
+
Console.logger.debug(self) {"Registering metric #{name} (#{type}): #{options}."}
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def self.prepended(provider)
|
34
|
+
provider.extend(Register)
|
35
|
+
end
|
36
|
+
|
27
37
|
private
|
28
38
|
|
29
|
-
|
39
|
+
# Relative metric adjustment.
|
40
|
+
def metric_adjust(name, amount = 1, attributes: nil)
|
30
41
|
Console.logger.info(self, name, "+= #{amount}", attributes)
|
31
42
|
end
|
32
43
|
|
33
|
-
|
34
|
-
|
44
|
+
# Absolute metric assignment.
|
45
|
+
def metric_count(name, value, attributes: nil)
|
46
|
+
Console.logger.info(self, name, "= #{amount}", attributes)
|
35
47
|
end
|
36
48
|
|
37
|
-
|
49
|
+
# Relative metric measurement.
|
50
|
+
def metric_measure(name, value, attributes: nil)
|
38
51
|
Console.logger.info(self, name, "<< #{amount}", attributes)
|
39
52
|
end
|
40
53
|
end
|
data/lib/metrics/backend/test.rb
CHANGED
@@ -24,15 +24,67 @@ require 'console'
|
|
24
24
|
|
25
25
|
module Metrics
|
26
26
|
module Backend
|
27
|
+
module Register
|
28
|
+
def metric_register(name, type, description: nil, unit: nil, &block)
|
29
|
+
unless name.is_a?(String)
|
30
|
+
raise ArgumentError, "Invalid name!"
|
31
|
+
end
|
32
|
+
|
33
|
+
unless type.is_a?(Symbol)
|
34
|
+
raise ArgumentError, "Invalid type!"
|
35
|
+
end
|
36
|
+
|
37
|
+
if description
|
38
|
+
unless description.is_a?(String)
|
39
|
+
raise ArgumentError, "Invalid description!"
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
if unit
|
44
|
+
unless unit.is_a?(String)
|
45
|
+
raise ArgumentError, "Invalid unit!"
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
def self.prepended(provider)
|
52
|
+
provider.extend(Register)
|
53
|
+
end
|
54
|
+
|
27
55
|
private
|
28
56
|
|
29
|
-
|
57
|
+
# Relative metric adjustment.
|
58
|
+
def metric_adjust(name, amount = 1, attributes: nil)
|
59
|
+
unless name.is_a?(String)
|
60
|
+
raise ArgumentError, "Invalid name!"
|
61
|
+
end
|
62
|
+
|
63
|
+
unless amount.is_a?(Numeric)
|
64
|
+
raise ArgumentError, "Invalid amount!"
|
65
|
+
end
|
30
66
|
end
|
31
67
|
|
32
|
-
|
68
|
+
# Absolute metric assignment.
|
69
|
+
def metric_count(name, value, attributes: nil)
|
70
|
+
unless name.is_a?(String)
|
71
|
+
raise ArgumentError, "Invalid name!"
|
72
|
+
end
|
73
|
+
|
74
|
+
unless value.is_a?(Numeric)
|
75
|
+
raise ArgumentError, "Invalid value!"
|
76
|
+
end
|
33
77
|
end
|
34
78
|
|
35
|
-
|
79
|
+
# Relative metric measurement.
|
80
|
+
def metric_measure(name, value, attributes: nil)
|
81
|
+
unless name.is_a?(String)
|
82
|
+
raise ArgumentError, "Invalid name!"
|
83
|
+
end
|
84
|
+
|
85
|
+
unless value.is_a?(Numeric)
|
86
|
+
raise ArgumentError, "Invalid value!"
|
87
|
+
end
|
36
88
|
end
|
37
89
|
end
|
38
90
|
end
|
data/lib/metrics/provider.rb
CHANGED
data/lib/metrics/version.rb
CHANGED
data.tar.gz.sig
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: metrics
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Williams
|
@@ -36,7 +36,7 @@ cert_chain:
|
|
36
36
|
RAOsIl+HOBTb252nx1kIRN5hqQx272AJCbCjKx8egcUQKffFVVCI0nye09v5CK+a
|
37
37
|
HiLJ8VOFx6w=
|
38
38
|
-----END CERTIFICATE-----
|
39
|
-
date: 2021-10-
|
39
|
+
date: 2021-10-15 00:00:00.000000000 Z
|
40
40
|
dependencies:
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rspec
|
@@ -83,7 +83,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
83
83
|
- !ruby/object:Gem::Version
|
84
84
|
version: '0'
|
85
85
|
requirements: []
|
86
|
-
rubygems_version: 3.
|
86
|
+
rubygems_version: 3.1.6
|
87
87
|
signing_key:
|
88
88
|
specification_version: 4
|
89
89
|
summary: Application metrics and instrumentation.
|
metadata.gz.sig
CHANGED
Binary file
|