alephant-broker 3.0.1 → 3.1.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: 68a9bc33df3994006cc8a45e6c03e7609ad87a85
4
- data.tar.gz: b9f7f4f87c2d11c774a4ccaaeed7c7e1ee3b6f9a
3
+ metadata.gz: a9e0e97812cfc74d3c37cdcdab494a245352a699
4
+ data.tar.gz: 3b396eee30f30acf3e21317c698e806bcd058c1d
5
5
  SHA512:
6
- metadata.gz: 02b9c8a85184e32b00019a3401727c32d06445e1afc61248d16e9960b0378a1ed153df9da524c5b8c198aa53792e9dc6f488695edaf52e6ee9369d83d8ebd126
7
- data.tar.gz: f5f3d1fee60fa8ce65a8615fcd51d159e5ddb7bd8551fa2916cfd695fc318eb0142aa3b32070e91f250b2520b98962b1994c0cb1dd2d569edcc96f58d43b6e55
6
+ metadata.gz: deef43f8365dc333a520d02aacad56193f2ecb72ddde29df9d0478827982e7d546f8bc688c31b90dce54538e202d9d80ca2aed2b0b22c439ea9c2f2eb275c56c
7
+ data.tar.gz: ae2f6611c3b0ce73fe341886464e3d937ae848c76c638d09a1b37d0e9832425defd44e48224688bf928e504a8244b3f499f5cc60d3337f43d68007f877e41678
@@ -15,6 +15,7 @@ module Alephant
15
15
  @@client ||= @@elasticache.client
16
16
  else
17
17
  logger.debug('Broker::Cache::Client#initialize: No config endpoint, NullClient used')
18
+ logger.metric(:name => "BrokerCacheClientNoConfigEndpoint", :unit => "Count", :value => 1)
18
19
  @@client = NullClient.new
19
20
  end
20
21
  end
@@ -23,6 +24,7 @@ module Alephant
23
24
  begin
24
25
  result = @@client.get(versioned(key))
25
26
  logger.info("Broker::Cache::Client#get key: #{key} - #{result ? 'hit' : 'miss'}")
27
+ logger.metric(:name => "BrokerCacheClientGetKeyMiss", :unit => "Count", :value => 1) unless result
26
28
  result ? result : set(key, block.call)
27
29
  rescue StandardError => e
28
30
  block.call if block_given?
@@ -1,5 +1,4 @@
1
1
  require 'crimp'
2
- require 'alephant/logger'
3
2
  require 'alephant/cache'
4
3
  require 'alephant/lookup'
5
4
  require 'alephant/broker/errors/invalid_cache_key'
@@ -20,9 +20,11 @@ module Alephant
20
20
  )
21
21
  rescue Alephant::Broker::Errors::ContentNotFound => e
22
22
  logger.warn 'Broker.ComponentFactory.create: Exception raised (ContentNotFound)'
23
+ logger.metric(:name => "BrokerComponentFactoryContentNotFound", :unit => "Count", :value => 1)
23
24
  ErrorComponent.new(component_meta, 404, e)
24
25
  rescue => e
25
26
  logger.warn("Broker.ComponentFactory.create: Exception raised (#{e.message}, #{e.backtrace.join('\n')})")
27
+ logger.metric(:name => "BrokerComponentFactoryExceptionRaised", :unit => "Count", :value => 1)
26
28
  ErrorComponent.new(component_meta, 500, e)
27
29
  end
28
30
  end
@@ -51,6 +51,7 @@ module Alephant
51
51
  JSON.parse(json)
52
52
  rescue JSON::ParserError => e
53
53
  logger.warn("Broker.environment#data: ParserError")
54
+ logger.metric(:name => "BrokerEnvironmentJSONParserError", :unit => "Count", :value => 1)
54
55
  nil
55
56
  end
56
57
  end
@@ -1,11 +1,14 @@
1
1
  require 'alephant/broker/cache'
2
2
  require 'alephant/broker/errors/content_not_found'
3
+ require 'alephant/logger'
3
4
  require 'faraday'
4
5
 
5
6
  module Alephant
