elastic-transport 8.3.1 → 8.3.5

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
  SHA256:
3
- metadata.gz: 6bb7bc2413d7967ff3ab408dc2615d71e1140a240f34f2b67c21550705c42b3d
4
- data.tar.gz: 82ba1e4d3be8ddb205b6d25c10ebffed36e20b6e267251122c80e1d1c87c3950
3
+ metadata.gz: a4543af71a663d5f638c673407101529237507d56e7e2034f0c7e9fd5dd78c6a
4
+ data.tar.gz: 39a000ce02f4cf2208d0ec41f51f133e74454748f90eb6617d08bac3aad7e572
5
5
  SHA512:
6
- metadata.gz: fb8b615d737254668a504439eede4e41e42327097a2160f66eee04cf84ff2bd26e89230f261870fab9aad337080a5562326a52792b8059e5f735a4e757d5ac29
7
- data.tar.gz: 342e0ad9f8c38e64cce7bebd45c706d4365449627c6ef31ffced9a7822c4250b1b76a156265ae9d8775874e864fb2f061bde0d76745ad9ed362f9cdd19bf5bbb
6
+ metadata.gz: 747447a8e84b3f71f1b8244237809c2087e60de35426820d065de72fb57b9ab17094ee1fb95e2f228c41902098b1d2ba8fd1f248f6d2cf493785d50745c08ec0
7
+ data.tar.gz: 6923af2b78bf3a8ecb956038a878f1752723546dfdabd3d6d3492f545f9d51312807a8faf7a8e1adee21b34034d95569b01939172198eb572709d16e6e5ace53
@@ -4,7 +4,7 @@ jobs:
4
4
  build:
5
5
  runs-on: ubuntu-latest
6
6
  steps:
7
- - uses: actions/checkout@v3
7
+ - uses: actions/checkout@v4
8
8
  - uses: ruby/setup-ruby@v1
9
9
  with:
10
10
  ruby-version: 3
@@ -17,10 +17,10 @@ jobs:
17
17
  fail-fast: false
18
18
  matrix:
19
19
  ruby: ['3.3', 'jruby-9.4']
20
- es_version: ['8.12-SNAPSHOT']
20
+ es_version: ['8.15.0-SNAPSHOT']
21
21
  runs-on: ubuntu-latest
22
22
  steps:
23
- - uses: actions/checkout@v2
23
+ - uses: actions/checkout@v4
24
24
  - name: Increase system limits
25
25
  run: |
26
26
  sudo swapoff -a
@@ -15,11 +15,11 @@ jobs:
15
15
  strategy:
16
16
  fail-fast: false
17
17
  matrix:
18
- ruby: [ '3.0', '3.1', '3.2', '3.3', 'jruby-9.3', 'jruby-9.4' ]
19
- es_version: ['8.10-SNAPSHOT', '8.11-SNAPSHOT', '8.12-SNAPSHOT']
18
+ ruby: ['3.0', '3.1', '3.2', '3.3', 'jruby-9.3', 'jruby-9.4']
19
+ es_version: ['8.14.2-SNAPSHOT', '8.15.0-SNAPSHOT', '8.16.0-SNAPSHOT']
20
20
  runs-on: ubuntu-latest
21
21
  steps:
22
- - uses: actions/checkout@v3
22
+ - uses: actions/checkout@v4
23
23
  - name: Increase system limits
24
24
  run: |
25
25
  sudo swapoff -a
@@ -53,11 +53,11 @@ jobs:
53
53
  strategy:
54
54
  fail-fast: false
55
55
  matrix:
56
- ruby: [ '3.0', '3.1', '3.2', '3.3', 'jruby-9.3' ]
57
- es_version: ['8.12-SNAPSHOT']
56
+ ruby: ['3.0', '3.1', '3.2', '3.3', 'jruby-9.3']
57
+ es_version: ['8.16.0-SNAPSHOT']
58
58
  runs-on: ubuntu-latest
59
59
  steps:
60
- - uses: actions/checkout@v3
60
+ - uses: actions/checkout@v4
61
61
  - name: Increase system limits
