elastic-transport 8.4.2 → 8.5.0
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/check_license_headers.rb +33 -0
- data/.github/license-header.txt +16 -0
- data/.github/workflows/license.yml +13 -0
- data/.github/workflows/otel.yml +48 -0
- data/.github/workflows/tests.yml +86 -0
- data/.gitignore +19 -0
- data/CHANGELOG.md +9 -7
- data/Gemfile +39 -0
- data/Gemfile-faraday1.gemfile +40 -0
- data/Rakefile +133 -0
- data/elastic-transport.gemspec +74 -0
- data/lib/elastic/transport/client.rb +27 -25
- data/lib/elastic/transport/opentelemetry.rb +3 -1
- data/lib/elastic/transport/transport/base.rb +34 -11
- data/lib/elastic/transport/transport/http/faraday.rb +0 -1
- data/lib/elastic/transport/transport/http/manticore.rb +5 -7
- data/lib/elastic/transport/transport/serializer/multi_json.rb +2 -16
- data/lib/elastic/transport/version.rb +1 -1
- data/spec/elastic/connections/collection_spec.rb +266 -0
- data/spec/elastic/connections/selector_spec.rb +166 -0
- data/spec/elastic/transport/base_spec.rb +265 -0
- data/spec/elastic/transport/client_spec.rb +1804 -0
- data/spec/elastic/transport/http/curb_spec.rb +126 -0
- data/spec/elastic/transport/http/faraday_spec.rb +141 -0
- data/spec/elastic/transport/http/manticore_spec.rb +164 -0
- data/spec/elastic/transport/meta_header_spec.rb +289 -0
- data/spec/elastic/transport/opentelemetry_spec.rb +356 -0
- data/spec/elastic/transport/sniffer_spec.rb +293 -0
- data/spec/spec_helper.rb +104 -0
- data/test/integration/jruby_test.rb +46 -0
- data/test/integration/transport_test.rb +144 -0
- data/test/profile/client_benchmark_test.rb +132 -0
- data/test/test_helper.rb +86 -0
- data/test/unit/adapters_test.rb +114 -0
- data/test/unit/connection_test.rb +133 -0
- data/test/unit/response_test.rb +30 -0
- data/test/unit/serializer_test.rb +33 -0
- data/test/unit/transport_base_test.rb +663 -0
- data/test/unit/transport_curb_test.rb +148 -0
- data/test/unit/transport_faraday_test.rb +251 -0
- data/test/unit/transport_manticore_test.rb +279 -0
- metadata +77 -7
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 5f325dbed521a79ebb43a9b74fdce73bc7184717c9ec6939262f227faeb2adc4
|
|
4
|
+
data.tar.gz: 193b1b6a263e079c987ab3ad59f5842c8872bb956c7dd16dc751560dc3c21fac
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: bb05fa43519780d747d3640687fcd3c600e3510c54e41eaf3dc4ceeadc05ba6c794f051a301fd5fd2a55ef3a157ce8fdb2098a63d5c28ed14d73d6cbe0432252
|
|
7
|
+
data.tar.gz: cc35d78faa229b78ee06eaf3d341dac37211f7683cf9f30db19bf57f4228071469cc3fddaac76a99ad749fb2690b015d03a3bebf0fb3fd976d66f7f437cdc0c2
|
|
@@ -0,0 +1,33 @@
|
|
|
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
|
+
LICENSE = File.read('./.github/license-header.txt')
|
|
19
|
+
files = `git ls-files | grep -E '\.rb|Rakefile|\.rake|\.erb|Gemfile|gemspec'`.split("\n")
|
|
20
|
+
errors = []
|
|
21
|
+
|
|
22
|
+
files.each do |file|
|
|
23
|
+
unless File.read(file).include?(LICENSE)
|
|
24
|
+
errors << file
|
|
25
|
+
puts "#{file} doesn't contain the correct license header"
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
if errors.empty?
|
|
30
|
+
puts 'All checked files have the correct license header'
|
|
31
|
+
else
|
|
32
|
+
exit 1
|
|
33
|
+
end
|
|
@@ -0,0 +1,16 @@
|
|
|
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.
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
name: License headers
|
|
2
|
+
on: [pull_request]
|
|
3
|
+
jobs:
|
|
4
|
+
build:
|
|
5
|
+
runs-on: ubuntu-latest
|
|
6
|
+
steps:
|
|
7
|
+
- uses: actions/checkout@v4
|
|
8
|
+
- uses: ruby/setup-ruby@v1
|
|
9
|
+
with:
|
|
10
|
+
ruby-version: '4.0'
|
|
11
|
+
- name: Check license headers
|
|
12
|
+
run: |
|
|
13
|
+
ruby ./.github/check_license_headers.rb
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
name: opentelemetry
|
|
2
|
+
on:
|
|
3
|
+
push:
|
|
4
|
+
branches:
|
|
5
|
+
- main
|
|
6
|
+
pull_request:
|
|
7
|
+
branches:
|
|
8
|
+
- main
|
|
9
|
+
jobs:
|
|
10
|
+
test-otel:
|
|
11
|
+
name: 'Test Open Telemetry'
|
|
12
|
+
env:
|
|
13
|
+
TEST_ES_SERVER: http://localhost:9250
|
|
14
|
+
PORT: 9250
|
|
15
|
+
TEST_WITH_OTEL: true
|
|
16
|
+
strategy:
|
|
17
|
+
fail-fast: false
|
|
18
|
+
matrix:
|
|
19
|
+
ruby: ['4.0', 'jruby-9.4']
|
|
20
|
+
es_version: ['9.4.0-SNAPSHOT']
|
|
21
|
+
runs-on: ubuntu-latest
|
|
22
|
+
steps:
|
|
23
|
+
- uses: actions/checkout@v4
|
|
24
|
+
- name: Increase system limits
|
|
25
|
+
run: |
|
|
26
|
+
sudo swapoff -a
|
|
27
|
+
sudo sysctl -w vm.swappiness=1
|
|
28
|
+
sudo sysctl -w fs.file-max=262144
|
|
29
|
+
sudo sysctl -w vm.max_map_count=262144
|
|
30
|
+
- uses: elastic/elastic-github-actions/elasticsearch@master
|
|
31
|
+
with:
|
|
32
|
+
stack-version: ${{ matrix.es_version }}
|
|
33
|
+
security-enabled: false
|
|
34
|
+
- uses: ruby/setup-ruby@v1
|
|
35
|
+
with:
|
|
36
|
+
ruby-version: ${{ matrix.ruby }}
|
|
37
|
+
- name: Build and test with Rake
|
|
38
|
+
run: |
|
|
39
|
+
sudo apt-get update
|
|
40
|
+
sudo apt-get install libcurl4-openssl-dev
|
|
41
|
+
ruby -v
|
|
42
|
+
bundle install
|
|
43
|
+
- name: unit tests
|
|
44
|
+
run: bundle exec rake test:unit
|
|
45
|
+
- name: specs
|
|
46
|
+
run: bundle exec rake test:spec
|
|
47
|
+
- name: integration tests
|
|
48
|
+
run: bundle exec rake test:integration
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
name: main tests
|
|
2
|
+
on:
|
|
3
|
+
push:
|
|
4
|
+
branches:
|
|
5
|
+
- main
|
|
6
|
+
pull_request:
|
|
7
|
+
branches:
|
|
8
|
+
- main
|
|
9
|
+
workflow_dispatch:
|
|
10
|
+
jobs:
|
|
11
|
+
test:
|
|
12
|
+
name: 'Main tests'
|
|
13
|
+
env:
|
|
14
|
+
TEST_ES_SERVER: http://localhost:9250
|
|
15
|
+
PORT: 9250
|
|
16
|
+
strategy:
|
|
17
|
+
fail-fast: false
|
|
18
|
+
matrix:
|
|
19
|
+
ruby: ['3.2', '3.3', '3.4', '4.0', 'jruby-9.3', 'jruby-9.4', 'jruby-10.0']
|
|
20
|
+
es_version: ['8.19.14-SNAPSHOT', '9.2.8-SNAPSHOT', '9.3.3-SNAPSHOT', '9.4.0-SNAPSHOT']
|
|
21
|
+
runs-on: ubuntu-latest
|
|
22
|
+
steps:
|
|
23
|
+
- uses: actions/checkout@v4
|
|
24
|
+
- name: Increase system limits
|
|
25
|
+
run: |
|
|
26
|
+
sudo swapoff -a
|
|
27
|
+
sudo sysctl -w vm.swappiness=1
|
|
28
|
+
sudo sysctl -w fs.file-max=262144
|
|
29
|
+
sudo sysctl -w vm.max_map_count=262144
|
|
30
|
+
- uses: elastic/elastic-github-actions/elasticsearch@master
|
|
31
|
+
with:
|
|
32
|
+
stack-version: ${{ matrix.es_version }}
|
|
33
|
+
security-enabled: false
|
|
34
|
+
- uses: ruby/setup-ruby@v1
|
|
35
|
+
with:
|
|
36
|
+
ruby-version: ${{ matrix.ruby }}
|
|
37
|
+
- name: Build and test with Rake
|
|
38
|
+
run: |
|
|
39
|
+
sudo apt-get update
|
|
40
|
+
sudo apt-get install libcurl4-openssl-dev
|
|
41
|
+
ruby -v
|
|
42
|
+
bundle install
|
|
43
|
+
- name: unit tests
|
|
44
|
+
run: bundle exec rake test:unit
|
|
45
|
+
- name: specs
|
|
46
|
+
run: bundle exec rake test:spec
|
|
47
|
+
- name: integration tests
|
|
48
|
+
run: bundle exec rake test:integration
|
|
49
|
+
test-faraday1:
|
|
50
|
+
name: 'Test Faraday 1'
|
|
51
|
+
env:
|
|
52
|
+
TEST_ES_SERVER: http://localhost:9250
|
|
53
|
+
PORT: 9250
|
|
54
|
+
strategy:
|
|
55
|
+
fail-fast: false
|
|
56
|
+
matrix:
|
|
57
|
+
ruby: ['3.0', '3.1', '3.2', '3.3', 'jruby-9.3']
|
|
58
|
+
es_version: ['8.19.14-SNAPSHOT']
|
|
59
|
+
runs-on: ubuntu-latest
|
|
60
|
+
steps:
|
|
61
|
+
- uses: actions/checkout@v4
|
|
62
|
+
- name: Increase system limits
|
|
63
|
+
run: |
|
|
64
|
+
sudo swapoff -a
|
|
65
|
+
sudo sysctl -w vm.swappiness=1
|
|
66
|
+
sudo sysctl -w fs.file-max=262144
|
|
67
|
+
sudo sysctl -w vm.max_map_count=262144
|
|
68
|
+
- uses: elastic/elastic-github-actions/elasticsearch@master
|
|
69
|
+
with:
|
|
70
|
+
stack-version: ${{ matrix.es_version }}
|
|
71
|
+
security-enabled: false
|
|
72
|
+
- uses: ruby/setup-ruby@v1
|
|
73
|
+
with:
|
|
74
|
+
ruby-version: ${{ matrix.ruby }}
|
|
75
|
+
- name: Build and test with Rake
|
|
76
|
+
run: |
|
|
77
|
+
sudo apt-get update
|
|
78
|
+
sudo apt-get install libcurl4-openssl-dev
|
|
79
|
+
ruby -v
|
|
80
|
+
BUNDLE_GEMFILE=./Gemfile-faraday1.gemfile bundle install
|
|
81
|
+
- name: faraday1 unit tests
|
|
82
|
+
run: BUNDLE_GEMFILE=./Gemfile-faraday1.gemfile bundle exec rake test:faraday1:unit
|
|
83
|
+
- name: specs
|
|
84
|
+
run: BUNDLE_GEMFILE=./Gemfile-faraday1.gemfile bundle exec rake test:faraday1:spec
|
|
85
|
+
- name: integration tests
|
|
86
|
+
run: BUNDLE_GEMFILE=./Gemfile-faraday1.gemfile bundle exec rake test:faraday1:integration
|
data/.gitignore
ADDED
data/CHANGELOG.md
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
## 8.
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
## 8.5.0
|
|
2
|
+
|
|
3
|
+
* OpenTelemetry:
|
|
4
|
+
* Updates OpenTelemetry conventions
|
|
5
|
+
* Updates code to capture `error.type` and `status_code` in OpenTelemetry.
|
|
6
|
+
* Captures ES|QL queries as SEARCH endpoints.
|
|
7
|
+
* Tested Ruby versions for elastic-transport `8.5.0`:
|
|
8
|
+
* MRI: `3.2`, `3.3`, `3.4`, `4.0`.
|
|
9
|
+
* JRuby: `9.3`, `9.4`, `10.0`.
|
|
8
10
|
|
|
9
11
|
## 8.4.1
|
|
10
12
|
|
data/Gemfile
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
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
|
+
source 'https://rubygems.org'
|
|
19
|
+
|
|
20
|
+
# Specify your gem's dependencies in elasticsearch-transport.gemspec
|
|
21
|
+
gemspec
|
|
22
|
+
|
|
23
|
+
group :development, :test do
|
|
24
|
+
gem 'faraday-excon'
|
|
25
|
+
gem 'faraday-httpclient'
|
|
26
|
+
gem 'faraday-net_http_persistent'
|
|
27
|
+
gem 'faraday-typhoeus'
|
|
28
|
+
gem 'mutex_m' if RUBY_VERSION >= '3.4'
|
|
29
|
+
gem 'opentelemetry-sdk', require: false if RUBY_VERSION >= '3.0'
|
|
30
|
+
if defined?(JRUBY_VERSION)
|
|
31
|
+
gem 'pry-nav'
|
|
32
|
+
else
|
|
33
|
+
gem 'async-http-faraday'
|
|
34
|
+
gem 'faraday-patron'
|
|
35
|
+
gem 'oj'
|
|
36
|
+
gem 'debug'
|
|
37
|
+
end
|
|
38
|
+
gem 'rspec'
|
|
39
|
+
end
|
|
@@ -0,0 +1,40 @@
|
|
|
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
|
+
source 'https://rubygems.org'
|
|
19
|
+
|
|
20
|
+
# Usage:
|
|
21
|
+
#
|
|
22
|
+
# $ BUNDLE_GEMFILE=./Gemfile-faraday1.gemfile bundle install
|
|
23
|
+
# $ BUNDLE_GEMFILE=./Gemfile-faraday1.gemfile bundle exec rake test:faraday1:unit
|
|
24
|
+
|
|
25
|
+
gem 'faraday', '~> 1'
|
|
26
|
+
gemspec
|
|
27
|
+
|
|
28
|
+
group :development, :test do
|
|
29
|
+
gem 'httpclient'
|
|
30
|
+
gem 'net-http-persistent'
|
|
31
|
+
gem 'rspec'
|
|
32
|
+
gem 'typhoeus'
|
|
33
|
+
if defined?(JRUBY_VERSION)
|
|
34
|
+
gem 'pry-nav'
|
|
35
|
+
else
|
|
36
|
+
gem 'debug'
|
|
37
|
+
gem 'oj'
|
|
38
|
+
gem 'patron'
|
|
39
|
+
end
|
|
40
|
+
end
|
data/Rakefile
ADDED
|
@@ -0,0 +1,133 @@
|
|
|
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 'bundler/gem_tasks'
|
|
19
|
+
require 'mkmf'
|
|
20
|
+
|
|
21
|
+
desc 'Run unit tests'
|
|
22
|
+
task default: 'test:unit'
|
|
23
|
+
task test: 'test:unit'
|
|
24
|
+
|
|
25
|
+
# ----- Test tasks ------------------------------------------------------------
|
|
26
|
+
require 'rake/testtask'
|
|
27
|
+
require 'rspec/core/rake_task'
|
|
28
|
+
FARADAY1_GEMFILE = 'Gemfile-faraday1.gemfile'.freeze
|
|
29
|
+
GEMFILES = ['Gemfile', FARADAY1_GEMFILE].freeze
|
|
30
|
+
|
|
31
|
+
task :install do
|
|
32
|
+
GEMFILES.each do |gemfile|
|
|
33
|
+
gemfile = File.expand_path("../#{gemfile}", __FILE__)
|
|
34
|
+
sh "bundle install --gemfile #{gemfile}"
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
namespace :test do
|
|
39
|
+
RSpec::Core::RakeTask.new(:spec)
|
|
40
|
+
|
|
41
|
+
Rake::TestTask.new(:unit) do |test|
|
|
42
|
+
test.libs << 'lib' << 'test'
|
|
43
|
+
test.test_files = FileList['test/unit/**/*_test.rb']
|
|
44
|
+
test.verbose = false
|
|
45
|
+
test.warning = false
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
Rake::TestTask.new(:integration) do |test|
|
|
49
|
+
test.libs << 'lib' << 'test'
|
|
50
|
+
test.test_files = FileList['test/integration/**/*_test.rb']
|
|
51
|
+
test.verbose = false
|
|
52
|
+
test.warning = false
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
desc 'Run all tests'
|
|
56
|
+
task :all do
|
|
57
|
+
Rake::Task['test:unit'].invoke
|
|
58
|
+
Rake::Task['test:spec'].invoke
|
|
59
|
+
Rake::Task['test:integration'].invoke
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
Rake::TestTask.new(:profile) do |test|
|
|
63
|
+
test.libs << 'lib' << 'test'
|
|
64
|
+
test.test_files = FileList['test/profile/**/*_test.rb']
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
namespace :faraday1 do
|
|
68
|
+
desc 'Faraday 1: Run RSpec with dependency on Faraday 1'
|
|
69
|
+
task :spec do
|
|
70
|
+
sh "BUNDLE_GEMFILE=#{FARADAY1_GEMFILE} bundle exec rspec"
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
desc 'Faraday 1: Run unit tests with dependency on Faraday 1'
|
|
74
|
+
task :unit do
|
|
75
|
+
Dir.glob('./test/unit/**/**.rb').each do |test|
|
|
76
|
+
sh "BUNDLE_GEMFILE=#{FARADAY1_GEMFILE} ruby -Ilib:test #{test}"
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
desc 'Faraday 1: Run integration tests with dependency on Faraday 1'
|
|
81
|
+
task :integration do
|
|
82
|
+
Dir.glob('./test/integration/**/**.rb').each do |test|
|
|
83
|
+
sh "BUNDLE_GEMFILE=#{FARADAY1_GEMFILE} ruby -Ilib:test #{test}"
|
|
84
|
+
end
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
desc 'Faraday 1: Run all tests'
|
|
88
|
+
task :all do
|
|
89
|
+
Rake::Task['test:faraday1:unit'].invoke
|
|
90
|
+
Rake::Task['test:faraday1:spec'].invoke
|
|
91
|
+
Rake::Task['test:faraday1:integration'].invoke
|
|
92
|
+
end
|
|
93
|
+
end
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
namespace :docker do
|
|
97
|
+
desc <<~DOC
|
|
98
|
+
Start Elasticsearch in a Docker container. Credentials are 'elastic:changeme'.
|
|
99
|
+
|
|
100
|
+
Default:
|
|
101
|
+
rake docker:start[version]
|
|
102
|
+
E.g.:
|
|
103
|
+
rake docker:start[8.0.0-SNAPSHOT]
|
|
104
|
+
DOC
|
|
105
|
+
task :start, [:version] do |_, params|
|
|
106
|
+
abort 'Docker not installed' unless find_executable 'docker'
|
|
107
|
+
abort 'You need to set a version, e.g. rake docker:start[7.x-SNAPSHOT]' unless params[:version]
|
|
108
|
+
|
|
109
|
+
system("docker run -p 9200:9200 -p 9300:9300 -e 'discovery.type=single-node' -e ELASTIC_PASSWORD=changeme docker.elastic.co/elasticsearch/elasticsearch:#{params[:version]}")
|
|
110
|
+
end
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
desc 'Run Ruby console with the Elastic transport client libraries loaded'
|
|
114
|
+
task :console do
|
|
115
|
+
require 'irb'
|
|
116
|
+
require 'irb/completion'
|
|
117
|
+
require 'elastic-transport'
|
|
118
|
+
ARGV.clear
|
|
119
|
+
IRB.start
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
# ----- Documentation tasks ---------------------------------------------------
|
|
123
|
+
require 'yard'
|
|
124
|
+
YARD::Rake::YardocTask.new(:doc) do |t|
|
|
125
|
+
t.options = %w| --embed-mixins --markup=markdown |
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
# ----- Code analysis tasks ---------------------------------------------------
|
|
129
|
+
require 'cane/rake_task'
|
|
130
|
+
Cane::RakeTask.new(:quality) do |cane|
|
|
131
|
+
cane.abc_max = 15
|
|
132
|
+
cane.no_style = true
|
|
133
|
+
end
|
|
@@ -0,0 +1,74 @@
|
|
|
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
|
+
# coding: utf-8
|
|
19
|
+
lib = File.expand_path('../lib', __FILE__)
|
|
20
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
21
|
+
require 'elastic/transport/version'
|
|
22
|
+
|
|
23
|
+
Gem::Specification.new do |s|
|
|
24
|
+
s.name = "elastic-transport"
|
|
25
|
+
s.version = Elastic::Transport::VERSION
|
|
26
|
+
s.authors = ['Elastic Client Library Maintainers']
|
|
27
|
+
s.email = ['client-libs@elastic.co']
|
|
28
|
+
s.summary = 'Low level Ruby client for Elastic services.'
|
|
29
|
+
s.homepage = 'https://github.com/elastic/elastic-transport-ruby'
|
|
30
|
+
s.license = 'Apache-2.0'
|
|
31
|
+
s.metadata = {
|
|
32
|
+
'homepage_uri' => 'https://github.com/elastic/elastic-transport-ruby',
|
|
33
|
+
'changelog_uri' => 'https://github.com/elastic/elastic-transport-ruby/blob/master/CHANGELOG.md',
|
|
34
|
+
'source_code_uri' => 'https://github.com/elastic/elastic-transport-ruby',
|
|
35
|
+
'bug_tracker_uri' => 'https://github.com/elastic/elastic-transport-ruby/issues'
|
|
36
|
+
}
|
|
37
|
+
s.files = `git ls-files`.split($/)
|
|
38
|
+
s.executables = s.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
|
39
|
+
s.test_files = s.files.grep(%r{^(test|spec|features)/})
|
|
40
|
+
s.require_paths = ['lib']
|
|
41
|
+
|
|
42
|
+
s.extra_rdoc_files = ['README.md', 'LICENSE']
|
|
43
|
+
s.rdoc_options = [ '--charset=UTF-8' ]
|
|
44
|
+
|
|
45
|
+
s.required_ruby_version = '>= 2.5'
|
|
46
|
+
|
|
47
|
+
s.add_dependency 'faraday', '< 3'
|
|
48
|
+
s.add_dependency 'multi_json'
|
|
49
|
+
|
|
50
|
+
# Faraday Adapters
|
|
51
|
+
if defined? JRUBY_VERSION
|
|
52
|
+
s.add_development_dependency 'manticore'
|
|
53
|
+
s.add_development_dependency 'base64'
|
|
54
|
+
end
|
|
55
|
+
s.add_development_dependency 'curb' unless defined? JRUBY_VERSION
|
|
56
|
+
s.add_development_dependency 'bundler'
|
|
57
|
+
s.add_development_dependency 'cane'
|
|
58
|
+
s.add_development_dependency 'hashie'
|
|
59
|
+
s.add_development_dependency 'minitest'
|
|
60
|
+
s.add_development_dependency 'minitest-reporters'
|
|
61
|
+
s.add_development_dependency 'mocha'
|
|
62
|
+
s.add_development_dependency 'pry'
|
|
63
|
+
s.add_development_dependency 'rake', '~> 13'
|
|
64
|
+
s.add_development_dependency 'require-prof' unless defined?(JRUBY_VERSION) || defined?(Rubinius)
|
|
65
|
+
s.add_development_dependency 'ruby-prof' unless defined?(JRUBY_VERSION) || defined?(Rubinius)
|
|
66
|
+
s.add_development_dependency 'shoulda-context'
|
|
67
|
+
s.add_development_dependency 'simplecov'
|
|
68
|
+
s.add_development_dependency 'test-unit', '~> 2'
|
|
69
|
+
s.add_development_dependency 'yard'
|
|
70
|
+
|
|
71
|
+
s.description = <<-DESC.gsub(/^ /, '')
|
|
72
|
+
Low level Ruby client for Elastic. See the `elasticsearch` or `elastic-enterprise-search` gems for full integration.
|
|
73
|
+
DESC
|
|
74
|
+
end
|
|
@@ -174,18 +174,19 @@ module Elastic
|
|
|
174
174
|
span_name = opts[:endpoint] || method
|
|
175
175
|
@otel.tracer.in_span(span_name) do |span|
|
|
176
176
|
span['http.request.method'] = method
|
|
177
|
-
span['db.system'] = 'elasticsearch'
|
|
177
|
+
span['db.system.name'] = 'elasticsearch'.freeze
|
|
178
|
+
span['kind'] = 'CLIENT'.freeze
|
|
178
179
|
opts[:defined_params]&.each do |k, v|
|
|
179
|
-
if v.respond_to?(:join)
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
180
|
+
span["db.operation.parameter.#{k}"] = if v.respond_to?(:join)
|
|
181
|
+
v.join(',')
|
|
182
|
+
else
|
|
183
|
+
v
|
|
184
|
+
end
|
|
184
185
|
end
|
|
185
|
-
if body_as_json = @otel.process_body(body, opts[:endpoint])
|
|
186
|
-
span['db.
|
|
186
|
+
if (body_as_json = @otel.process_body(body, opts[:endpoint]))
|
|
187
|
+
span['db.query.text'] = body_as_json
|
|
187
188
|
end
|
|
188
|
-
span['db.operation'] = opts[:endpoint] if opts[:endpoint]
|
|
189
|
+
span['db.operation.name'] = opts[:endpoint] if opts[:endpoint]
|
|
189
190
|
transport.perform_request(method, path, params || {}, body, headers)
|
|
190
191
|
end
|
|
191
192
|
else
|
|
@@ -271,27 +272,28 @@ module Elastic
|
|
|
271
272
|
# Construct a new `URI::Generic` directly from the array returned by URI::split.
|
|
272
273
|
# This avoids `URI::HTTP` and `URI::HTTPS`, which supply default ports.
|
|
273
274
|
uri = URI::Generic.new(*URI.split(host))
|
|
274
|
-
|
|
275
275
|
default_port = uri.scheme == 'https' ? 443 : DEFAULT_PORT
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
:
|
|
279
|
-
:
|
|
280
|
-
:
|
|
281
|
-
:
|
|
282
|
-
:
|
|
276
|
+
{
|
|
277
|
+
scheme: uri.scheme,
|
|
278
|
+
user: uri.user,
|
|
279
|
+
password: uri.password,
|
|
280
|
+
host: uri.host,
|
|
281
|
+
path: uri.path,
|
|
282
|
+
port: uri.port || default_port
|
|
283
|
+
}
|
|
283
284
|
else
|
|
284
285
|
host, port = host.split(':')
|
|
285
|
-
{ :host
|
|
286
|
-
:port => port }
|
|
286
|
+
{ host: host, port: port }
|
|
287
287
|
end
|
|
288
288
|
when URI
|
|
289
|
-
{
|
|
290
|
-
:
|
|
291
|
-
:
|
|
292
|
-
:
|
|
293
|
-
:
|
|
294
|
-
:
|
|
289
|
+
{
|
|
290
|
+
scheme: host.scheme,
|
|
291
|
+
user: host.user,
|
|
292
|
+
password: host.password,
|
|
293
|
+
host: host.host,
|
|
294
|
+
path: host.path,
|
|
295
|
+
port: host.port
|
|
296
|
+
}
|
|
295
297
|
when Hash
|
|
296
298
|
host
|
|
297
299
|
else
|
|
@@ -42,10 +42,12 @@ module Elastic
|
|
|
42
42
|
'async_search.submit',
|
|
43
43
|
'msearch',
|
|
44
44
|
'eql.search',
|
|
45
|
+
'esql.async_query',
|
|
46
|
+
'esql.query',
|
|
45
47
|
'terms_enum',
|
|
46
48
|
'search_template',
|
|
47
49
|
'msearch_template',
|
|
48
|
-
'render_search_template'
|
|
50
|
+
'render_search_template'
|
|
49
51
|
]
|
|
50
52
|
|
|
51
53
|
# Initialize the Open Telemetry wrapper object. Takes the options originally passed to
|