elastomer-client 0.5.0 → 0.5.1

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: 1ef2b4c790e85cb9d9141c34ae1945b230cadeb8
4
- data.tar.gz: 463229368a9644620aab366e4ad67efa393e47fa
3
+ metadata.gz: eee472ee555f628e95e3dd97d76ead36bc509e41
4
+ data.tar.gz: a56d61d1c97b089af9170a1e662b835b6c6def50
5
5
  SHA512:
6
- metadata.gz: 904e906d03a23949bc0725932be4d7aaf6cd23185ab5a382160c7611e6c500adc03283813068a3fdfca5d067253736b309c7a74767d0c1a1a0d28b6a5e689689
7
- data.tar.gz: 0f0d9fcb4527e8a0b1e43df7fba7c2d5fb822c78e8270e4ec4e239d0439647bbe6afbe2f569093ec0cffed21623187b1420ee3d7c4b4ae5148f6dd8accbe7ef9
6
+ metadata.gz: 62ec42794c0799c52152e5b2ce6962b241c6dde67d46d402466957c5582c8b2ffd0b4cde9ddbdd355c71516f87bc60fba59f470b735b7dfb28c34731a2e35c7f
7
+ data.tar.gz: 837d5438ca92b8d4b7296a2086504fffb51b01daa39003fbbb2b9d2b5407ddb30a76846fdaf53c552c6a6148b0a57270ca37735275b02dde809579d7cce07c9e
@@ -20,7 +20,7 @@ module Elastomer
20
20
  # The payload contains the following bits of information:
21
21
  #
22
22
  # * :index - index name (if any)
23
- # * :type - documeht type (if any)
23
+ # * :type - document type (if any)
24
24
  # * :action - the action being performed
25
25
  # * :url - request URL
26
26
  # * :method - request method (:head, :get, :put, :post, :delete)
@@ -42,7 +42,7 @@ module Elastomer
42
42
  # The name to subscribe to for notifications
43
43
  NAME = 'request.client.elastomer'.freeze
44
44
 
45
- # Internal: Execute the given block and provide instrumentaiton info to
45
+ # Internal: Execute the given block and provide instrumentation info to
46
46
  # subscribers. The name we use for subscriptions is
47
47
  # `request.client.elastomer` and a supplemental payload is provided with
48
48
  # more information about the specific ElasticSearch request.
@@ -55,18 +55,20 @@ module Elastomer
55
55
  # Returns the response from the block
56
56
  def instrument( path, body, params )
57
57
  payload = {
58
- :index => params[:index],
59
- :type => params[:type],
60
- :action => params[:action],
61
- :context => params[:context],
62
- :body => body
58
+ :index => params[:index],
59
+ :type => params[:type],
60
+ :action => params[:action],
61
+ :context => params[:context],
62
+ :request_body => body,
63
+ :body => body # for backwards compatibility
63
64
  }
64
65
 
65
66
  ::Elastomer::Notifications.service.instrument(NAME, payload) do
66
67
  response = yield
67
- payload[:url] = response.env[:url]
68
- payload[:method] = response.env[:method]
69
- payload[:status] = response.status
68
+ payload[:url] = response.env[:url]
69
+ payload[:method] = response.env[:method]
70
+ payload[:status] = response.status
71
+ payload[:response_body] = response.body
70
72
  response
71
73
  end
72
74
  end
@@ -1,5 +1,5 @@
1
1
  module Elastomer
2
- VERSION = '0.5.0'
2
+ VERSION = '0.5.1'
3
3
 
4
4
  def self.version
5
5
  VERSION
@@ -56,6 +56,22 @@ describe Elastomer::Notifications do
56
56
  @index.delete; assert_action_event('index.delete')
57
57
  end
58
58
 
59
+ it 'includes the response body in the payload' do
60
+ @index.create('number_of_replicas' => 0)
61
+ event = @events.detect { |e| e.payload[:action] == 'index.create' }
62
+ assert event.payload[:response_body]
63
+ end
64
+
65
+ it 'includes the request body in the payload' do
66
+ @index.create('number_of_replicas' => 0)
67
+ event = @events.detect { |e| e.payload[:action] == 'index.create' }
68
+
69
+ payload = event.payload
70
+ assert payload[:response_body]
71
+ assert payload[:request_body]
72
+ assert_same payload[:body], payload[:request_body]
73
+ end
74
+
59
75
  def assert_action_event(action)
60
76
  assert @events.detect { |e| e.payload[:action] == action }, "expected #{action} event"
61
77
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: elastomer-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tim Pease
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-01-21 00:00:00.000000000 Z
12
+ date: 2015-04-03 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: addressable