62
62
  run: |
63
63
  sudo swapoff -a
@@ -76,7 +76,6 @@ jobs:
76
76
  sudo apt-get update
77
77
  sudo apt-get install libcurl4-openssl-dev
78
78
  ruby -v
79
- gem install bundler
80
79
  BUNDLE_GEMFILE=./Gemfile-faraday1.gemfile bundle install
81
80
  - name: faraday1 unit tests
82
81
  run: BUNDLE_GEMFILE=./Gemfile-faraday1.gemfile bundle exec rake test:faraday1:unit
data/CHANGELOG.md CHANGED
@@ -1,3 +1,17 @@
1
+ ## 8.3.5
2
+
3
+ - Small updates in source code documentation.
4
+ - Updates meta header for Elasticsearch Serverless.
5
+ - Fixes issues with ES_SERVERLESS_SERVICE_VERSION for backwards compatibility
6
+
7
+ ## 8.3.3, 8.3.4 (yanked)
8
+
9
+ - Yanked due to errors.
10
+
11
+ ## 8.3.2
12
+
13
+ - OpenTelemetry: In v8.3.0 and v8.3.1, the environment variable `OTEL_INSTRUMENTATION_ELASTICSEARCH_CAPTURE_SEARCH_QUERY` was available but is now deprecated in favor of `OTEL_RUBY_INSTRUMENTATION_ELASTICSEARCH_CAPTURE_SEARCH_QUERY`.
14
+
1
15
  ## 8.3.1
2
16
 
3
17
  Tested versions of Ruby: (MRI) 3.0, 3.1, 3.2, 3.3, JRuby 9.3 and JRuby 9.4
data/Gemfile CHANGED
@@ -23,16 +23,14 @@ gemspec
23
23
  group :development, :test do
24
24
  gem 'faraday-httpclient'
25
25
  gem 'faraday-net_http_persistent'
26
- gem 'faraday-patron' unless defined? JRUBY_VERSION
27
26
  gem 'faraday-typhoeus'
28
- gem 'rspec'
29
- gem 'oj' unless defined? JRUBY_VERSION
27
+ gem 'opentelemetry-sdk', require: false if RUBY_VERSION >= '3.0'
30
28
  if defined?(JRUBY_VERSION)
31
29
  gem 'pry-nav'
32
30
  else
31
+ gem 'faraday-patron'
32
+ gem 'oj'
33
33
  gem 'pry-byebug'
34
34
  end
35
- if RUBY_VERSION >= '3.0'
36
- gem 'opentelemetry-sdk', require: false
37
- end
35
+ gem 'rspec'
38
36
  end
@@ -23,18 +23,18 @@ source 'https://rubygems.org'
23
23
  # $ BUNDLE_GEMFILE=./Gemfile-faraday1.gemfile bundle exec rake test:faraday1:unit
24
24
 
25
25
  gem 'faraday', '~> 1'
26
- gemspec path: './'
26
+ gemspec
27
27
 
28
28
  group :development, :test do
29
29
  gem 'httpclient'
30
30
  gem 'net-http-persistent'
31
- gem 'patron' unless defined? JRUBY_VERSION
32
31
  gem 'rspec'
33
32
  gem 'typhoeus'
34
- gem 'oj' unless defined? JRUBY_VERSION
35
33
  if defined?(JRUBY_VERSION)
36
34
  gem 'pry-nav'
37
35
  else
38
36
  gem 'pry-byebug'
37
+ gem 'oj'
38
+ gem 'patron'
39
39
  end
40
40
  end
@@ -83,7 +83,7 @@ module Elastic
83
83
  #
84
84
  # @option arguments [Integer] :sniffer_timeout Timeout for reloading connections in seconds (1 by default)
85
85
  #
86
- # @option arguments [Boolean,Number] :retry_on_failure Retry X times when request fails before raising and
86
+ # @option arguments [Boolean,Number] :retry_on_failure Retry X times when request fails before raising an
87
87
  # exception (false by default)
88
88
  # @option arguments [Number] :delay_on_retry Delay in milliseconds between each retry (0 by default)
