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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 47038b401644ef77b0316ac3b16340df8f7efe44ca7d5b696a1cb73615a52ef7
4
- data.tar.gz: '018de755d4db7d975b4b699b8fe67d7f19559816f1d970b595836609905c9a3c'
3
+ metadata.gz: ca751f7a0f0ce3c575014f236d8f34738723c6b64933c1fac259f9c19b13c460
4
+ data.tar.gz: 0e9b3b2a695ec555416b20d969968079943730723411076081c6e5447af632aa
5
5
  SHA512:
6
- metadata.gz: 3a5e5475285bad1a0b9e1124e5988a06490cf3a0eaed388499b1deaf91410084713a797aee99cd7bed6cde2483d7fe9fa0db471de01c38f2cfc899bfec94b87d
7
- data.tar.gz: '019ed337389e7508fe8115e1587810a4eeee9d206bac126139718af8de82bb807928afca1588987cad5a964b8f510e9c4e50768f64eba3feb8f7c757f7acbdb9'
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
- def metric_increment(name, amount = 1, attributes: nil)
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
- def metric_decrement(name, amount = 1, attributes: nil)
34
- Console.logger.info(self, name, "-= #{amount}", attributes)
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
- def metric_measure(name, amount = 1, attributes: nil)
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
@@ -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
- def metric_increment(name, amount = 1, attributes: nil)
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
- def metric_decrement(name, amount = 1, attributes: nil)
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
- def metric_measure(name, amount = 1, attributes: nil)
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
@@ -33,7 +33,6 @@ module Metrics
33
33
  if Metrics.const_defined?(:Backend)
34
34
  def self.Provider(klass, &block)
35
35
  klass.extend(Provider)
36
- klass.prepend(Backend)
37
36
 
38
37
  provider = klass.metrics_provider
39
38
  provider.prepend(Backend)
@@ -21,5 +21,5 @@
21
21
  # THE SOFTWARE.
22
22
 
23
23
  module Metrics
24
- VERSION = "0.1.0"
24
+ VERSION = "0.2.0"
25
25
  end
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.1.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-09 00:00:00.000000000 Z
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.2.22
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