6
7
  module Broker
7
8
  module LoadStrategy
8
9
  class HTTP
10
+ include Logger
11
+
9
12
  class URL
10
13
  def generate
11
14
  raise NotImplementedError
@@ -19,6 +22,7 @@ module Alephant
19
22
  def load(component_meta)
20
23
  cache_object(component_meta)
21
24
  rescue
25
+ logger.metric(:name => "BrokerLoadStrategyHTTPCacheMiss", :unit => "Count", :value => 1)
22
26
  cache.set(component_meta.cache_key, content(component_meta))
23
27
  end
24
28
 
@@ -47,9 +51,17 @@ module Alephant
47
51
  end
48
52
 
49
53
  def request(component_meta)
54
+ before = Time.new
50
55
  component_meta.cached = false
56
+
51
57
  Faraday.get(url_for component_meta).tap do |r|
52
- raise Alephant::Broker::Errors::ContentNotFound unless r.success?
58
+ unless r.success?
59
+ logger.metric(:name => "BrokerLoadStrategyHTTPContentNotFound", :unit => "Count", :value => 1)
60
+ raise Alephant::Broker::Errors::ContentNotFound
61
+ end
62
+
63
+ request_time = Time.new - before
64
+ logger.metric(:name => "BrokerHTTPLoadComponentTime", :unit => "Seconds", :value => request_time)
53
65
  end
54
66
  end
55
67
 
@@ -1,17 +1,21 @@
1
1
  require "alephant/broker/cache"
2
2
  require 'alephant/broker/errors/content_not_found'
3
3
  require 'alephant/broker/errors/invalid_cache_key'
4
+ require 'alephant/logger'
4
5
 
5
6
  module Alephant
6
7
  module Broker
7
8
  module LoadStrategy
8
9
  class S3
10
+ include Logger
11
+
9
12
  def load(component_meta)
10
13
  add_s3_headers(
11
14
  cache_object(component_meta),
12
15
  component_meta
13
16
  )
14
17
  rescue