89
89
  #
@@ -91,7 +91,8 @@ module Elastic
91
91
  #
92
92
  # @option arguments [Boolean] :reload_on_failure Reload connections after failure (false by default)
93
93
  #
94
- # @option arguments [Integer] :request_timeout The request timeout to be passed to transport in options
94
+ # @option arguments [Integer] :request_timeout The request timeout to be passed to transport in options in seconds
95
+ # (the default value is taken from the transport)
95
96
  #
96
97
  # @option arguments [Symbol] :adapter A specific adapter for Faraday (e.g. `:patron`)
97
98
  #
@@ -110,7 +111,7 @@ module Elastic
110
111
  #
111
112
  # @option arguments [String] :send_get_body_as Specify the HTTP method to use for GET requests with a body.
112
113
  # (Default: GET)
113
- # @option arguments [true, false] :compression Whether to compress requests. Gzip compression will be used.
114
+ # @option arguments [Boolean] :compression Whether to compress requests. Gzip compression will be used.
114
115
  # The default is false. Responses will automatically be inflated if they are compressed.
115
116
  # If a custom transport object is used, it must handle the request compression and response inflation.
116
117
  #
@@ -172,7 +173,7 @@ module Elastic
172
173
  # Performs a request through delegation to {#transport}.
173
174
  #
174
175
  def perform_request(method, path, params = {}, body = nil, headers = nil, opts = {})
175
- method = @send_get_body_as if 'GET' == method && body
176
+ method = @send_get_body_as if method == 'GET' && body
176
177
  validate_ca_fingerprints if @ca_fingerprint
177
178
  if @otel
178
179
  # If no endpoint is specified in the opts, use the HTTP method name
@@ -41,6 +41,12 @@ module Elastic
41
41
  def meta_header_service_version
42
42
  if enterprise_search?
43
43
  Elastic::ENTERPRISE_SERVICE_VERSION
44
+ elsif serverless?
45
+ if defined?(Elastic::ES_SERVERLESS_SERVICE_VERSION)
46
+ Elastic::ES_SERVERLESS_SERVICE_VERSION
47
+ else
48
+ Elastic::ELASTICSEARCH_SERVICE_VERSION
49
+ end
44
50
  elsif elasticsearch?
45
51
  Elastic::ELASTICSEARCH_SERVICE_VERSION
46
52
  elsif defined?(Elasticsearch::VERSION)
@@ -60,6 +66,11 @@ module Elastic
60
66
  called_from?('elasticsearch')
61
67
  end
62
68
 
69
+ def serverless?
70
+ defined?(ElasticsearchServerless::CLIENT_VERSION) &&
71
+ called_from?('elasticsearch-serverless')
72
+ end
73
+
63
74
  def called_from?(service)
64
75
  !caller.select { |c| c.match?(service) }.empty?
65
76
  end
@@ -70,7 +81,7 @@ module Elastic
70
81
  def client_meta_version(version)
71
82
  regexp = /^([0-9]+\.[0-9]+\.[0-9]+)(\.?[a-z0-9.-]+)?$/
72
83
  match = version.match(regexp)
73
- return "#{match[1]}p" if (match[2])
84
+ return "#{match[1]}p" if match[2]
74
85
 
75
86
  version
76
87
  end
@@ -27,7 +27,8 @@ module Elastic
27
27
  # Describes how to handle search queries in the request body when assigned to
28
28
  # a span attribute.
29
29
  # Valid values are 'raw', 'omit', 'sanitize'. Default is 'omit'.
30
- ENV_VARIABLE_BODY_STRATEGY = 'OTEL_INSTRUMENTATION_ELASTICSEARCH_CAPTURE_SEARCH_QUERY'
30
+ ENV_VARIABLE_BODY_STRATEGY = 'OTEL_RUBY_INSTRUMENTATION_ELASTICSEARCH_CAPTURE_SEARCH_QUERY'
31
+ ENV_VARIABLE_DEPRECATED_BODY_STRATEGY = 'OTEL_INSTRUMENTATION_ELASTICSEARCH_CAPTURE_SEARCH_QUERY'
31
32
  DEFAULT_BODY_STRATEGY = 'omit'
