elastomer-client 0.5.0 → 0.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/elastomer/notifications.rb +12 -10
- data/lib/elastomer/version.rb +1 -1
- data/test/notifications_test.rb +16 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: eee472ee555f628e95e3dd97d76ead36bc509e41
|
4
|
+
data.tar.gz: a56d61d1c97b089af9170a1e662b835b6c6def50
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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 -
|
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
|
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
|
59
|
-
:type
|
60
|
-
:action
|
61
|
-
:context
|
62
|
-
:
|
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]
|
68
|
-
payload[:method]
|
69
|
-
payload[: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
|
data/lib/elastomer/version.rb
CHANGED
data/test/notifications_test.rb
CHANGED
@@ -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.
|
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-
|
12
|
+
date: 2015-04-03 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: addressable
|