Class: Elasticsearch::Tracer::Transport
- Inherits:
-
Object
- Object
- Elasticsearch::Tracer::Transport
- Defined in:
- lib/elasticsearch/tracer/transport.rb
Instance Attribute Summary collapse
-
#active_span ⇒ Object
readonly
Returns the value of attribute active_span.
-
#tracer ⇒ Object
readonly
Returns the value of attribute tracer.
-
#wrapped ⇒ Object
readonly
Returns the value of attribute wrapped.
Instance Method Summary collapse
-
#initialize(tracer: OpenTracing.global_tracer, active_span: nil, transport:) ⇒ Transport
constructor
A new instance of Transport.
- #perform_request(method, path, params = {}, body = nil, headers = nil) ⇒ Object
Constructor Details
#initialize(tracer: OpenTracing.global_tracer, active_span: nil, transport:) ⇒ Transport
Returns a new instance of Transport.
6 7 8 9 10 |
# File 'lib/elasticsearch/tracer/transport.rb', line 6 def initialize(tracer: OpenTracing.global_tracer, active_span: nil, transport:) @tracer = tracer @active_span = active_span @wrapped = transport end |
Instance Attribute Details
#active_span ⇒ Object (readonly)
Returns the value of attribute active_span.
4 5 6 |
# File 'lib/elasticsearch/tracer/transport.rb', line 4 def active_span @active_span end |
#tracer ⇒ Object (readonly)
Returns the value of attribute tracer.
4 5 6 |
# File 'lib/elasticsearch/tracer/transport.rb', line 4 def tracer @tracer end |
#wrapped ⇒ Object (readonly)
Returns the value of attribute wrapped.
4 5 6 |
# File 'lib/elasticsearch/tracer/transport.rb', line 4 def wrapped @wrapped end |
Instance Method Details
#perform_request(method, path, params = {}, body = nil, headers = nil) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/elasticsearch/tracer/transport.rb', line 12 def perform_request(method, path, params={}, body=nil, headers=nil) = { 'component' => 'elasticsearch-ruby', 'span.kind' => 'client', 'http.method' => method, 'http.url' => path, 'db.type' => 'elasticsearch', 'elasticsearch.params' => URI.encode_www_form(params) } ['db.statement'] = MultiJson.dump(body) unless Thread.current[self.object_id.to_s] span = tracer.start_span(method, child_of: active_span.respond_to?(:call) ? active_span.call : active_span, tags: ) response = @wrapped.perform_request(method, path, params, body, headers) span.set_tag('http.status_code', response.status) response rescue Exception => e if span span.record_exception(e) end raise ensure span.finish if span end |