updown 0.3.1 → 0.4.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: ae7726d29d3ab3d38259054cdab774e129640a24
4
- data.tar.gz: c5ddc78ed903615481aad4d0fe8a1c306eebd6fd
3
+ metadata.gz: 11ad73d000351864816dc649ba37815d432f9dba
4
+ data.tar.gz: 4d38bdc654d9a62fc14d697811a579937afb2463
5
5
  SHA512:
6
- metadata.gz: 6d1b87d64a6190c1e29381ce067754cf47c377f1496c3ad9a3b631b257e8e3e538fd47ea2d69c023126dbd1238705de1d9c9a641a5440754e81c439afdb910a8
7
- data.tar.gz: f968ad6072e94d9eb1f75f7a4cf1bbcd40768c9de21cb4892427fc56f096124a0481ec5c5c6850b99bbd0dcc2c7703b0aa1d43fb94f7b2971c38603433867357
6
+ metadata.gz: f5c7d7112b065d20fdaf5b626109bd4bf282f2ea833a1a75749ce6a0c4b2b735e8ef5bcb8dfef6df5f9d0bf535786e76daef73a182f945e1dbd83955b3ea8fa8
7
+ data.tar.gz: ce936d0df39b4cd0393bd702c4551b88bb7ca1d25358cc179430ec9efb8e09c37ac9df82648283ca3d14d45a06351bcc3084bb63372574f0cefacb01d826ce46
@@ -1,3 +1,9 @@
1
+ ### 0.4.0
2
+ _2016-06-05_
3
+
4
+ * Added support for the check/:token/metrics endpoint
5
+ * Added support for the metrics parameter to the check/:token endpoint
6
+
1
7
  ### 0.2.2
2
8
  _2015-06-28_
3
9
 
data/README.md CHANGED
@@ -45,6 +45,11 @@ Retrieve a specific check:
45
45
  ```ruby
46
46
  Updown::Check.get check_token
47
47
  # => <Updown::Check>
48
+
49
+ # include performance metrics for the last hour
50
+ check = Updown::Check.get check_token, metrics: true
51
+ check.metrics
52
+ # => {"apdex": 0.98, "requests": { … }, "timings": { … }}
48
53
  ```
49
54
 
50
55
  List downtimes for a specific check (paginated, 100 per call):
@@ -57,6 +62,27 @@ check.downtimes page: 2
57
62
  # => [<Updown::Downtime>]
58
63
  ```
59
64
 
65
+ Get detailed performance metrics for a specific check:
66
+
67
+ ```ruby
68
+ # Default is for last month
69
+ check.get_metrics
70
+ # => {"apdex": 0.98, "requests": { … }, "timings": { … }}
71
+
72
+ # Specify time span
73
+ check.get_metrics from: 4.hours.ago, to: 2.hours.ago
74
+ # => {"apdex": 1, "requests": { … }, "timings": { … }}
75
+
76
+ # Specify grouping per location (:host) or hour (:time)
77
+ check.get_metrics group: :host
78
+ # => {
79
+ # "sgp" => {"apdex": 0.82, "host": { city: "Singapore", … }, … },
80
+ # "sfo" => {"apdex": 0.98, "host": { city: "San Francisco", … }, … },
81
+ # "alpha" => {"apdex": 0.98, "host": { city: "Montreal", … }, … },
82
+ # "gra" => {"apdex": 0.92, "host": { city: "Gravelines", … }, … }
83
+ # }
84
+ ```
85
+
60
86
  Create a new check:
61
87
 
62
88
  ```ruby
@@ -17,12 +17,16 @@ module Updown
17
17
  process { Call.resource["checks/#{token}/downtimes"].get(params: filters) }
18
18
  end
19
19
 
20
+ def self.metrics(token, filters={})
21
+ process { Call.resource["checks/#{token}/metrics"].get(params: filters) }
22
+ end
23
+
20
24
  def self.create_check(attributes={})
21
25
  process { Call.resource['checks'].post(attributes) }
22
26
  end
23
27
 
24
28
  def self.get_check(token, attributes={})
25
- process { Call.resource["checks/#{token}"].get(attributes) }
29
+ process { Call.resource["checks/#{token}"].get(params: attributes) }
26
30
  end
27
31
 
28
32
  def self.update_check(token, attributes={})
@@ -37,7 +41,7 @@ module Updown
37
41
  JSON.parse yield
38
42
  rescue RestClient::BadRequest, RestClient::Unauthorized, RestClient::ResourceNotFound => e
39
43
  result = (JSON.parse(e.response) rescue {})
40
- raise Updown::Error.new(result['error'] || e.reponse)
44
+ raise Updown::Error.new(result['error'] || e.response)
41
45
  end
42
46
 
43
47
  end
@@ -2,7 +2,7 @@ require 'time'
2
2
 
3
3
  module Updown
4
4
  class Check
5
- attr_accessor :token, :url, :alias, :last_status, :uptime, :down, :down_since, :error, :period, :apdex_t, :enabled, :published, :last_check_at, :next_check_at, :ssl_tested_at, :ssl_valid, :ssl_error
5
+ attr_accessor :token, :url, :alias, :last_status, :uptime, :down, :down_since, :error, :period, :apdex_t, :enabled, :published, :last_check_at, :next_check_at, :ssl_tested_at, :ssl_valid, :ssl_error, :metrics
6
6
 
7
7
  def self.all
8
8
  Updown::Call.checks.map do |check|
@@ -30,6 +30,7 @@ module Updown
30
30
  @uptime = json['uptime']
31
31
  @down = json['down']
32
32
  @error = json['error']
33
+ @metrics = json['metrics']
33
34
  @down_since = Time.parse(json['down_since']) if json['down_since']
34
35
  @last_check_at = Time.parse(json['last_check_at']) if json['last_check_at']
35
36
  @next_check_at = Time.parse(json['next_check_at']) if json['next_check_at']
@@ -44,6 +45,10 @@ module Updown
44
45
  Downtime.find(@token, page: page)
45
46
  end
46
47
 
48
+ def get_metrics filters = {}
49
+ Updown::Call.metrics(@token, filters)
50
+ end
51
+
47
52
  def update(attributes={})
48
53
  Check.new Updown::Call.update_check(@token, attributes)
49
54
  end
@@ -33,7 +33,6 @@ module Updown
33
33
  desc 'open ID', 'Open the status page of a check'
34
34
  def open(token)
35
35
  configure_api_key
36
-
37
36
  system "open https://updown.io/#{token}"
38
37
  end
39
38
 
@@ -1,3 +1,3 @@
1
1
  module Updown
2
- VERSION = "0.3.1"
2
+ VERSION = "0.4.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: updown
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aske Hansen
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2016-03-07 00:00:00.000000000 Z
12
+ date: 2016-06-05 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -143,3 +143,4 @@ signing_key:
143
143
  specification_version: 4
144
144
  summary: updown.io API wrapper
145
145
  test_files: []
146
+ has_rdoc: