metrics 0.5.0 → 0.6.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: e702c99fcc40f6be98ab5cab1d6ff490fbcd6bd6cf1d792a643f45573c4cd710
4
- data.tar.gz: 35ec716809e70775717f18bc10a4f70165cad91a1bbd076b200f847c812c764c
3
+ metadata.gz: 3775c730581fa1814523cea022ac4bbbcf5b1cb3f52e0d2f35dd667d521675eb
4
+ data.tar.gz: a8b3e43df8a40894e91112ee7e3c0d9743628a4b7f191cd4263b064283c21c30
5
5
  SHA512:
6
- metadata.gz: bc4627290512e876360564aae30dc4319cd0568a31826c3b28b2773a981121d684a4494f49fc2d8d2b3bd16d19807b9b22440505cb58e8b95fd4f4a68cd60c4c
7
- data.tar.gz: fc270ec8d5d3afea0358482e981329f74639a27bdaf5e66a1b6e3b2d014e6dbc8f0602584ed5446e39d9ad4cd33dad68539821b276b3ec817696d0efca661029
6
+ metadata.gz: 621b704d21ef9901f9a5d4c5d044ff87c072b1bb72959317e7ac983cf6197b6d5e52ab9a1d43e56931841e4c96eb853fb8925d479b83a4c56ce75a341251d443
7
+ data.tar.gz: 076a0cc98e045a97a7fef09eb0da44175a77af63753983e4c94f1dd686e3b6503d5797ce252652663326a06eb8938ce3e3b05d553ad97309232754bb24d61497
checksums.yaml.gz.sig CHANGED
Binary file
@@ -0,0 +1,65 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Released under the MIT License.
4
+ # Copyright, 2021-2022, by Samuel Williams.
5
+
6
+ require 'console'
7
+ require_relative '../metric'
8
+
9
+ module Metrics
10
+ module Backend
11
+ module Capture
12
+ class Metric < Metrics::Metric
13
+ def initialize(...)
14
+ super
15
+
16
+ @values = []
17
+ @tags = Set.new
18
+ @sample_rates = []
19
+ end
20
+
21
+ attr :values
22
+ attr :tags
23
+ attr :sample_rates
24
+
25
+ def emit(value, tags: nil, sample_rate: 1.0)
26
+ @values << value
27
+ @tags.merge(tags) if tags
28
+ @sample_rates << sample_rate
29
+ end
30
+
31
+ def as_json
32
+ {
33
+ name: @name,
34
+ type: @type,
35
+ description: @description,
36
+ unit: @unit,
37
+ values: @values,
38
+ tags: @tags.to_a.sort,
39
+ sample_rates: @sample_rates.sort.uniq
40
+ }
41
+ end
42
+
43
+ def to_json(...)
44
+ as_json.to_json(...)
45
+ end
46
+ end
47
+
48
+ def self.metrics
49
+ @metrics ||= []
50
+ end
51
+
52
+ module Interface
53
+ def metric(name, type, description: nil, unit: nil, &block)
54
+ metric = Metric.new(name, type, description, unit)
55
+
56
+ Capture.metrics << metric
57
+
58
+ return metric
59
+ end
60
+ end
61
+ end
62
+
63
+ Interface = Capture::Interface
64
+ end
65
+ end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2021-2022, by Samuel Williams.
4
+ # Copyright, 2021-2023, by Samuel Williams.
5
5
 
6
6
  require 'console'
7
7
  require_relative '../metric'
@@ -34,4 +34,3 @@ module Metrics
34
34
  Interface = Console::Interface
35
35
  end
36
36
  end
37
-
@@ -4,5 +4,5 @@
4
4
  # Copyright, 2021-2022, by Samuel Williams.
5
5
 
6
6
  module Metrics
7
- VERSION = "0.5.0"
7
+ VERSION = "0.6.0"
8
8
  end
data/license.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # MIT License
2
2
 
3
- Copyright, 2021-2022, by Samuel Williams.
3
+ Copyright, 2021-2023, by Samuel Williams.
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
data/readme.md CHANGED
@@ -27,27 +27,3 @@ We welcome contributions to this project.
27
27
 
28
28
  - [metrics-backend-datadog](https://github.com/socketry/metrics-backend-datadog) — A Metrics backend for Datadog.
29
29
  - [traces](https://github.com/socketry/traces) — A code tracing interface which follows a similar pattern.
30
-
31
- ## License
32
-
33
- Released under the MIT license.
34
-
35
- Copyright, 2021, by [Samuel G. D. Williams](http://www.codeotaku.com).
36
-
37
- Permission is hereby granted, free of charge, to any person obtaining a copy
38
- of this software and associated documentation files (the "Software"), to deal
39
- in the Software without restriction, including without limitation the rights
40
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
41
- copies of the Software, and to permit persons to whom the Software is
42
- furnished to do so, subject to the following conditions:
43
-
44
- The above copyright notice and this permission notice shall be included in
45
- all copies or substantial portions of the Software.
46
-
47
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
48
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
49
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
50
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
51
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
52
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
53
- THE SOFTWARE.
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.5.0
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
@@ -37,7 +37,7 @@ cert_chain:
37
37
  Q2K9NVun/S785AP05vKkXZEFYxqG6EW012U4oLcFl5MySFajYXRYbuUpH6AY+HP8
38
38
  voD0MPg1DssDLKwXyt1eKD/+Fq0bFWhwVM/1XiAXL7lyYUyOq24KHgQ2Csg=
39
39
  -----END CERTIFICATE-----
40
- date: 2022-11-09 00:00:00.000000000 Z
40
+ date: 2023-03-03 00:00:00.000000000 Z
41
41
  dependencies:
42
42
  - !ruby/object:Gem::Dependency
43
43
  name: bake-test
@@ -103,6 +103,7 @@ extra_rdoc_files: []
103
103
  files:
104
104
  - lib/metrics.rb
105
105
  - lib/metrics/backend.rb
106
+ - lib/metrics/backend/capture.rb
106
107
  - lib/metrics/backend/console.rb
107
108
  - lib/metrics/backend/test.rb
108
109
  - lib/metrics/metric.rb
@@ -130,7 +131,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
130
131
  - !ruby/object:Gem::Version
131
132
  version: '0'
132
133
  requirements: []
133
- rubygems_version: 3.3.7
134
+ rubygems_version: 3.4.7
134
135
  signing_key:
135
136
  specification_version: 4
136
137
  summary: Application metrics and instrumentation.
metadata.gz.sig CHANGED
Binary file