jenkins_statsd 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/jenkins_statsd/jenkins_client.rb +24 -5
- data/lib/jenkins_statsd/statsd_client.rb +4 -0
- data/lib/jenkins_statsd/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3bba0435e463911efbea5abc1fae0c85aabf7142
|
4
|
+
data.tar.gz: 5387e77c0fafc1eed91eec7d5073d67f368e8a95
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 54e82f30945f30dea148cdb3790f80effbf25ea574293bb4911c7a6fbdcbb1e67ff213207fa7ff508dc41218b221b85f8e95171dbddedb2114d69e1bb312791b
|
7
|
+
data.tar.gz: 5343b5028a93830bba8172bf4ec2571307bdfd722ea901cb063445815500a90109fd95fb29e0f2f1279494ecf1f53e049eb5199667bc3d7756e469821784d45b
|
@@ -5,10 +5,14 @@ module JenkinsStatsd
|
|
5
5
|
class JenkinsClient
|
6
6
|
attr_reader :metrics_url
|
7
7
|
|
8
|
-
|
8
|
+
GAUGES_EXCLUDE = [
|
9
9
|
%r(^jenkins\.versions)
|
10
10
|
]
|
11
11
|
|
12
|
+
METERS_EXCLUDE = [
|
13
|
+
%r(^http)
|
14
|
+
]
|
15
|
+
|
12
16
|
def initialize(host, api_token)
|
13
17
|
@metrics_url = File.join(host, 'metrics', api_token, 'metrics')
|
14
18
|
end
|
@@ -18,21 +22,36 @@ module JenkinsStatsd
|
|
18
22
|
response = RestClient.get metrics_url
|
19
23
|
parsed = JSON.parse(response.body)
|
20
24
|
metrics[:gauges] = extract_gauges(parsed)
|
25
|
+
metrics[:meters] = extract_meters(parsed)
|
21
26
|
metrics
|
22
27
|
end
|
23
28
|
|
24
29
|
protected
|
25
30
|
|
31
|
+
def ignore?(str, list)
|
32
|
+
list.each do |pattern|
|
33
|
+
return true if str.match(pattern)
|
34
|
+
end
|
35
|
+
false
|
36
|
+
end
|
37
|
+
|
26
38
|
def extract_gauges(data)
|
27
39
|
gauges = {}
|
28
40
|
data['gauges'].each do |key, value|
|
29
|
-
|
30
|
-
next if key.match(pattern)
|
41
|
+
next if ignore?(key, GAUGES_EXCLUDE)
|
31
42
|
|
32
|
-
|
33
|
-
end
|
43
|
+
gauges[key] = value['value']
|
34
44
|
end
|
35
45
|
gauges
|
36
46
|
end
|
47
|
+
|
48
|
+
def extract_meters(data)
|
49
|
+
meters = {}
|
50
|
+
data['meters'].each do |key, value|
|
51
|
+
next if ignore?(key, METERS_EXCLUDE)
|
52
|
+
meters["#{key}.m1_rate"] = value['m1_rate']
|
53
|
+
end
|
54
|
+
meters
|
55
|
+
end
|
37
56
|
end
|
38
57
|
end
|