18
+ logger.metric(:name => "BrokerLoadStrategyS3CacheMiss", :unit => "Count", :value => 1)
15
19
  add_s3_headers(
16
20
  cache.set(
17
21
  component_meta.cache_key,
@@ -45,6 +49,7 @@ module Alephant
45
49
  component_meta.cached = false
46
50
  s3.get s3_path(component_meta)
47
51
  rescue AWS::S3::Errors::NoSuchKey, InvalidCacheKey
52
+ logger.metric(:name => "BrokerLoadStrategyS3InvalidCacheKey", :unit => "Count", :value => 1)
48
53
  raise Alephant::Broker::Errors::ContentNotFound
49
54
  end
50
55
 
@@ -16,6 +16,9 @@ module Alephant
16
16
  nil,
17
17
  env.options
18
18
  )
19
+ rescue InvalidAssetId
20
+ logger.metric(:name => "BrokerRequestAssetInvalidAssetId", :unit => "Count", :value => 1)
21
+ logger.warn 'Broker.Request.Asset.initialize: Exception raised (InvalidAssetId)'
19
22
  end
20
23
 
21
24
  private
@@ -1,4 +1,5 @@
1
1
  require 'alephant/broker/errors/invalid_cache_key'
2
+ require 'alephant/logger'
2
3
  require 'aws-sdk'
3
4
  require 'ostruct'
4
5
 
@@ -6,6 +7,8 @@ module Alephant
6
7
  module Broker
7
8
  module Response
8
9
  class Base
10
+ include Logger
11
+
9
12
  attr_reader :content, :headers, :status
10
13
 
11
14
  STATUS_CODE_MAPPING = {
@@ -19,12 +22,20 @@ module Alephant
19
22
  @headers = { "Content-Type" => content_type }
20
23
  @status = status
21
24
 
25
+ log if status !~ /200/
26
+
22
27
  setup
23
28
  end
24
29
 
25
30
  protected
26
31
 
27
32
  def setup; end
33
+
34
+ private
35
+
36
+ def log
37
+ logger.metric(:name => "BrokerResponse#{status}", :unit => "Count", :value => 1)
38
+ end
28
39
  end
29
40
  end
30
41
  end
@@ -1,5 +1,5 @@
1
1
  module Alephant
2
2
  module Broker
3
- VERSION = "3.0.1"
3
+ VERSION = "3.1.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,281 +1,281 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: alephant-broker
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.1
4
+ version: 3.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Steven Jack
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-11-24 00:00:00.000000000 Z
11
+ date: 2014-12-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: rspec
15
- version_requirements: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - '>='
18
- - !ruby/object:Gem::Version
19
- version: '0'
20
14
  requirement: !ruby/object:Gem::Requirement
21
15
  requirements:
22
16
  - - '>='
23
17
  - !ruby/object:Gem::Version
24
18
  version: '0'
19
+ name: rspec
25
20
  prerelease: false
26
21
  type: :development
27
- - !ruby/object:Gem::Dependency
28
- name: rspec-nc
29
22
  version_requirements: !ruby/object:Gem::Requirement
30
23
  requirements:
31
24
  - - '>='
32
25
  - !ruby/object:Gem::Version
33
26
  version: '0'
27
+ - !ruby/object:Gem::Dependency
34
28
  requirement: !ruby/object:Gem::Requirement
35
29
  requirements:
36
30
  - - '>='
37
31
  - !ruby/object:Gem::Version
38
32
  version: '0'
33
+ name: rspec-nc
39
34
  prerelease: false
40
35
  type: :development
41
- - !ruby/object:Gem::Dependency
42
- name: guard
43
36
  version_requirements: !ruby/object:Gem::Requirement
44
37
  requirements:
45
38
  - - '>='
46
39
  - !ruby/object:Gem::Version
47
40
  version: '0'
41
+ - !ruby/object:Gem::Dependency
48
42
  requirement: !ruby/object:Gem::Requirement
49
43
  requirements:
50
44
  - - '>='
51
45
  - !ruby/object:Gem::Version
52
46
  version: '0'
47
+ name: guard
53
48
  prerelease: false
54
49
  type: :development
55
- - !ruby/object:Gem::Dependency
56
- name: guard-rspec
57
50
  version_requirements: !ruby/object:Gem::Requirement
58
51
  requirements:
59
52
  - - '>='
60
53
  - !ruby/object:Gem::Version
61
54
  version: '0'
55
+ - !ruby/object:Gem::Dependency
62
56
  requirement: !ruby/object:Gem::Requirement
63
57
  requirements:
64
58
  - - '>='
65
59
  - !ruby/object:Gem::Version
66
60
  version: '0'
61
+ name: guard-rspec
67
62
  prerelease: false
68
63
  type: :development
69
- - !ruby/object:Gem::Dependency
70
- name: pry
71
64
  version_requirements: !ruby/object:Gem::Requirement
72
65
  requirements:
73
66
  - - '>='
74
67
  - !ruby/object:Gem::Version
75
68
  version: '0'
69
+ - !ruby/object:Gem::Dependency
76
70
  requirement: !ruby/object:Gem::Requirement
77
71
  requirements:
78
72
  - - '>='
79
73
  - !ruby/object:Gem::Version
80
74
  version: '0'
75
+ name: pry
81
76
  prerelease: false
82
77
  type: :development
83
- - !ruby/object:Gem::Dependency
84
- name: pry-remote
85
78
  version_requirements: !ruby/object:Gem::Requirement
86
79
  requirements:
87
80
  - - '>='
88
81
  - !ruby/object:Gem::Version
89
82
  version: '0'
83
+ - !ruby/object:Gem::Dependency
90
84
  requirement: !ruby/object:Gem::Requirement
91
85
  requirements:
92
86
  - - '>='
93
87
  - !ruby/object:Gem::Version
94
88
  version: '0'
89
+ name: pry-remote
95
90
  prerelease: false
96
91
  type: :development
97
- - !ruby/object:Gem::Dependency
98
- name: pry-nav
99
92
  version_requirements: !ruby/object:Gem::Requirement
100
93
  requirements:
101
94
  - - '>='
102
95
  - !ruby/object:Gem::Version
103
96
  version: '0'
97
+ - !ruby/object:Gem::Dependency
104
98
  requirement: !ruby/object:Gem::Requirement
105
99
  requirements:
106
100
  - - '>='
107
101
  - !ruby/object:Gem::Version
108
102
  version: '0'
103
+ name: pry-nav
109
104
  prerelease: false
110
105
  type: :development
111
- - !ruby/object:Gem::Dependency
112
- name: rake-rspec
113
106
  version_requirements: !ruby/object:Gem::Requirement
114
107
  requirements:
115
108
  - - '>='
116
109
  - !ruby/object:Gem::Version
117
- version: 0.0.2
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
118
112
  requirement: !ruby/object:Gem::Requirement
119
113
  requirements:
120
114
  - - '>='
121
115
  - !ruby/object:Gem::Version
122
116
  version: 0.0.2
117
+ name: rake-rspec
123
118
  prerelease: false
124
119
  type: :development
125
- - !ruby/object:Gem::Dependency
126
- name: bundler
127
120
  version_requirements: !ruby/object:Gem::Requirement
128
121
  requirements:
129
- - - ~>
122
+ - - '>='
130
123
  - !ruby/object:Gem::Version
131
- version: '1.5'
124
+ version: 0.0.2
125
+ - !ruby/object:Gem::Dependency
132
126
  requirement: !ruby/object:Gem::Requirement
133
127
  requirements:
134
128
  - - ~>
135
129
  - !ruby/object:Gem::Version
136
130
  version: '1.5'
131
+ name: bundler
137
132
  prerelease: false
138
133
  type: :development
139
- - !ruby/object:Gem::Dependency
140
- name: rake
141
134
  version_requirements: !ruby/object:Gem::Requirement
142
135
  requirements:
143
- - - '>='
136
+ - - ~>
144
137
  - !ruby/object:Gem::Version
145
- version: '0'
138
+ version: '1.5'
139
+ - !ruby/object:Gem::Dependency
146
140
  requirement: !ruby/object:Gem::Requirement
147
141
  requirements:
148
142
  - - '>='
149
143
  - !ruby/object:Gem::Version
150
144
  version: '0'
145
+ name: rake
151
146
  prerelease: false
152
147
  type: :development
153
- - !ruby/object:Gem::Dependency
154
- name: rack-test
155
148
  version_requirements: !ruby/object:Gem::Requirement
156
149
  requirements:
157
150
  - - '>='
158
151
  - !ruby/object:Gem::Version
159
152
  version: '0'
153
+ - !ruby/object:Gem::Dependency
160
154
  requirement: !ruby/object:Gem::Requirement
161
155
  requirements:
162
156
  - - '>='
163
157
  - !ruby/object:Gem::Version
164
158
  version: '0'
159
+ name: rack-test
165
160
  prerelease: false
166
161
  type: :development
167
- - !ruby/object:Gem::Dependency
168
- name: alephant-lookup
169
162
  version_requirements: !ruby/object:Gem::Requirement
170
163
  requirements:
171
164
  - - '>='
172
165
  - !ruby/object:Gem::Version
173
166
  version: '0'
167
+ - !ruby/object:Gem::Dependency
174
168
  requirement: !ruby/object:Gem::Requirement
175
169
  requirements:
176
170
  - - '>='
177
171
  - !ruby/object:Gem::Version
178
172
  version: '0'
173
+ name: alephant-lookup
179
174
  prerelease: false
180
175
  type: :runtime
181
- - !ruby/object:Gem::Dependency
182
- name: alephant-cache
183
176
  version_requirements: !ruby/object:Gem::Requirement
184
177
  requirements:
185
178
  - - '>='
186
179
  - !ruby/object:Gem::Version
187
180
  version: '0'
181
+ - !ruby/object:Gem::Dependency
188
182
  requirement: !ruby/object:Gem::Requirement
189
183
  requirements:
190
184
  - - '>='
191
185
  - !ruby/object:Gem::Version
192
186
  version: '0'
187
+ name: alephant-cache
193
188
  prerelease: false
194
189
  type: :runtime
195
- - !ruby/object:Gem::Dependency
196
- name: alephant-logger
197
190
  version_requirements: !ruby/object:Gem::Requirement
198
191
  requirements:
199
192
  - - '>='
200
193
  - !ruby/object:Gem::Version
201
194
  version: '0'
195
+ - !ruby/object:Gem::Dependency
202
196
  requirement: !ruby/object:Gem::Requirement
203
197
  requirements:
204
198
  - - '>='
205
199
  - !ruby/object:Gem::Version
206
200
  version: '0'
201
+ name: alephant-logger
207
202
  prerelease: false
208
203
  type: :runtime
209
- - !ruby/object:Gem::Dependency
210
- name: alephant-sequencer
211
204
  version_requirements: !ruby/object:Gem::Requirement
212
205
  requirements:
213
206
  - - '>='
214
207
  - !ruby/object:Gem::Version
215
208
  version: '0'
209
+ - !ruby/object:Gem::Dependency
216
210
  requirement: !ruby/object:Gem::Requirement
217
211
  requirements:
218
212
  - - '>='
219
213
  - !ruby/object:Gem::Version
220
214
  version: '0'
215
+ name: alephant-sequencer
221
216
  prerelease: false
222
217
  type: :runtime
223
- - !ruby/object:Gem::Dependency
224
- name: dalli-elasticache
225
218
  version_requirements: !ruby/object:Gem::Requirement
226
219
  requirements:
227
220
  - - '>='
228
221
  - !ruby/object:Gem::Version
229
222
  version: '0'
223
+ - !ruby/object:Gem::Dependency
230
224
  requirement: !ruby/object:Gem::Requirement
231
225
  requirements:
232
226
  - - '>='
233
227
  - !ruby/object:Gem::Version
234
228
  version: '0'
229
+ name: dalli-elasticache
235
230
  prerelease: false
236
231
  type: :runtime
237
- - !ruby/object:Gem::Dependency
238
- name: pmap
239
232
  version_requirements: !ruby/object:Gem::Requirement
240
233
  requirements:
241
234
  - - '>='
242
235
  - !ruby/object:Gem::Version
243
236
  version: '0'
237
+ - !ruby/object:Gem::Dependency
244
238
  requirement: !ruby/object:Gem::Requirement
245
239
  requirements:
246
240
  - - '>='
247
241
  - !ruby/object:Gem::Version
248
242
  version: '0'
243
+ name: pmap
249
244
  prerelease: false
250
245
  type: :runtime
251
- - !ruby/object:Gem::Dependency
252
- name: faraday
253
246
  version_requirements: !ruby/object:Gem::Requirement
254
247
  requirements:
255
248
  - - '>='
256
249
  - !ruby/object:Gem::Version
257
250
  version: '0'
251
+ - !ruby/object:Gem::Dependency
258
252
  requirement: !ruby/object:Gem::Requirement
259
253
  requirements:
260
254
  - - '>='
261
255
  - !ruby/object:Gem::Version
262
256
  version: '0'
257
+ name: faraday
263
258
  prerelease: false
264
259
  type: :runtime
265
- - !ruby/object:Gem::Dependency
266
- name: crimp
267
260
  version_requirements: !ruby/object:Gem::Requirement
268
261
  requirements:
269
262
  - - '>='
270
263
  - !ruby/object:Gem::Version
271
264
  version: '0'
265
+ - !ruby/object:Gem::Dependency
272
266
  requirement: !ruby/object:Gem::Requirement
273
267
  requirements:
274
268
  - - '>='
275
269
  - !ruby/object:Gem::Version
276
270
  version: '0'
271
+ name: crimp
277
272
  prerelease: false
278
273
  type: :runtime
274
+ version_requirements: !ruby/object:Gem::Requirement
275
+ requirements:
276
+ - - '>='
277
+ - !ruby/object:Gem::Version
278
+ version: '0'
279
279
  description: Brokers requests for alephant components
280
280
  email:
281
281
  - stevenmajack@gmail.com