mettric 0.1.13 → 0.2.1

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
  SHA1:
3
- metadata.gz: 08cdfaf00799db2eafb16139724b95f0b0b9fed6
4
- data.tar.gz: 8c1c7e145b57ddfd9f79df0720b7cd8a7ed4e5a8
3
+ metadata.gz: d76dbab9498e309d9cbceef170e6d5f6677f9728
4
+ data.tar.gz: 9e373a5068b4d00e2e272eba10b9f92d36becfe3
5
5
  SHA512:
6
- metadata.gz: 746ead2be6615e86d659e89928a41b826e5d6d1e14b50637e46a5e693c8134c38e407f6b392999ea61444f80440d4651ec84b287df09b2f36e12053f22f7d762
7
- data.tar.gz: 3ac48229d7ecc2aedd0f637d5d37289e5fc6a1f8b85812194000a5ef567ac4119630eabf344586db349d28b5fba37a58a31a4169dfa228ba81571bf9dea1568b
6
+ metadata.gz: 304c43ef459a0160fb4249b61540b449e6bade8bda5626267ca610f3894ff009fa4f6c12b2f151b322a58a4216cef7cab8c50f7f7df7d106c8a01e679666b23f
7
+ data.tar.gz: ceb560d5c836833300ee731e8590e2a6ac07cc4e5f7b8e722c9baa4bb0f7caf3feae19204e3412197c927bfce22c7d5c68dd5db3c31544de54974e98fedda1cd
@@ -42,8 +42,8 @@ class Mettric
42
42
  exception = e
43
43
  state = 'failure'
44
44
  end
45
- payload[:service] = "#{payload[:service]} ms" unless payload[:service].to_s.end_with?(' ms')
46
45
  payload[:metric] = ((Time.now - start) * 1000).to_i
46
+ payload[:description] = [payload[:description], "(ms)"].compact.join(' ')
47
47
  payload[:tags] ||= []
48
48
  payload[:tags] << :timing
49
49
  track(payload)
@@ -5,19 +5,30 @@ class Mettric::SidekiqMiddleware
5
5
  end
6
6
 
7
7
  def call(worker, msg, queue)
8
- opts = worker.class.sidekiq_options['mettric']
8
+ begin
9
+ opts = worker.class.sidekiq_options['mettric']
9
10
 
10
- # Don't do anything if we're told to skip this class
11
- if opts != true and opts != nil
12
- return yield
13
- end
11
+ # Don't do anything if we're told to skip this class
12
+ if opts != true and opts != nil
13
+ return yield
14
+ end
15
+
16
+ # Tracking under this name
17
+ service = "sidekiq.queue:#{queue.to_s.underscore}.worker:#{worker.class.name.underscore}"
14
18
 
15
- # Track the job timing
16
- service = "sidekiq.queue:#{queue.to_s.underscore}.worker:#{worker.class.name.underscore} ms"
17
- Mettric.time(service: service, tags: ['sidekiq']) do
18
- yield
19
+ # Yield & time
20
+ Mettric.time(service: "#{service}.duration", tags: ['sidekiq']) do
21
+ yield
22
+ end
23
+ rescue
24
+ Mettric.event(service: "#{service}.error", tags: ['sidekiq'])
25
+ raise
19
26
  end
27
+
28
+ # Track success
29
+ Mettric.event(service: "#{service}.success", tags: ['sidekiq'])
20
30
  end
31
+
21
32
  end
22
33
 
23
34
  if Kernel.const_defined?(:Sidekiq)
@@ -1,3 +1,3 @@
1
1
  class Mettric
2
- VERSION = "0.1.13"
2
+ VERSION = "0.2.1"
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.1.13
4
+ version: 0.2.1
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-06-06 00:00:00.000000000 Z
11
+ date: 2016-06-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport