mettric 0.3.3 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.markdown +4 -0
- data/README.md +51 -10
- data/lib/mettric/mettric.rb +13 -6
- data/lib/mettric/version.rb +1 -1
- metadata +2 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8fd01d8d2f12be7b467a9fd8babaccbdf873e7cc
|
4
|
+
data.tar.gz: e36ebf89466f62855160699d992c18a742826cd5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7d76f9127dd7917457842ecaa1f25620139790139126bdd57dfe5b11d7e64ae4121e1c536ed64ca5f26ed3fa13024d0f2c5b17c6a178e3467927da4a2e21541c
|
7
|
+
data.tar.gz: 2048afba553355767a530e024820699492d1525b1e5608d1cecaed72bf168babb9a4dc8235f6a69fefa414121251d084b94521828f5edd7f575810e2d65aac73
|
data/CHANGELOG.markdown
CHANGED
data/README.md
CHANGED
@@ -65,19 +65,60 @@ Upon configuration, Mettric will install a [sidekiq](http://sidekiq.org/) middle
|
|
65
65
|
### Time things
|
66
66
|
|
67
67
|
```ruby
|
68
|
-
⏱
|
68
|
+
⏱ service: 'test.sleep', tags: [:tired] do
|
69
69
|
sleep 1
|
70
70
|
end
|
71
|
+
```
|
71
72
|
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
73
|
+
Above snippet will send the following payloads via riemann-ruby-client:
|
74
|
+
|
75
|
+
```json
|
76
|
+
[
|
77
|
+
{
|
78
|
+
"host": "override",
|
79
|
+
"service": "my_app.test.slept.duration",
|
80
|
+
"metric": 1000,
|
81
|
+
"description": "(ms)",
|
82
|
+
"tags": ["timing", "tired"]
|
83
|
+
},
|
84
|
+
{
|
85
|
+
"host": "override",
|
86
|
+
"service": "my_app.test.success",
|
87
|
+
"metric": 1,
|
88
|
+
"description": "(ms)",
|
89
|
+
"tags": ["event", "tired"]
|
90
|
+
}
|
91
|
+
]
|
92
|
+
```
|
93
|
+
|
94
|
+
Exceptions in your code are also handled:
|
95
|
+
|
96
|
+
```ruby
|
97
|
+
⏱ service: 'test.sleep', tags: [:tired] do
|
98
|
+
sleep 1
|
99
|
+
raise "My ambition is handicapped by laziness"
|
100
|
+
end
|
101
|
+
```
|
102
|
+
|
103
|
+
Above snippet will send the following payloads (and then raise
|
104
|
+
your exception):
|
105
|
+
|
106
|
+
```json
|
107
|
+
[
|
108
|
+
{
|
109
|
+
"host": "override",
|
110
|
+
"service": "my_app.test.sleep.duration",
|
111
|
+
"metric": 1000,
|
112
|
+
"description": "(ms)",
|
113
|
+
"tags": ["timing", "tired"]
|
114
|
+
},
|
115
|
+
{
|
116
|
+
"host": "override",
|
117
|
+
"service": "my_app.test.sleep.failure",
|
118
|
+
"metric": 1,
|
119
|
+
"description": "My ambition is handicapped by laziness",
|
120
|
+
"tags": ["event", "tired"]
|
121
|
+
}
|
81
122
|
```
|
82
123
|
|
83
124
|
### For grown ups
|
data/lib/mettric/mettric.rb
CHANGED
@@ -54,12 +54,19 @@ class Mettric
|
|
54
54
|
exception = e
|
55
55
|
state = 'failure'
|
56
56
|
end
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
payload[:
|
61
|
-
|
62
|
-
|
57
|
+
timing_payload = payload.dup
|
58
|
+
timing_payload[:service] = "#{payload[:service]}.duration"
|
59
|
+
timing_payload[:metric] = ((Time.now - start) * 1000).to_i
|
60
|
+
timing_payload[:description] = [payload[:description], "(ms)"].compact.join(' ')
|
61
|
+
timing_payload[:tags] = (payload[:tags] || []) + [:timing]
|
62
|
+
track(timing_payload)
|
63
|
+
|
64
|
+
if exception
|
65
|
+
event(service: "#{payload[:service]}.failure", tags: payload[:tags], description: exception.to_s)
|
66
|
+
raise exception
|
67
|
+
else
|
68
|
+
event(service: "#{payload[:service]}.success", tags: payload[:tags])
|
69
|
+
end
|
63
70
|
result
|
64
71
|
end
|
65
72
|
|
data/lib/mettric/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mettric
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jannis Hermanns
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-08-
|
11
|
+
date: 2016-08-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -175,4 +175,3 @@ signing_key:
|
|
175
175
|
specification_version: 4
|
176
176
|
summary: Count metrics
|
177
177
|
test_files: []
|
178
|
-
has_rdoc:
|