32
33
  # A string list of keys whose values are redacted. This is only relevant if the body strategy is
33
34
  # 'sanitize'. For example, a config 'sensitive-key,other-key' will redact the values at
@@ -53,7 +54,8 @@ module Elastic
53
54
  @tracer = (opts[:opentelemetry_tracer_provider] || ::OpenTelemetry.tracer_provider).tracer(
54
55
  OTEL_TRACER_NAME, Elastic::Transport::VERSION
55
56
  )
56
- @body_strategy = ENV[ENV_VARIABLE_BODY_STRATEGY] || DEFAULT_BODY_STRATEGY
57
+ @body_strategy = ENV[ENV_VARIABLE_DEPRECATED_BODY_STRATEGY] || ENV[ENV_VARIABLE_BODY_STRATEGY] ||
58
+ DEFAULT_BODY_STRATEGY
57
59
  @sanitize_keys = ENV[ENV_VARIABLE_BODY_SANITIZE_KEYS]&.split(',')&.collect! do |pattern|
58
60
  Regexp.new(pattern.gsub('*', '.*'))
59
61
  end
@@ -24,7 +24,7 @@ module Elastic
24
24
  module Base
25
25
  # @param transport [Object] The instance of transport which uses this serializer
26
26
  #
27
- def initialize(transport=nil)
27
+ def initialize(transport = nil)
28
28
  @transport = transport
29
29
  end
30
30
  end
@@ -36,13 +36,13 @@ module Elastic
36
36
 
37
37
  # De-serialize a Hash from JSON string
38
38
  #
39
- def load(string, options={})
39
+ def load(string, options = {})
40
40
  ::MultiJson.load(string, options)
41
41
  end
42
42
 
43
43
  # Serialize a Hash to JSON string
44
44
  #
45
- def dump(object, options={})
45
+ def dump(object, options = {})
46
46
  ::MultiJson.dump(object, options)
47
47
  end
48
48
  end
@@ -17,6 +17,6 @@
17
17
 
18
18
  module Elastic
19
19
  module Transport
20
- VERSION = '8.3.1'.freeze
20
+ VERSION = '8.3.5'.freeze
21
21
  end
22
22
  end
@@ -131,6 +131,25 @@ if defined?(::OpenTelemetry)
131
131
  end
132
132
  end
133
133
 
134
+ context 'with deprecated ENV variable' do
135
+ let(:sanitized_body) do
136
+ { query: { match: { password: 'REDACTED' } } }
137
+ end
138
+
139
+ around(:example) do |ex|
140
+ body_strategy = ENV[described_class::ENV_VARIABLE_DEPRECATED_BODY_STRATEGY]
141
+ ENV[described_class::ENV_VARIABLE_DEPRECATED_BODY_STRATEGY] = 'sanitize'
142
+ ex.run
143
+ ENV[described_class::ENV_VARIABLE_DEPRECATED_BODY_STRATEGY] = body_strategy
144
+ end
145
+
146
+ it 'sanitizes the body' do
147
+ client.perform_request('GET', '/_search', nil, body, nil, endpoint: 'search')
148
+
149
+ expect(span.attributes['db.statement']).to eq(sanitized_body.to_json)
150
+ end
151
+ end
152
+
134
153
  context 'with custom keys' do
135
154
  let(:body) do
136
155
  { query: { match: { sensitive: { query: 'secret'} } } }
@@ -20,66 +20,66 @@ require 'test_helper'
20
20
  class Elastic::Transport::Transport::Connections::ConnectionTest < Minitest::Test
21
21
  include Elastic::Transport::Transport::Connections
22
22
 
23
- context "Connection" do
24
- should "be initialized with :host, :connection, and :options" do
23
+ context 'Connection' do
24
+ should 'be initialized with :host, :connection, and :options' do
25
25
  c = Connection.new :host => 'x', :connection => 'y', :options => {}
26
26
  assert_equal 'x', c.host
