elastic-transport 8.4.0 → 8.4.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/.github/workflows/otel.yml +1 -1
- data/.github/workflows/tests.yml +4 -3
- data/CHANGELOG.md +6 -1
- data/CONTRIBUTING.md +12 -1
- data/README.md +3 -4
- data/lib/elastic/transport/transport/base.rb +8 -4
- data/lib/elastic/transport/transport/connections/connection.rb +0 -1
- data/lib/elastic/transport/transport/errors.rb +2 -0
- data/lib/elastic/transport/transport/http/curb.rb +3 -4
- data/lib/elastic/transport/transport/sniffer.rb +2 -0
- data/lib/elastic/transport/version.rb +1 -1
- data/lib/elastic/transport.rb +0 -1
- data/spec/elastic/transport/opentelemetry_spec.rb +26 -9
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5634ceac3d52fa6af5174e9aad5ecf2613018e4a9977114305a9f3a42ee25909
|
4
|
+
data.tar.gz: 92acaa8ac6c08475e3dc91aa1132e1a719060b0bab0c05c94b3feae92f9cb83f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2cd0a8e98e8bf2cfa5964779042672f15ba4d968b0fadec444474dc2253584c9dc3cf5932ffb731415503a57719838e5aa05eec78e77e184fbc3eb762291c137
|
7
|
+
data.tar.gz: d7132ee663cd2984e5b34ea7827ff27010e69c66d6ad3dc2ca3571b6d4b516ab1004b7a45c7495e68e38a047defc66c947cd2c1a0a026086a3b718d6328dc1ed
|
data/.github/workflows/otel.yml
CHANGED
data/.github/workflows/tests.yml
CHANGED
@@ -6,6 +6,7 @@ on:
|
|
6
6
|
pull_request:
|
7
7
|
branches:
|
8
8
|
- main
|
9
|
+
workflow_dispatch:
|
9
10
|
jobs:
|
10
11
|
test:
|
11
12
|
name: 'Main tests'
|
@@ -15,8 +16,8 @@ jobs:
|
|
15
16
|
strategy:
|
16
17
|
fail-fast: false
|
17
18
|
matrix:
|
18
|
-
ruby: ['3.
|
19
|
-
es_version: ['8.
|
19
|
+
ruby: ['3.2', '3.3', '3.4', 'jruby-9.3', 'jruby-9.4', 'jruby-10.0']
|
20
|
+
es_version: ['8.18.8-SNAPSHOT', '8.19.5-SNAPSHOT', '9.0.8-SNAPSHOT', '9.1.5-SNAPSHOT', '9.2.0-SNAPSHOT']
|
20
21
|
runs-on: ubuntu-latest
|
21
22
|
steps:
|
22
23
|
- uses: actions/checkout@v4
|
@@ -54,7 +55,7 @@ jobs:
|
|
54
55
|
fail-fast: false
|
55
56
|
matrix:
|
56
57
|
ruby: ['3.0', '3.1', '3.2', '3.3', 'jruby-9.3']
|
57
|
-
es_version: ['8.
|
58
|
+
es_version: ['8.19.5-SNAPSHOT']
|
58
59
|
runs-on: ubuntu-latest
|
59
60
|
steps:
|
60
61
|
- uses: actions/checkout@v4
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
## 8.4.1
|
2
|
+
|
3
|
+
- Moves `require 'timeout'` to the classes that use it. Closed [#79](https://github.com/elastic/elastic-transport-ruby/issues/79).
|
4
|
+
- Sanitize url on OTEL spans, thanks @steve21168. Pull Request: [#98](https://github.com/elastic/elastic-transport-ruby/pull/98)
|
5
|
+
|
1
6
|
## 8.4.0
|
2
7
|
|
3
8
|
- Adds support for **[Excon](https://github.com/excon/excon)** Faraday adapter. You can use the Excon adapter by setting it in when initializing an Elasticsearch client:
|
@@ -21,7 +26,7 @@ Excon.defaults[:ssl_ca_file] = path_to_file
|
|
21
26
|
ENV['SSL_CERT_FILE'] = path_to_file
|
22
27
|
Excon.defaults[:ssl_verify_callback] = callback
|
23
28
|
# (see OpenSSL::SSL::SSLContext#verify_callback)
|
24
|
-
Excon.defaults[:ssl_verify_peer] = false
|
29
|
+
Excon.defaults[:ssl_verify_peer] = false # (less secure).
|
25
30
|
```
|
26
31
|
|
27
32
|
- Adds support for **[Async::HTTP::Faraday](https://github.com/socketry/async-http-faraday)**. You can use the adapter by setting it when initializing an Elasticsearch client:
|
data/CONTRIBUTING.md
CHANGED
@@ -41,7 +41,9 @@ E.g.:
|
|
41
41
|
$ rake docker:start[8.0.0-alpha1]
|
42
42
|
```
|
43
43
|
|
44
|
-
You can find the available version in [Docker @ Elastic](https://www.docker.elastic.co/r/elasticsearch).
|
44
|
+
You can find the available version in [Docker @ Elastic](https://www.docker.elastic.co/r/elasticsearch).
|
45
|
+
|
46
|
+
You can also run Elasticsearch and Kibana locally with Docker with `start-local`:
|
45
47
|
|
46
48
|
```bash
|
47
49
|
curl -fsSL https://elastic.co/start-local | sh
|
@@ -49,6 +51,15 @@ curl -fsSL https://elastic.co/start-local | sh
|
|
49
51
|
|
50
52
|
This will run Elasticsearch in http://localhost:9200 and Kibana in http://localhost:5601. More information is available [here](https://www.elastic.co/guide/en/elasticsearch/reference/current/run-elasticsearch-locally.html).
|
51
53
|
|
54
|
+
## Faraday 1 tests
|
55
|
+
|
56
|
+
You can run the tests for Faraday v1 with the following commands:
|
57
|
+
|
58
|
+
```bash
|
59
|
+
BUNDLE_GEMFILE=Gemfile-faraday1.gemfile bundle install
|
60
|
+
BUNDLE_GEMFILE=Gemfile-faraday1.gemfile rake test:all
|
61
|
+
```
|
62
|
+
|
52
63
|
# Contributing
|
53
64
|
|
54
65
|
The process for contributing is:
|
data/README.md
CHANGED
@@ -1,8 +1,7 @@
|
|
1
1
|
# Elastic Transport
|
2
|
-
[](https://github.com/elastic/elastic-transport-ruby/actions/workflows/tests.yml)
|
3
2
|
[](https://github.com/elastic/elastic-transport-ruby/actions/workflows/tests.yml)
|
4
3
|
|
5
|
-
This gem provides a low-level Ruby client for connecting to an [Elastic](http://elastic.co) cluster. It powers
|
4
|
+
This gem provides a low-level Ruby client for connecting to an [Elastic](http://elastic.co) cluster. It powers the [Elasticsearch client](https://github.com/elasticsearch/elasticsearch-ruby/) and other Elastic projects.
|
6
5
|
|
7
6
|
In the simplest form, connect to Elasticsearch running on `http://localhost:9200` without any configuration:
|
8
7
|
|
@@ -14,9 +13,9 @@ response = client.perform_request('GET', '_cluster/health')
|
|
14
13
|
# => #<Elastic::Transport::Transport::Response:0x007fc5d506ce38 @status=200, @body={ ... } >
|
15
14
|
```
|
16
15
|
|
17
|
-
**Refer to [the official documentation on Elastic Transport](https://www.elastic.co/
|
16
|
+
**Refer to [the official documentation on Elastic Transport](https://www.elastic.co/docs/reference/elasticsearch/clients/ruby/transport).**
|
18
17
|
|
19
|
-
**Refer to [Advanced Configuration](https://www.elastic.co/
|
18
|
+
**Refer to [Advanced Configuration](https://www.elastic.co/docs/reference/elasticsearch/clients/ruby/advanced-config) to read about more configuration options.**
|
20
19
|
|
21
20
|
## Compatibility
|
22
21
|
|
@@ -195,7 +195,7 @@ module Elastic
|
|
195
195
|
#
|
196
196
|
def __log_response(method, path, params, body, url, response, json, took, duration)
|
197
197
|
if logger
|
198
|
-
sanitized_url = url.to_s
|
198
|
+
sanitized_url = sanitize_url(url.to_s)
|
199
199
|
log_info "#{method.to_s.upcase} #{sanitized_url} " +
|
200
200
|
"[status:#{response.status}, request:#{sprintf('%.3fs', duration)}, query:#{took}]"
|
201
201
|
log_debug "> #{__convert_to_json(body)}" if body
|
@@ -379,11 +379,11 @@ module Elastic
|
|
379
379
|
private
|
380
380
|
|
381
381
|
USER_AGENT_STR = 'User-Agent'.freeze
|
382
|
-
USER_AGENT_REGEX = /user-?_?agent
|
382
|
+
USER_AGENT_REGEX = /user-?_?agent/.freeze
|
383
383
|
ACCEPT_ENCODING = 'Accept-Encoding'.freeze
|
384
384
|
CONTENT_ENCODING = 'Content-Encoding'.freeze
|
385
385
|
CONTENT_TYPE_STR = 'Content-Type'.freeze
|
386
|
-
CONTENT_TYPE_REGEX = /content-?_?type
|
386
|
+
CONTENT_TYPE_REGEX = /content-?_?type/.freeze
|
387
387
|
DEFAULT_CONTENT_TYPE = 'application/json'.freeze
|
388
388
|
GZIP = 'gzip'.freeze
|
389
389
|
GZIP_FIRST_TWO_BYTES = '1f8b'.freeze
|
@@ -472,9 +472,13 @@ module Elastic
|
|
472
472
|
end
|
473
473
|
end
|
474
474
|
|
475
|
+
def sanitize_url(url)
|
476
|
+
url.to_s.gsub(/\/\/(.+):(.+)@/, '//' + '\1:' + SANITIZED_PASSWORD + '@')
|
477
|
+
end
|
478
|
+
|
475
479
|
def capture_otel_span_attributes(connection, url)
|
476
480
|
if defined?(::OpenTelemetry)
|
477
|
-
::OpenTelemetry::Trace.current_span&.set_attribute('url.full', url)
|
481
|
+
::OpenTelemetry::Trace.current_span&.set_attribute('url.full', sanitize_url(url))
|
478
482
|
::OpenTelemetry::Trace.current_span&.set_attribute('server.address', connection.host[:host])
|
479
483
|
::OpenTelemetry::Trace.current_span&.set_attribute('server.port', connection.host[:port].to_i)
|
480
484
|
end
|
@@ -30,7 +30,7 @@ module Elastic
|
|
30
30
|
# @return [Response]
|
31
31
|
# @see Transport::Base#perform_request
|
32
32
|
#
|
33
|
-
def perform_request(method, path, params={}, body=nil, headers=nil, opts={})
|
33
|
+
def perform_request(method, path, params = {}, body = nil, headers = nil, opts = {})
|
34
34
|
super do |connection, url|
|
35
35
|
capture_otel_span_attributes(connection, url)
|
36
36
|
connection.connection.url = connection.full_url(path, params)
|
@@ -51,7 +51,6 @@ module Elastic
|
|
51
51
|
connection.connection.headers = headers
|
52
52
|
end
|
53
53
|
end
|
54
|
-
|
55
54
|
else raise ArgumentError, "Unsupported HTTP method: #{method}"
|
56
55
|
end
|
57
56
|
|
@@ -73,7 +72,7 @@ module Elastic
|
|
73
72
|
#
|
74
73
|
# @return [Connections::Connection]
|
75
74
|
#
|
76
|
-
def __build_connection(host, options={}, block=nil)
|
75
|
+
def __build_connection(host, options = {}, block = nil)
|
77
76
|
client = ::Curl::Easy.new
|
78
77
|
|
79
78
|
apply_headers(client, options)
|
@@ -87,7 +86,7 @@ module Elastic
|
|
87
86
|
|
88
87
|
client.instance_eval(&block) if block
|
89
88
|
|
90
|
-
Connections::Connection.new
|
89
|
+
Connections::Connection.new(host: host, connection: client)
|
91
90
|
end
|
92
91
|
|
93
92
|
# Returns an array of implementation specific connection errors.
|
data/lib/elastic/transport.rb
CHANGED
@@ -25,8 +25,8 @@ if defined?(::OpenTelemetry)
|
|
25
25
|
let(:span) { exporter.finished_spans[0] }
|
26
26
|
|
27
27
|
let(:client) do
|
28
|
-
Elastic::Transport::Client.new(hosts: ELASTICSEARCH_HOSTS).tap do |
|
29
|
-
allow(
|
28
|
+
Elastic::Transport::Client.new(hosts: ELASTICSEARCH_HOSTS).tap do |client|
|
29
|
+
allow(client).to receive(:__build_connections)
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
@@ -36,7 +36,8 @@ if defined?(::OpenTelemetry)
|
|
36
36
|
let(:tracer_provider) do
|
37
37
|
double('tracer_provider').tap do |tp|
|
38
38
|
expect(tp).to receive(:tracer).with(
|
39
|
-
Elastic::Transport::OpenTelemetry::OTEL_TRACER_NAME,
|
39
|
+
Elastic::Transport::OpenTelemetry::OTEL_TRACER_NAME,
|
40
|
+
Elastic::Transport::VERSION
|
40
41
|
)
|
41
42
|
end
|
42
43
|
end
|
@@ -59,7 +60,7 @@ if defined?(::OpenTelemetry)
|
|
59
60
|
it 'creates a span with path parameters' do
|
60
61
|
client.perform_request(
|
61
62
|
'POST', '/users/_create/abc', nil, { name: 'otel-test' }, nil,
|
62
|
-
defined_params: {'index' => 'users', 'id' => 'abc'}, endpoint: 'create'
|
63
|
+
defined_params: { 'index' => 'users', 'id' => 'abc' }, endpoint: 'create'
|
63
64
|
)
|
64
65
|
|
65
66
|
span = exporter.finished_spans.find { |s| s.name == 'create' }
|
@@ -96,7 +97,7 @@ if defined?(::OpenTelemetry)
|
|
96
97
|
|
97
98
|
context 'when a request is instrumented' do
|
98
99
|
let(:body) do
|
99
|
-
{ query: { match: { password: { query: 'secret'} } } }
|
100
|
+
{ query: { match: { password: { query: 'secret' } } } }
|
100
101
|
end
|
101
102
|
|
102
103
|
it 'creates a span and omits db.statement' do
|
@@ -214,9 +215,9 @@ if defined?(::OpenTelemetry)
|
|
214
215
|
|
215
216
|
around(:example) do |ex|
|
216
217
|
body_strategy = ENV[described_class::ENV_VARIABLE_BODY_STRATEGY]
|
217
|
-
ENV[described_class::ENV_VARIABLE_BODY_STRATEGY]
|
218
|
+
ENV[described_class::ENV_VARIABLE_BODY_STRATEGY] = 'omit'
|
218
219
|
ex.run
|
219
|
-
ENV[described_class::ENV_VARIABLE_BODY_STRATEGY]
|
220
|
+
ENV[described_class::ENV_VARIABLE_BODY_STRATEGY]= body_strategy
|
220
221
|
end
|
221
222
|
|
222
223
|
it 'does not include anything' do
|
@@ -308,11 +309,11 @@ if defined?(::OpenTelemetry)
|
|
308
309
|
let(:key_patterns) { [/something/] }
|
309
310
|
|
310
311
|
let(:body) do
|
311
|
-
{ query: { match: { something:
|
312
|
+
{ query: { match: { something: 'test' } } }
|
312
313
|
end
|
313
314
|
|
314
315
|
let(:expected_body) do
|
315
|
-
{ query: { match: { something:
|
316
|
+
{ query: { match: { something: 'REDACTED' } } }
|
316
317
|
end
|
317
318
|
|
318
319
|
it 'redacts sensitive values' do
|
@@ -320,6 +321,22 @@ if defined?(::OpenTelemetry)
|
|
320
321
|
end
|
321
322
|
end
|
322
323
|
end
|
324
|
+
|
325
|
+
context 'sanitize in URL' do
|
326
|
+
let(:client) {
|
327
|
+
Elastic::Transport::Client.new(host: 'http://elastic:changeme@localhost:9250')
|
328
|
+
}
|
329
|
+
|
330
|
+
it 'sanitizes URL' do
|
331
|
+
client.perform_request(
|
332
|
+
'GET', '/', {}, nil, {}
|
333
|
+
)
|
334
|
+
|
335
|
+
span = exporter.finished_spans.find { |s| s.name == 'GET' }
|
336
|
+
expect(span.name).to eql('GET')
|
337
|
+
expect(span.attributes['url.full']).to match(/http:\/\/elastic:\*+@localhost:9250/)
|
338
|
+
end
|
339
|
+
end
|
323
340
|
end
|
324
341
|
end
|
325
342
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: elastic-transport
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 8.4.
|
4
|
+
version: 8.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Elastic Client Library Maintainers
|
8
8
|
bindir: bin
|
9
9
|
cert_chain: []
|
10
|
-
date:
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
11
11
|
dependencies:
|
12
12
|
- !ruby/object:Gem::Dependency
|
13
13
|
name: faraday
|
@@ -256,8 +256,8 @@ email:
|
|
256
256
|
executables: []
|
257
257
|
extensions: []
|
258
258
|
extra_rdoc_files:
|
259
|
-
- README.md
|
260
259
|
- LICENSE
|
260
|
+
- README.md
|
261
261
|
files:
|
262
262
|
- ".github/check_license_headers.rb"
|
263
263
|
- ".github/license-header.txt"
|
@@ -338,7 +338,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
338
338
|
- !ruby/object:Gem::Version
|
339
339
|
version: '0'
|
340
340
|
requirements: []
|
341
|
-
rubygems_version: 3.6.
|
341
|
+
rubygems_version: 3.6.9
|
342
342
|
specification_version: 4
|
343
343
|
summary: Low level Ruby client for Elastic services.
|
344
344
|
test_files:
|