mettric 0.3.3 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 95b13d756407adf93e6c26a324991bb782d7e8f5
4
- data.tar.gz: 6aaf4d58fecea98c8971538b45e56cd0539ea4f1
3
+ metadata.gz: 8fd01d8d2f12be7b467a9fd8babaccbdf873e7cc
4
+ data.tar.gz: e36ebf89466f62855160699d992c18a742826cd5
5
5
  SHA512:
6
- metadata.gz: 6c24767b61749c1e1c018b429919f72ffb994f654008744544e13120e244951ab809e81a569ade14cbe4cfd3b2bdd43e92bbab9ee2fc7d3380944dd525190079
7
- data.tar.gz: edb6103e863ad23a94e7099b2644544b2004e9369b6ae3dbd1b2071de32dc54c2794258bbb563edac2431652a847db174d22ec5f7e5747d5cba93f69af4511e0
6
+ metadata.gz: 7d76f9127dd7917457842ecaa1f25620139790139126bdd57dfe5b11d7e64ae4121e1c536ed64ca5f26ed3fa13024d0f2c5b17c6a178e3467927da4a2e21541c
7
+ data.tar.gz: 2048afba553355767a530e024820699492d1525b1e5608d1cecaed72bf168babb9a4dc8235f6a69fefa414121251d084b94521828f5edd7f575810e2d65aac73
@@ -1,3 +1,7 @@
1
+ 1.0.0 (2016-08-19)
2
+ ==================
3
+ - Change behaviour of Mettric.time and ⏱
4
+
1
5
  0.3.3 (2016-08-09)
2
6
  ==================
3
7
  - Fix code for not raising Mettric::Errors more more
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
- (service: 'test.slept', tags: [:tired]) do
68
+ ⏱ service: 'test.sleep', tags: [:tired] do
69
69
  sleep 1
70
70
  end
71
+ ```
71
72
 
72
- # Will send the following payload via riemann-ruby-client:
73
- #
74
- # {
75
- # host: 'override',
76
- # service: 'my_app.test.slept',
77
- # metric: 1000,
78
- # description: '(ms)',
79
- # tags: ['timing', 'tired']
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
@@ -54,12 +54,19 @@ class Mettric
54
54
  exception = e
55
55
  state = 'failure'
56
56
  end
57
- payload[:metric] = ((Time.now - start) * 1000).to_i
58
- payload[:description] = [payload[:description], "(ms)"].compact.join(' ')
59
- payload[:tags] ||= []
60
- payload[:tags] << :timing
61
- track(payload)
62
- raise exception if exception
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
 
@@ -1,3 +1,3 @@
1
1
  class Mettric
2
- VERSION = "0.3.3"
2
+ VERSION = "1.0.0"
3
3
  end
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.3.3
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-09 00:00:00.000000000 Z
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: