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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c3d4e4612e2d8b6fe7427a5208ea13fabd1c9c66
4
- data.tar.gz: f59227cdaeb1b714dcb8702cb756ef149b9d1226
3
+ metadata.gz: 3bba0435e463911efbea5abc1fae0c85aabf7142
4
+ data.tar.gz: 5387e77c0fafc1eed91eec7d5073d67f368e8a95
5
5
  SHA512:
6
- metadata.gz: 35e8c4512a26432334f8ff85d5ea81589e0e1d4c489c6fa4724055a961b42505c084326706a262f4ef8b414b9a981bdab88218e32c5a65ccac3c84b62a12cf66
7
- data.tar.gz: 02323e6b532a3f7852102a0ea63e918296a68a0fc2cc438830bdbe7577dcab04e18a2a62a72bc8cc70face3db125ad787fb882ae866aa53f9df7150f659a02f4
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
- EXCLUDE = [
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
- EXCLUDE.each do |pattern|
30
- next if key.match(pattern)
41
+ next if ignore?(key, GAUGES_EXCLUDE)
31
42
 
32
- gauges[key] = value['value']
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
@@ -11,6 +11,10 @@ module JenkinsStatsd
11
11
  metrics[:gauges].each do |key, value|
12
12
  statsd.gauge(key, value)
13
13
  end
14
+
15
+ metrics[:meters].each do |key, value|
16
+ statsd.gauge(key, value)
17
+ end
14
18
  end
15
19
  end
16
20
  end
@@ -1,3 +1,3 @@
1
1
  module JenkinsStatsd
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jenkins_statsd
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Chun-Lum