27
27
  assert_equal 'y', c.connection
28
28
  assert_instance_of Hash, c.options
29
29
  end
30
30
 
31
- should "return full path" do
31
+ should 'return full path' do
32
32
  c = Connection.new
33
33
  assert_equal '_search', c.full_path('_search')
34
34
  assert_equal '_search', c.full_path('_search', {})
35
- assert_equal '_search?foo=bar', c.full_path('_search', {:foo => 'bar'})
36
- assert_equal '_search?foo=bar+bam', c.full_path('_search', {:foo => 'bar bam'})
35
+ assert_equal '_search?foo=bar', c.full_path('_search', {foo: 'bar'})
36
+ assert_equal '_search?foo=bar+bam', c.full_path('_search', {foo: 'bar bam'})
37
37
  end
38
38
 
39
- should "return full url" do
40
- c = Connection.new :host => { :protocol => 'http', :host => 'localhost', :port => '9200' }
41
- assert_equal 'http://localhost:9200/_search?foo=bar', c.full_url('_search', {:foo => 'bar'})
39
+ should 'return full url' do
40
+ c = Connection.new host: { protocol: 'http', host: 'localhost', port: '9200' }
41
+ assert_equal 'http://localhost:9200/_search?foo=bar', c.full_url('_search', { foo: 'bar' })
42
42
  end
43
43
 
44
- should "return full url with credentials" do
45
- c = Connection.new :host => { :protocol => 'http', :user => 'U', :password => 'P', :host => 'localhost', :port => '9200' }
46
- assert_equal 'http://U:P@localhost:9200/_search?foo=bar', c.full_url('_search', {:foo => 'bar'})
44
+ should 'return full url with credentials' do
45
+ c = Connection.new host: { protocol: 'http', user: 'U', password: 'P', host: 'localhost', port: '9200' }
46
+ assert_equal 'http://U:P@localhost:9200/_search?foo=bar', c.full_url('_search', { foo: 'bar' })
47
47
  end
48
48
 
49
- should "return full url with escaped credentials" do
50
- c = Connection.new :host => { :protocol => 'http', :user => 'U$$$', :password => 'P^^^', :host => 'localhost', :port => '9200' }
51
- assert_equal 'http://U%24%24%24:P%5E%5E%5E@localhost:9200/_search?foo=bar', c.full_url('_search', {:foo => 'bar'})
49
+ should 'return full url with escaped credentials' do
50
+ c = Connection.new host: { protocol: 'http', user: 'U$$$', password: 'P^^^', host: 'localhost', port: '9200' }
51
+ assert_equal 'http://U%24%24%24:P%5E%5E%5E@localhost:9200/_search?foo=bar', c.full_url('_search', { foo: 'bar' })
52
52
  end
53
53
 
54
- should "return full url with path" do
55
- c = Connection.new :host => { :protocol => 'http', :host => 'localhost', :port => '9200', :path => '/foo' }
56
- assert_equal 'http://localhost:9200/foo/_search?foo=bar', c.full_url('_search', {:foo => 'bar'})
54
+ should 'return full url with path' do
55
+ c = Connection.new host: { protocol: 'http', host: 'localhost', port: '9200', path: '/foo' }
56
+ assert_equal 'http://localhost:9200/foo/_search?foo=bar', c.full_url('_search', { foo: 'bar' })
57
57
  end
58
58
 
59
- should "return right full url with path when path starts with /" do
60
- c = Connection.new :host => { :protocol => 'http', :host => 'localhost', :port => '9200', :path => '/foo' }
61
- assert_equal 'http://localhost:9200/foo/_search?foo=bar', c.full_url('/_search', {:foo => 'bar'})
59
+ should 'return right full url with path when path starts with /' do
60
+ c = Connection.new host: { protocol: 'http', host: 'localhost', port: '9200', path: '/foo' }
61
+ assert_equal 'http://localhost:9200/foo/_search?foo=bar', c.full_url('/_search', { foo: 'bar' })
62
62
  end
63
63
 
