Class: Jaeger::HttpSender
- Inherits:
-
Object
- Object
- Jaeger::HttpSender
- Defined in:
- lib/jaeger/http_sender.rb
Instance Method Summary collapse
-
#initialize(url:, encoder:, headers: {}, logger: Logger.new($stdout)) ⇒ HttpSender
constructor
A new instance of HttpSender.
- #send_spans(spans) ⇒ Object
Constructor Details
#initialize(url:, encoder:, headers: {}, logger: Logger.new($stdout)) ⇒ HttpSender
Returns a new instance of HttpSender.
7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/jaeger/http_sender.rb', line 7 def initialize(url:, encoder:, headers: {}, logger: Logger.new($stdout)) @encoder = encoder @logger = logger @uri = URI(url) @uri.query = 'format=jaeger.thrift' @transport = ::Thrift::HTTPClientTransport.new(@uri.to_s) @transport.add_headers(headers) @serializer = ::Thrift::Serializer.new end |
Instance Method Details
#send_spans(spans) ⇒ Object
20 21 22 23 24 25 26 |
# File 'lib/jaeger/http_sender.rb', line 20 def send_spans(spans) batch = @encoder.encode(spans) @transport.write(@serializer.serialize(batch)) @transport.flush rescue StandardError => e @logger.error("Failure while sending a batch of spans: #{e}") end |