ruby-druid 0.11.2 → 0.11.3

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
- SHA256:
3
- metadata.gz: 5c242b82f9ca73bc79a18d0fed69b6f956f515900c363bd7878b53f10eaad62d
4
- data.tar.gz: e1699daefede54f60a9ac0e2be9b175b8d6dfd356c4550a36421933bd3e57866
2
+ SHA1:
3
+ metadata.gz: 50802fa6fd17c18928330f89aa8a9e8aa1b552c9
4
+ data.tar.gz: 52827d8bb44dc95de2335f9792ab79f211ed0ad0
5
5
  SHA512:
6
- metadata.gz: c9e438973e1a8816ebbd293a409aafbad9c015a29ffa93a55826bf4c13c741f223eb30597e059f7b35357941f818cdba791a9337ea0cb0833c45c6fd7a9a5842
7
- data.tar.gz: 5ac8395f4155f4c830bf6518e292a4fc7a7ce9b54df8337931072e5cd49409c1a54d739182ce82f6a148fcd040c8c3c0dde772d06ff192a0605363d27408cdfa
6
+ metadata.gz: 9606e256ba1341ba5de30371eb5a65307506131be89ebff99cbc21e2546f5e692a8487b89ad8d410e8491cfc2980dec00a79476400e1091a8cf92247726ab0c2
7
+ data.tar.gz: 82a3948ec8332ff637ba32b0a981fb07fdce8efc7e44c5d59a5c37ca70d5cd27d406988bb8c74071936ac28ec3a3cbfeef07a5453cad2825796413e35db5c1f0
data/README.md CHANGED
@@ -276,6 +276,13 @@ Druid::Query::Builder.new.filter{dimension => 1, dimension1 =>2, dimension2 => 3
276
276
  Druid::Query::Builder.new.filter{dimension.eq(1) & dimension1.eq(2) & dimension2.eq(3)}
277
277
  ```
278
278
 
279
+ ## Instrumentation
280
+
281
+ Provides a single event `post.druid`. Payload:
282
+
283
+ - `data_source`
284
+ - `query`
285
+
279
286
  ## Contributing
280
287
 
281
288
  1. Fork it
@@ -59,12 +59,16 @@ module Druid
59
59
  query.dataSource = name
60
60
 
61
61
  req = Net::HTTP::Post.new(uri.path, { 'Content-Type' => 'application/json' })
62
- req.body = query.to_json
62
+ query_as_json = query.as_json
63
+ req.body = MultiJson.dump(query_as_json)
63
64
 
64
- response = Net::HTTP.new(uri.host, uri.port).start do |http|
65
- http.open_timeout = 10 # if druid is down fail fast
66
- http.read_timeout = nil # we wait until druid is finished
67
- http.request(req)
65
+
66
+ response = ActiveSupport::Notifications.instrument('post.druid', data_source: name, query: query_as_json) do
67
+ Net::HTTP.new(uri.host, uri.port).start do |http|
68
+ http.open_timeout = 10 # if druid is down fail fast
69
+ http.read_timeout = nil # we wait until druid is finished
70
+ http.request(req)
71
+ end
68
72
  end
69
73
 
70
74
  if response.code != '200'
@@ -1,3 +1,3 @@
1
1
  module Druid
2
- VERSION = '0.11.2'
2
+ VERSION = '0.11.3'
3
3
  end
@@ -1,7 +1,8 @@
1
1
  describe Druid::DataSource do
2
2
 
3
3
  context '#post' do
4
- it 'parses response on 200' do
4
+ context 'if the request is succesful' do
5
+ before do
5
6
  # MRI
6
7
  stub_request(:post, "http://www.example.com/druid/v2").
7
8
  with(:body => "{\"context\":{\"queryId\":null},\"queryType\":\"timeseries\",\"intervals\":[\"2013-04-04T00:00:00+00:00/2013-04-04T00:00:00+00:00\"],\"granularity\":\"all\",\"dataSource\":\"test\"}",
@@ -12,12 +13,25 @@ describe Druid::DataSource do
12
13
  with(:body => "{\"context\":{\"queryId\":null},\"granularity\":\"all\",\"intervals\":[\"2013-04-04T00:00:00+00:00/2013-04-04T00:00:00+00:00\"],\"queryType\":\"timeseries\",\"dataSource\":\"test\"}",
13
14
  :headers => { 'Accept' => '*/*', 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Content-Type' => 'application/json', 'User-Agent' => 'Ruby' }).
14
15
  to_return(:status => 200, :body => '[]', :headers => {})
16
+ end
17
+
18
+ it 'parses response on 200' do
15
19
  ds = Druid::DataSource.new('test/test', 'http://www.example.com/druid/v2')
16
20
  query = Druid::Query::Builder.new.interval('2013-04-04', '2013-04-04').granularity(:all).query
17
21
  query.context.queryId = nil
18
22
  expect(ds.post(query)).to be_empty
19
23
  end
20
24
 
25
+ it 'instruments requests' do
26
+ expect(ActiveSupport::Notifications).to receive(:instrument).with('post.druid', data_source: 'test', query: instance_of(Hash)).and_call_original
27
+
28
+ ds = Druid::DataSource.new('test/test', 'http://www.example.com/druid/v2')
29
+ query = Druid::Query::Builder.new.interval('2013-04-04', '2013-04-04').granularity(:all).query
30
+ query.context.queryId = nil
31
+ ds.post(query)
32
+ end
33
+ end
34
+
21
35
  it 'raises on request failure' do
22
36
  stub_request(:post, 'http://www.example.com/druid/v2')
23
37
  .with(
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-druid
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.11.2
4
+ version: 0.11.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ruby Druid Community
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-11-04 00:00:00.000000000 Z
11
+ date: 2020-11-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -165,7 +165,7 @@ dependencies:
165
165
  description: |2
166
166
  ruby-druid is a Ruby client for Druid. It includes a Squeel-like query DSL
167
167
  and generates a JSON query that can be sent to Druid directly.
168
- email:
168
+ email:
169
169
  executables: []
170
170
  extensions: []
171
171
  extra_rdoc_files: []
@@ -195,7 +195,7 @@ homepage: https://github.com/ruby-druid/ruby-druid
195
195
  licenses:
196
196
  - MIT
197
197
  metadata: {}
198
- post_install_message:
198
+ post_install_message:
199
199
  rdoc_options: []
200
200
  require_paths:
201
201
  - lib
@@ -210,8 +210,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
210
210
  - !ruby/object:Gem::Version
211
211
  version: '0'
212
212
  requirements: []
213
- rubygems_version: 3.0.3
214
- signing_key:
213
+ rubyforge_project:
214
+ rubygems_version: 2.6.11
215
+ signing_key:
215
216
  specification_version: 4
216
217
  summary: A Ruby client for Druid
217
218
  test_files: