Class: Appsignal::Transmitter Private
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 collapse
- CONTENT_TYPE =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
"application/json; charset=UTF-8".freeze
- HTTP_ERRORS =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
[ EOFError, Errno::ECONNREFUSED, Errno::ECONNRESET, Errno::EINVAL, Net::HTTPBadResponse, Net::HTTPHeaderSyntaxError, Net::ProtocolError, Timeout::Error, OpenSSL::SSL::SSLError ].freeze
Instance Attribute Summary collapse
- #base_uri ⇒ Object readonly private
- #config ⇒ Object readonly private
Instance Method Summary collapse
-
#initialize(base_uri, config = Appsignal.config) ⇒ Transmitter
constructor
private
A new instance of Transmitter.
- #transmit(payload) ⇒ Object private
- #uri ⇒ Object private
Constructor Details
#initialize(base_uri, config = Appsignal.config) ⇒ Transmitter
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 Transmitter.
34 35 36 37 38 39 40 41 42 |
# File 'lib/appsignal/transmitter.rb', line 34 def initialize(base_uri, config = Appsignal.config) @base_uri = if base_uri.start_with? "http" base_uri else "#{config[:endpoint]}/1/#{base_uri}" end @config = config end |
Instance Attribute Details
#base_uri ⇒ 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.
26 27 28 |
# File 'lib/appsignal/transmitter.rb', line 26 def base_uri @base_uri end |
#config ⇒ 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.
26 27 28 |
# File 'lib/appsignal/transmitter.rb', line 26 def config @config end |
Instance Method Details
#transmit(payload) ⇒ 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.
56 57 58 59 |
# File 'lib/appsignal/transmitter.rb', line 56 def transmit(payload) config.logger.debug "Transmitting payload to #{uri}" http_client.request(http_post(payload)) end |
#uri ⇒ 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.
44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/appsignal/transmitter.rb', line 44 def uri @uri ||= URI(base_uri).tap do |uri| uri.query = ::Rack::Utils.build_query( :api_key => config[:push_api_key], :name => config[:name], :environment => config.env, :hostname => config[:hostname], :gem_version => Appsignal::VERSION ) end end |