mettric 0.1.11 → 0.1.12
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/mettric/client.rb +1 -2
- data/lib/mettric/mettric.rb +14 -1
- data/lib/mettric/scnr.rb +13 -4
- data/lib/mettric/version.rb +1 -1
- data/lib/mettric/worker.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 555d7e8f5825dd4b4d33cdf1007a869854bab852
|
4
|
+
data.tar.gz: 6014b23f15ad3bbf4134fba45b2de25da778e57c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0894d38c1412cdf571be55852bb3b61099805da54a8467803e5f6353a69e0445140a7925f4dabd0d91d5863aec1b5ff285147c875dcecb638c055f969e79701e
|
7
|
+
data.tar.gz: 63bf7b956aa464f4fa9e1a53eeb9fea1c89c37bce02fd8a5a3d465106a97b6af5727bbbe3115a29d7d8f024937692d964b9050e9e35d65372a4823857c3be21e
|
data/lib/mettric/client.rb
CHANGED
@@ -72,8 +72,7 @@ class Mettric::Client
|
|
72
72
|
out = stringify(payload)
|
73
73
|
raise Mettric::MissingService, out if out[:service].blank?
|
74
74
|
|
75
|
-
out[:tags]
|
76
|
-
out[:tags] << 'mettric'
|
75
|
+
out[:tags] = [out[:tags], :mettric].flatten.compact.uniq
|
77
76
|
out[:tags] << env if env.present?
|
78
77
|
out[:metric] ||= 1
|
79
78
|
|
data/lib/mettric/mettric.rb
CHANGED
@@ -19,6 +19,19 @@ class Mettric
|
|
19
19
|
QUEUE.size
|
20
20
|
end
|
21
21
|
|
22
|
+
# Tracking meter readings is the default
|
23
|
+
def self.meter(payload)
|
24
|
+
track(payload)
|
25
|
+
end
|
26
|
+
|
27
|
+
# To track events
|
28
|
+
def self.event(payload)
|
29
|
+
payload[:tags] ||= []
|
30
|
+
payload[:tags] << :event
|
31
|
+
track(payload)
|
32
|
+
end
|
33
|
+
|
34
|
+
# To track durations
|
22
35
|
def self.time(payload)
|
23
36
|
exception = nil
|
24
37
|
state = 'success'
|
@@ -32,7 +45,7 @@ class Mettric
|
|
32
45
|
payload[:service] = "#{payload[:service]} ms" unless payload[:service].to_s.end_with?(' ms')
|
33
46
|
payload[:metric] = ((Time.now - start) * 1000).to_i
|
34
47
|
payload[:tags] ||= []
|
35
|
-
payload[:tags] <<
|
48
|
+
payload[:tags] << :timing
|
36
49
|
track(payload)
|
37
50
|
end
|
38
51
|
|
data/lib/mettric/scnr.rb
CHANGED
@@ -1,11 +1,20 @@
|
|
1
|
-
#
|
2
|
-
|
3
|
-
|
1
|
+
# An event (to become a rate)
|
2
|
+
# https://youtu.be/pWso-qRaIlM?t=48
|
3
|
+
def 🛎 (payload)
|
4
|
+
Mettric.event(payload)
|
4
5
|
rescue Mettric::CouldNotStartWorkerThread
|
5
6
|
puts "***WARNING*** Mettric::CouldNotStartWorkerThread raised"
|
6
7
|
end
|
7
8
|
|
8
|
-
|
9
|
+
# A meter
|
10
|
+
def 🌡 (payload)
|
11
|
+
Mettric.meter(payload)
|
12
|
+
rescue Mettric::CouldNotStartWorkerThread
|
13
|
+
puts "***WARNING*** Mettric::CouldNotStartWorkerThread raised"
|
14
|
+
end
|
15
|
+
|
16
|
+
# A duration
|
17
|
+
def ⏱ (payload, &block)
|
9
18
|
Mettric.time(payload) do
|
10
19
|
block.call
|
11
20
|
end
|
data/lib/mettric/version.rb
CHANGED
data/lib/mettric/worker.rb
CHANGED
@@ -15,7 +15,7 @@ class Mettric::Worker
|
|
15
15
|
|
16
16
|
def loop
|
17
17
|
Mettric::Client.new(@config) do |client|
|
18
|
-
deliver(client, service: 'mettric.worker.start') rescue nil
|
18
|
+
deliver(client, service: 'mettric.worker.start', metric: 1) rescue nil
|
19
19
|
while payload = @queue.pop
|
20
20
|
deliver(client, payload)
|
21
21
|
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.
|
4
|
+
version: 0.1.12
|
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-
|
11
|
+
date: 2016-06-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|