Class: ElasticAPM::Transport::Connection::ProxyPipe::Write Private
- Inherits:
-
Object
- Object
- ElasticAPM::Transport::Connection::ProxyPipe::Write
- Includes:
- Logging
- Defined in:
- lib/elastic_apm/transport/connection/proxy_pipe.rb
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Constant Summary
Constants included from Logging
Logging::LEVELS, Logging::PREFIX
Instance Attribute Summary collapse
- #io ⇒ Object readonly private
Class Method Summary collapse
- .finalize(io) ⇒ Object private
Instance Method Summary collapse
- #bytes_sent ⇒ Object private
- #close ⇒ Object private
- #closed? ⇒ Boolean private
- #enable_compression! ⇒ Object private
-
#initialize(io, compress: true) ⇒ Write
constructor
private
A new instance of Write.
- #write(str) ⇒ Object private
Methods included from Logging
#debug, #error, #fatal, #info, #warn
Constructor Details
#initialize(io, compress: true) ⇒ Write
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Write.
43 44 45 46 47 48 49 50 51 52 |
# File 'lib/elastic_apm/transport/connection/proxy_pipe.rb', line 43 def initialize(io, compress: true) @io = io @compress = compress @bytes_sent = Concurrent::AtomicFixnum.new(0) @config = ElasticAPM.agent&.config # this is silly, fix Logging return unless compress enable_compression! ObjectSpace.define_finalizer(self, self.class.finalize(@io)) end |
Instance Attribute Details
#io ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
58 59 60 |
# File 'lib/elastic_apm/transport/connection/proxy_pipe.rb', line 58 def io @io end |
Class Method Details
.finalize(io) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
54 55 56 |
# File 'lib/elastic_apm/transport/connection/proxy_pipe.rb', line 54 def self.finalize(io) proc { io.close } end |
Instance Method Details
#bytes_sent ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
81 82 83 |
# File 'lib/elastic_apm/transport/connection/proxy_pipe.rb', line 81 def bytes_sent @bytes_sent.value end |
#close ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
65 66 67 |
# File 'lib/elastic_apm/transport/connection/proxy_pipe.rb', line 65 def close io.close end |
#closed? ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
69 70 71 |
# File 'lib/elastic_apm/transport/connection/proxy_pipe.rb', line 69 def closed? io.closed? end |
#enable_compression! ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
60 61 62 63 |
# File 'lib/elastic_apm/transport/connection/proxy_pipe.rb', line 60 def enable_compression! io.binmode @io = Zlib::GzipWriter.new(io) end |
#write(str) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
73 74 75 76 77 78 79 |
# File 'lib/elastic_apm/transport/connection/proxy_pipe.rb', line 73 def write(str) io.puts(str).tap do @bytes_sent.update do |curr| @compress ? io.tell : curr + str.bytesize end end end |