elasticsearch-rails 8.0.0.pre → 8.0.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/README.md +13 -12
- data/lib/elasticsearch/rails/instrumentation/log_subscriber.rb +12 -3
- data/lib/elasticsearch/rails/tasks/import.rb +0 -1
- data/lib/elasticsearch/rails/version.rb +1 -1
- data/spec/instrumentation/log_subscriber_spec.rb +57 -0
- data/spec/spec_helper.rb +1 -0
- metadata +6 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ad1605494dc4d7e8b3e47dbece4aa520f4407117f3abc0b774277e9a52baa0da
|
4
|
+
data.tar.gz: 19a2243d269e8ddb6ab17bb5e2e9272e4dc6bb36855b4fe83b84ea3eb82ef60e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2a9f94de3cd3b297af45123027010d0dce6ffcee38577a06f4fbfe1023b58eea8f257d3970ea05d8c2403e288ae03945d20789ef8a1b3f08a1577639d4e9b39a
|
7
|
+
data.tar.gz: 0c2f2455b7f27fcd1ee0c6b246f2bbc289655ffc920aed28a1b07cbe04cd38e9b2eb1e8ad433ce613c0c85787ff11e9bc2d71be7e0db921c8ea7a39ffd349a9b
|
data/README.md
CHANGED
@@ -6,18 +6,19 @@ library, providing features suitable for Ruby on Rails applications.
|
|
6
6
|
|
7
7
|
## Compatibility
|
8
8
|
|
9
|
-
This library is compatible with Ruby 1
|
9
|
+
This library is compatible with Ruby 3.1 and higher.
|
10
10
|
|
11
|
-
The version numbers follow the Elasticsearch major versions. Currently the `main` branch is compatible with version `
|
11
|
+
The version numbers follow the Elasticsearch major versions. Currently the `main` branch is compatible with version `8.x` of the Elasticsearch stack.
|
12
12
|
|
13
|
-
| Rubygem
|
14
|
-
|
15
|
-
| 0.1
|
16
|
-
| 2.x
|
17
|
-
| 5.x
|
18
|
-
| 6.x
|
19
|
-
| 7.x
|
20
|
-
|
|
13
|
+
| Rubygem | | Elasticsearch |
|
14
|
+
|:-------:|:-:|:-------------:|
|
15
|
+
| 0.1 | → | 1.x |
|
16
|
+
| 2.x | → | 2.x |
|
17
|
+
| 5.x | → | 5.x |
|
18
|
+
| 6.x | → | 6.x |
|
19
|
+
| 7.x | → | 7.x |
|
20
|
+
| 8.x | → | 8.x |
|
21
|
+
| main | → | 8.x |
|
21
22
|
|
22
23
|
## Installation
|
23
24
|
|
@@ -137,9 +138,9 @@ This software is licensed under the Apache 2 license, quoted below.
|
|
137
138
|
the Apache License, Version 2.0 (the "License"); you may
|
138
139
|
not use this file except in compliance with the License.
|
139
140
|
You may obtain a copy of the License at
|
140
|
-
|
141
|
+
|
141
142
|
http://www.apache.org/licenses/LICENSE-2.0
|
142
|
-
|
143
|
+
|
143
144
|
Unless required by applicable law or agreed to in writing,
|
144
145
|
software distributed under the License is distributed on an
|
145
146
|
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
@@ -18,7 +18,6 @@
|
|
18
18
|
module Elasticsearch
|
19
19
|
module Rails
|
20
20
|
module Instrumentation
|
21
|
-
|
22
21
|
# A log subscriber to attach to Elasticsearch related events
|
23
22
|
#
|
24
23
|
# @see https://github.com/rails/rails/blob/master/activerecord/lib/active_record/log_subscriber.rb
|
@@ -46,11 +45,21 @@ module Elasticsearch
|
|
46
45
|
payload = event.payload
|
47
46
|
name = "#{payload[:klass]} #{payload[:name]} (#{event.duration.round(1)}ms)"
|
48
47
|
search = payload[:search].inspect.gsub(/:(\w+)=>/, '\1: ')
|
48
|
+
debug %Q| #{color(name, GREEN, color_option(true))} #{colorize_logging ? "\e[2m#{search}\e[0m" : search}|
|
49
|
+
end
|
49
50
|
|
50
|
-
|
51
|
+
private
|
52
|
+
|
53
|
+
def color_option(bold_value)
|
54
|
+
new_color_syntax? ? { bold: bold_value } : bold_value
|
51
55
|
end
|
52
|
-
end
|
53
56
|
|
57
|
+
def new_color_syntax?
|
58
|
+
return @new_color_syntax if defined?(@new_color_syntax)
|
59
|
+
|
60
|
+
@new_color_syntax = ::ActiveSupport.respond_to?(:gem_version) && ::ActiveSupport::gem_version >= '7.1'
|
61
|
+
end
|
62
|
+
end
|
54
63
|
end
|
55
64
|
end
|
56
65
|
end
|
@@ -80,7 +80,6 @@ namespace :elasticsearch do
|
|
80
80
|
total_errors = klass.__elasticsearch__.import force: ENV.fetch('FORCE', false),
|
81
81
|
batch_size: ENV.fetch('BATCH', 1000).to_i,
|
82
82
|
index: ENV.fetch('INDEX', nil),
|
83
|
-
type: ENV.fetch('TYPE', nil),
|
84
83
|
scope: ENV.fetch('SCOPE', nil) do |response|
|
85
84
|
pbar.inc response['items'].size if pbar
|
86
85
|
STDERR.flush
|
@@ -0,0 +1,57 @@
|
|
1
|
+
# Licensed to Elasticsearch B.V. under one or more contributor
|
2
|
+
# license agreements. See the NOTICE file distributed with
|
3
|
+
# this work for additional information regarding copyright
|
4
|
+
# ownership. Elasticsearch B.V. licenses this file to you under
|
5
|
+
# the Apache License, Version 2.0 (the "License"); you may
|
6
|
+
# not use this file except in compliance with the License.
|
7
|
+
# You may obtain a copy of the License at
|
8
|
+
#
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
#
|
11
|
+
# Unless required by applicable law or agreed to in writing,
|
12
|
+
# software distributed under the License is distributed on an
|
13
|
+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
14
|
+
# KIND, either express or implied. See the License for the
|
15
|
+
# specific language governing permissions and limitations
|
16
|
+
# under the License.
|
17
|
+
|
18
|
+
require 'spec_helper'
|
19
|
+
require 'elasticsearch/rails/instrumentation/log_subscriber'
|
20
|
+
|
21
|
+
describe Elasticsearch::Rails::Instrumentation::LogSubscriber do
|
22
|
+
subject(:instance) { described_class.new }
|
23
|
+
|
24
|
+
let(:logger) { instance_double(Logger) }
|
25
|
+
|
26
|
+
before do
|
27
|
+
allow(instance).to receive(:logger) { logger }
|
28
|
+
end
|
29
|
+
|
30
|
+
describe '#search' do
|
31
|
+
subject { instance.search(event) }
|
32
|
+
|
33
|
+
let(:event) { double("search.elasticsearch", duration: 1.2345, payload: { name: "execute", search: { query: { match_all: {}}}}) }
|
34
|
+
|
35
|
+
it 'logs the event' do
|
36
|
+
expect(instance).to receive(:color).with(" execute (1.2ms)", described_class::GREEN, { bold: true }).and_call_original
|
37
|
+
expect(logger).to receive(:debug?) { true }
|
38
|
+
expect(logger).to receive(:debug).with(" \e[1m\e[32m execute (1.2ms)\e[0m \e[2m{query: {match_all: {}}}\e[0m")
|
39
|
+
subject
|
40
|
+
end
|
41
|
+
|
42
|
+
context 'when ActiveSupport version is older' do
|
43
|
+
let(:active_support_version) { '7.0.0' }
|
44
|
+
|
45
|
+
before do
|
46
|
+
allow(::ActiveSupport).to receive(:gem_version) { Gem::Version.new(active_support_version) }
|
47
|
+
end
|
48
|
+
|
49
|
+
it 'logs the event' do
|
50
|
+
expect(instance).to receive(:color).with(' execute (1.2ms)', described_class::GREEN, true).and_return "\e[1m\e[32m execute (1.2ms)\e[0m"
|
51
|
+
expect(logger).to receive(:debug?) { true }
|
52
|
+
expect(logger).to receive(:debug).with(" \e[1m\e[32m execute (1.2ms)\e[0m \e[2m{query: {match_all: {}}}\e[0m")
|
53
|
+
subject
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: elasticsearch-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 8.0.
|
4
|
+
version: 8.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Elastic Client Library Maintainers
|
8
|
-
autorequire:
|
9
8
|
bindir: bin
|
10
9
|
cert_chain: []
|
11
|
-
date:
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
12
11
|
dependencies:
|
13
12
|
- !ruby/object:Gem::Dependency
|
14
13
|
name: bundler
|
@@ -240,8 +239,8 @@ email:
|
|
240
239
|
executables: []
|
241
240
|
extensions: []
|
242
241
|
extra_rdoc_files:
|
243
|
-
- README.md
|
244
242
|
- LICENSE.txt
|
243
|
+
- README.md
|
245
244
|
files:
|
246
245
|
- ".gitignore"
|
247
246
|
- CHANGELOG.md
|
@@ -275,6 +274,7 @@ files:
|
|
275
274
|
- lib/rails/templates/searchable.dsl.rb
|
276
275
|
- lib/rails/templates/searchable.rb
|
277
276
|
- lib/rails/templates/seeds.rb
|
277
|
+
- spec/instrumentation/log_subscriber_spec.rb
|
278
278
|
- spec/instrumentation_spec.rb
|
279
279
|
- spec/lograge_spec.rb
|
280
280
|
- spec/spec_helper.rb
|
@@ -286,7 +286,6 @@ metadata:
|
|
286
286
|
changelog_uri: https://github.com/elastic/elasticsearch-rails/blob/main/CHANGELOG.md
|
287
287
|
source_code_uri: https://github.com/elastic/elasticsearch-rails/
|
288
288
|
bug_tracker_uri: https://github.com/elastic/elasticsearch-rails/issues
|
289
|
-
post_install_message:
|
290
289
|
rdoc_options:
|
291
290
|
- "--charset=UTF-8"
|
292
291
|
require_paths:
|
@@ -302,11 +301,11 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
302
301
|
- !ruby/object:Gem::Version
|
303
302
|
version: '0'
|
304
303
|
requirements: []
|
305
|
-
rubygems_version: 3.
|
306
|
-
signing_key:
|
304
|
+
rubygems_version: 3.7.1
|
307
305
|
specification_version: 4
|
308
306
|
summary: Ruby on Rails integrations for Elasticsearch.
|
309
307
|
test_files:
|
308
|
+
- spec/instrumentation/log_subscriber_spec.rb
|
310
309
|
- spec/instrumentation_spec.rb
|
311
310
|
- spec/lograge_spec.rb
|
312
311
|
- spec/spec_helper.rb
|