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 +4 -4
- checksums.yaml.gz.sig +0 -0
- data/lib/metrics/backend/capture.rb +65 -0
- data/lib/metrics/backend/console.rb +1 -2
- data/lib/metrics/version.rb +1 -1
- data/license.md +1 -1
- data/readme.md +0 -24
- data.tar.gz.sig +0 -0
- metadata +4 -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: 3775c730581fa1814523cea022ac4bbbcf5b1cb3f52e0d2f35dd667d521675eb
|
4
|
+
data.tar.gz: a8b3e43df8a40894e91112ee7e3c0d9743628a4b7f191cd4263b064283c21c30
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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-
|
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
|
-
|
data/lib/metrics/version.rb
CHANGED
data/license.md
CHANGED
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.
|
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:
|
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.
|
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
|