64
- should "have a string representation" do
65
- c = Connection.new :host => 'x'
64
+ should 'have a string representation' do
65
+ c = Connection.new(host: 'x')
66
66
  assert_match(/host: x/, c.to_s)
67
67
  assert_match(/alive/, c.to_s)
68
68
  end
69
69
 
70
- should "not be dead by default" do
70
+ should 'not be dead by default' do
71
71
  c = Connection.new
72
72
  assert ! c.dead?
73
73
  end
74
74
 
75
- should "be dead when marked" do
75
+ should 'be dead when marked' do
76
76
  c = Connection.new.dead!
77
77
  assert c.dead?
78
78
  assert_equal 1, c.failures
79
79
  assert_in_delta c.dead_since, Time.now, 1
80
80
  end
81
81
 
82
- should "be alive when marked" do
82
+ should 'be alive when marked' do
83
83
  c = Connection.new.dead!
84
84
  assert c.dead?
85
85
  assert_equal 1, c.failures
@@ -90,7 +90,7 @@ class Elastic::Transport::Transport::Connections::ConnectionTest < Minitest::Tes
90
90
  assert_equal 1, c.failures
91
91
  end
92
92
 
93
- should "be healthy when marked" do
93
+ should 'be healthy when marked' do
94
94
  c = Connection.new.dead!
95
95
  assert c.dead?
96
96
  assert_equal 1, c.failures
@@ -101,35 +101,33 @@ class Elastic::Transport::Transport::Connections::ConnectionTest < Minitest::Tes
101
101
  assert_equal 0, c.failures
102
102
  end
103
103
 
104
- should "be resurrected if timeout passed" do
104
+ should 'be resurrected if timeout passed' do
105
105
  c = Connection.new.dead!
106
106
 
107
107
  now = Time.now + 60
108
108
  Time.stubs(:now).returns(now)
109
109
 
110
- assert c.resurrect!, c.inspect
111
- assert ! c.dead?, c.inspect
110
+ assert(c.resurrect!, c.inspect)
111
+ assert(!c.dead?, c.inspect)
112
112
  end
113
113
 
114
- should "be resurrected if timeout passed for multiple failures" do
114
+ should 'be resurrected if timeout passed for multiple failures' do
115
115
  c = Connection.new.dead!.dead!
116
116
 
117
- now = Time.now + 60*2
117
+ now = Time.now + 60 * 2
118
118
  Time.stubs(:now).returns(now)
119
119
 
120
120
  assert c.resurrect!, c.inspect
121
121
  assert ! c.dead?, c.inspect
122
122
  end
123
123
 
124
- should "implement the equality operator" do
125
- c1 = Connection.new(:host => { :protocol => 'http', :host => 'foo', :port => 123 })
126
- c2 = Connection.new(:host => { :protocol => 'http', :host => 'foo', :port => 123 })
127
- c3 = Connection.new(:host => { :protocol => 'http', :host => 'foo', :port => 456 })
124
+ should 'implement the equality operator' do
125
+ c1 = Connection.new(host: { protocol: 'http', host: 'foo', port: 123 })
126
+ c2 = Connection.new(host: { protocol: 'http', host: 'foo', port: 123 })
127
+ c3 = Connection.new(host: { protocol: 'http', host: 'foo', port: 456 })
128
128
 
129
129
  assert c1 == c2, "Connection #{c1} should be equal to #{c2}"
130
130
  assert c2 != c3, "Connection #{c2} should NOT be equal to #{c3}"
131
131
  end
132
-
133
132
  end
134
-
135
133
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: elastic-transport
3
3
  version: !ruby/object:Gem::Version
4
- version: 8.3.1
4
+ version: 8.3.5
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-01-24 00:00:00.000000000 Z
11
+ date: 2024-07-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -340,7 +340,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
340
340
  - !ruby/object:Gem::Version
341
341
  version: '0'
342
342
  requirements: []
343
- rubygems_version: 3.5.3
343
+ rubygems_version: 3.4.19
344
344
  signing_key:
345
345
  specification_version: 4
346
346
  summary: Low level Ruby client for Elastic services.