elasticsearch-rails 8.0.0.pre → 8.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +1 -1
- data/README.md +13 -12
- data/lib/elasticsearch/rails/instrumentation/log_subscriber.rb +12 -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 +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: feb6cc50443134d9f6bc424aee2e46edd208f111d98b66e0bcba2c13eed8905f
|
4
|
+
data.tar.gz: bc01ddaec5725cc35431e89318eef5d021c8eadb12fe6ae047419adaec82e9d2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: daba8716f145f0b4ffbb953832eff315c3c09821a1439923fbc9ed8ac7d3e3bd2c6e9dc0a3e37f97b355d2bac828329ef0ee3b23786977d9c96117faed92ab87
|
7
|
+
data.tar.gz: d7956874bf60225e7d6d2d520951b446feb32b1b184836e86b8a04592c4d860cedbfd604be143a57d1afaf8be26118ae91dc4c6abf091a409a6556706ffa6a98
|
data/Gemfile
CHANGED
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
|
@@ -46,8 +46,19 @@ module Elasticsearch
|
|
46
46
|
payload = event.payload
|
47
47
|
name = "#{payload[:klass]} #{payload[:name]} (#{event.duration.round(1)}ms)"
|
48
48
|
search = payload[:search].inspect.gsub(/:(\w+)=>/, '\1: ')
|
49
|
+
debug %Q| #{color(name, GREEN, color_option(true))} #{colorize_logging ? "\e[2m#{search}\e[0m" : search}|
|
50
|
+
end
|
51
|
+
|
52
|
+
private
|
53
|
+
|
54
|
+
def color_option(bold_value)
|
55
|
+
new_color_syntax? ? { bold: bold_value } : bold_value
|
56
|
+
end
|
57
|
+
|
58
|
+
def new_color_syntax?
|
59
|
+
return @new_color_syntax if defined?(@new_color_syntax)
|
49
60
|
|
50
|
-
|
61
|
+
@new_color_syntax = ::Rails.respond_to?(:gem_version) && ::Rails.gem_version >= '7.1'
|
51
62
|
end
|
52
63
|
end
|
53
64
|
|
@@ -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 Rails version is older" do
|
43
|
+
let(:rails_version) { "7.0.0" }
|
44
|
+
|
45
|
+
before do
|
46
|
+
allow(::Rails).to receive(:gem_version) { Gem::Version.new(rails_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_call_original
|
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,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: elasticsearch-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 8.0.0
|
4
|
+
version: 8.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Elastic Client Library Maintainers
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-05-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -275,6 +275,7 @@ files:
|
|
275
275
|
- lib/rails/templates/searchable.dsl.rb
|
276
276
|
- lib/rails/templates/searchable.rb
|
277
277
|
- lib/rails/templates/seeds.rb
|
278
|
+
- spec/instrumentation/log_subscriber_spec.rb
|
278
279
|
- spec/instrumentation_spec.rb
|
279
280
|
- spec/lograge_spec.rb
|
280
281
|
- spec/spec_helper.rb
|
@@ -302,11 +303,12 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
302
303
|
- !ruby/object:Gem::Version
|
303
304
|
version: '0'
|
304
305
|
requirements: []
|
305
|
-
rubygems_version: 3.5.
|
306
|
+
rubygems_version: 3.5.9
|
306
307
|
signing_key:
|
307
308
|
specification_version: 4
|
308
309
|
summary: Ruby on Rails integrations for Elasticsearch.
|
309
310
|
test_files:
|
311
|
+
- spec/instrumentation/log_subscriber_spec.rb
|
310
312
|
- spec/instrumentation_spec.rb
|
311
313
|
- spec/lograge_spec.rb
|
312
314
|
- spec/spec_helper.rb
|