Skip to content

OTel instrumentation: Add path patterns and endpoint in opts to perform_request #2131

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
3 changes: 3 additions & 0 deletions elasticsearch-api/Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,6 @@ group :development do
gem 'pry-byebug'
end
end

gem 'elastic-transport', git: 'git@github.com:estolfo/elastic-transport-ruby.git', branch: 'otel-instrumentation'
gem 'opentelemetry-sdk'
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,13 @@ def delete(arguments = {})

arguments = arguments.clone
headers = arguments.delete(:headers) || {}
request_opts = { :endpoint => "async_search.delete" }

defined_params = ["id"].inject({}) do |set_variables, variable|
set_variables[variable] = arguments[variable] if arguments.key?(variable)
set_variables
end
request_opts[:defined_params] = defined_params unless defined_params.empty?

body = nil

Expand All @@ -44,7 +51,7 @@ def delete(arguments = {})
params = {}

Elasticsearch::API::Response.new(
perform_request(method, path, params, body, headers)
perform_request(method, path, params, body, headers, request_opts)
)
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,13 @@ def get(arguments = {})

arguments = arguments.clone
headers = arguments.delete(:headers) || {}
request_opts = { :endpoint => "async_search.get" }

defined_params = ["id"].inject({}) do |set_variables, variable|
set_variables[variable] = arguments[variable] if arguments.key?(variable)
set_variables
end
request_opts[:defined_params] = defined_params unless defined_params.empty?

body = nil

Expand All @@ -47,7 +54,7 @@ def get(arguments = {})
params = Utils.process_params(arguments)

Elasticsearch::API::Response.new(
perform_request(method, path, params, body, headers)
perform_request(method, path, params, body, headers, request_opts)
)
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,13 @@ def status(arguments = {})

arguments = arguments.clone
headers = arguments.delete(:headers) || {}
request_opts = { :endpoint => "async_search.status" }

defined_params = ["id"].inject({}) do |set_variables, variable|
set_variables[variable] = arguments[variable] if arguments.key?(variable)
set_variables
end
request_opts[:defined_params] = defined_params unless defined_params.empty?

body = nil

Expand All @@ -44,7 +51,7 @@ def status(arguments = {})
params = {}

Elasticsearch::API::Response.new(
perform_request(method, path, params, body, headers)
perform_request(method, path, params, body, headers, request_opts)
)
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,13 @@ module Actions
def submit(arguments = {})
arguments = arguments.clone
headers = arguments.delete(:headers) || {}
request_opts = { :endpoint => "async_search.submit" }

defined_params = ["index"].inject({}) do |set_variables, variable|
set_variables[variable] = arguments[variable] if arguments.key?(variable)
set_variables
end
request_opts[:defined_params] = defined_params unless defined_params.empty?

body = arguments.delete(:body)

Expand All @@ -88,7 +95,7 @@ def submit(arguments = {})
params = Utils.process_params(arguments)

Elasticsearch::API::Response.new(
perform_request(method, path, params, body, headers)
perform_request(method, path, params, body, headers, request_opts)
)
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,13 @@ def delete_autoscaling_policy(arguments = {})

arguments = arguments.clone
headers = arguments.delete(:headers) || {}
request_opts = { :endpoint => "autoscaling.delete_autoscaling_policy" }

defined_params = ["name"].inject({}) do |set_variables, variable|
set_variables[variable] = arguments[variable] if arguments.key?(variable)
set_variables
end
request_opts[:defined_params] = defined_params unless defined_params.empty?

body = nil

Expand All @@ -44,7 +51,7 @@ def delete_autoscaling_policy(arguments = {})
params = {}

Elasticsearch::API::Response.new(
perform_request(method, path, params, body, headers)
perform_request(method, path, params, body, headers, request_opts)
)
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ module Actions
def get_autoscaling_capacity(arguments = {})
arguments = arguments.clone
headers = arguments.delete(:headers) || {}
request_opts = { :endpoint => "autoscaling.get_autoscaling_capacity" }

body = nil

Expand All @@ -39,7 +40,7 @@ def get_autoscaling_capacity(arguments = {})
params = {}

Elasticsearch::API::Response.new(
perform_request(method, path, params, body, headers)
perform_request(method, path, params, body, headers, request_opts)
)
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,13 @@ def get_autoscaling_policy(arguments = {})

arguments = arguments.clone
headers = arguments.delete(:headers) || {}
request_opts = { :endpoint => "autoscaling.get_autoscaling_policy" }

defined_params = ["name"].inject({}) do |set_variables, variable|
set_variables[variable] = arguments[variable] if arguments.key?(variable)
set_variables
end
request_opts[:defined_params] = defined_params unless defined_params.empty?

body = nil

Expand All @@ -44,7 +51,7 @@ def get_autoscaling_policy(arguments = {})
params = {}

Elasticsearch::API::Response.new(
perform_request(method, path, params, body, headers)
perform_request(method, path, params, body, headers, request_opts)
)
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,13 @@ def put_autoscaling_policy(arguments = {})

arguments = arguments.clone
headers = arguments.delete(:headers) || {}
request_opts = { :endpoint => "autoscaling.put_autoscaling_policy" }

defined_params = ["name"].inject({}) do |set_variables, variable|
set_variables[variable] = arguments[variable] if arguments.key?(variable)
set_variables
end
request_opts[:defined_params] = defined_params unless defined_params.empty?

body = arguments.delete(:body)

Expand All @@ -46,7 +53,7 @@ def put_autoscaling_policy(arguments = {})
params = {}

Elasticsearch::API::Response.new(
perform_request(method, path, params, body, headers)
perform_request(method, path, params, body, headers, request_opts)
)
end
end
Expand Down
9 changes: 8 additions & 1 deletion elasticsearch-api/lib/elasticsearch/api/actions/bulk.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,13 @@ def bulk(arguments = {})

arguments = arguments.clone
headers = arguments.delete(:headers) || {}
request_opts = { :endpoint => "bulk" }

defined_params = ["index"].inject({}) do |set_variables, variable|
set_variables[variable] = arguments[variable] if arguments.key?(variable)
set_variables
end
request_opts[:defined_params] = defined_params unless defined_params.empty?

body = arguments.delete(:body)

Expand All @@ -66,7 +73,7 @@ def bulk(arguments = {})

headers.merge!("Content-Type" => "application/x-ndjson")
Elasticsearch::API::Response.new(
perform_request(method, path, params, payload, headers)
perform_request(method, path, params, payload, headers, request_opts)
)
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,13 @@ module Actions
def aliases(arguments = {})
arguments = arguments.clone
headers = arguments.delete(:headers) || {}
request_opts = { :endpoint => "cat.aliases" }

defined_params = ["name"].inject({}) do |set_variables, variable|
set_variables[variable] = arguments[variable] if arguments.key?(variable)
set_variables
end
request_opts[:defined_params] = defined_params unless defined_params.empty?

body = nil

Expand All @@ -54,7 +61,7 @@ def aliases(arguments = {})
params[:h] = Utils.__listify(params[:h]) if params[:h]

Elasticsearch::API::Response.new(
perform_request(method, path, params, body, headers)
perform_request(method, path, params, body, headers, request_opts)
)
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,13 @@ module Actions
def allocation(arguments = {})
arguments = arguments.clone
headers = arguments.delete(:headers) || {}
request_opts = { :endpoint => "cat.allocation" }

defined_params = ["node_id"].inject({}) do |set_variables, variable|
set_variables[variable] = arguments[variable] if arguments.key?(variable)
set_variables
end
request_opts[:defined_params] = defined_params unless defined_params.empty?

body = nil

Expand All @@ -55,7 +62,7 @@ def allocation(arguments = {})
params[:h] = Utils.__listify(params[:h]) if params[:h]

Elasticsearch::API::Response.new(
perform_request(method, path, params, body, headers)
perform_request(method, path, params, body, headers, request_opts)
)
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,13 @@ module Actions
def component_templates(arguments = {})
arguments = arguments.clone
headers = arguments.delete(:headers) || {}
request_opts = { :endpoint => "cat.component_templates" }

defined_params = ["name"].inject({}) do |set_variables, variable|
set_variables[variable] = arguments[variable] if arguments.key?(variable)
set_variables
end
request_opts[:defined_params] = defined_params unless defined_params.empty?

body = nil

Expand All @@ -53,7 +60,7 @@ def component_templates(arguments = {})
params = Utils.process_params(arguments)

Elasticsearch::API::Response.new(
perform_request(method, path, params, body, headers)
perform_request(method, path, params, body, headers, request_opts)
)
end
end
Expand Down
9 changes: 8 additions & 1 deletion elasticsearch-api/lib/elasticsearch/api/actions/cat/count.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,13 @@ module Actions
def count(arguments = {})
arguments = arguments.clone
headers = arguments.delete(:headers) || {}
request_opts = { :endpoint => "cat.count" }

defined_params = ["index"].inject({}) do |set_variables, variable|
set_variables[variable] = arguments[variable] if arguments.key?(variable)
set_variables
end
request_opts[:defined_params] = defined_params unless defined_params.empty?

body = nil

Expand All @@ -52,7 +59,7 @@ def count(arguments = {})
params[:h] = Utils.__listify(params[:h]) if params[:h]

Elasticsearch::API::Response.new(
perform_request(method, path, params, body, headers)
perform_request(method, path, params, body, headers, request_opts)
)
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,13 @@ module Actions
def fielddata(arguments = {})
arguments = arguments.clone
headers = arguments.delete(:headers) || {}
request_opts = { :endpoint => "cat.fielddata" }

defined_params = ["fields"].inject({}) do |set_variables, variable|
set_variables[variable] = arguments[variable] if arguments.key?(variable)
set_variables
end
request_opts[:defined_params] = defined_params unless defined_params.empty?

body = nil

Expand All @@ -52,7 +59,7 @@ def fielddata(arguments = {})
params = Utils.process_params(arguments)

Elasticsearch::API::Response.new(
perform_request(method, path, params, body, headers)
perform_request(method, path, params, body, headers, request_opts)
)
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ module Actions
def health(arguments = {})
arguments = arguments.clone
headers = arguments.delete(:headers) || {}
request_opts = { :endpoint => "cat.health" }

body = nil

Expand All @@ -47,7 +48,7 @@ def health(arguments = {})
params[:h] = Utils.__listify(params[:h]) if params[:h]

Elasticsearch::API::Response.new(
perform_request(method, path, params, body, headers)
perform_request(method, path, params, body, headers, request_opts)
)
end
end
Expand Down
3 changes: 2 additions & 1 deletion elasticsearch-api/lib/elasticsearch/api/actions/cat/help.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ module Actions
def help(arguments = {})
arguments = arguments.clone
headers = arguments.delete(:headers) || {}
request_opts = { :endpoint => "cat.help" }

body = nil

Expand All @@ -41,7 +42,7 @@ def help(arguments = {})
params = Utils.process_params(arguments)

Elasticsearch::API::Response.new(
perform_request(method, path, params, body, headers)
perform_request(method, path, params, body, headers, request_opts)
)
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,13 @@ module Actions
def indices(arguments = {})
arguments = arguments.clone
headers = arguments.delete(:headers) || {}
request_opts = { :endpoint => "cat.indices" }

defined_params = ["index"].inject({}) do |set_variables, variable|
set_variables[variable] = arguments[variable] if arguments.key?(variable)
set_variables
end
request_opts[:defined_params] = defined_params unless defined_params.empty?

body = nil

Expand All @@ -59,7 +66,7 @@ def indices(arguments = {})
params[:h] = Utils.__listify(params[:h]) if params[:h]

Elasticsearch::API::Response.new(
perform_request(method, path, params, body, headers)
perform_request(method, path, params, body, headers, request_opts)
)
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ module Actions
def master(arguments = {})
arguments = arguments.clone
headers = arguments.delete(:headers) || {}
request_opts = { :endpoint => "cat.master" }

body = nil

Expand All @@ -46,7 +47,7 @@ def master(arguments = {})
params = Utils.process_params(arguments)

Elasticsearch::API::Response.new(
perform_request(method, path, params, body, headers)
perform_request(method, path, params, body, headers, request_opts)
)
end
end
Expand Down
Loading