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
- JSON_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"
- NDJSON_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/x-ndjson; charset=UTF-8"
- 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, format: :json) ⇒ 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.
35 36 37 38 39 40 41 42 43 |
# File 'lib/appsignal/transmitter.rb', line 35 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.
27 28 29 |
# File 'lib/appsignal/transmitter.rb', line 27 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.
27 28 29 |
# File 'lib/appsignal/transmitter.rb', line 27 def config @config end |
Instance Method Details
#transmit(payload, format: :json) ⇒ 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.
57 58 59 60 |
# File 'lib/appsignal/transmitter.rb', line 57 def transmit(payload, format: :json) Appsignal.internal_logger.debug "Transmitting payload to #{uri}" http_client.request(http_post(payload, :format => format)) 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.
45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/appsignal/transmitter.rb', line 45 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 |