Class: Appsignal::Transmitter
Constant Summary collapse
- CONTENT_TYPE =
'application/json; charset=UTF-8'.freeze
- CONTENT_ENCODING =
'gzip'.freeze
- HTTP_ERRORS =
[ EOFError, Errno::ECONNREFUSED, Errno::ECONNRESET, Errno::EINVAL, Net::HTTPBadResponse, Net::HTTPHeaderSyntaxError, Net::ProtocolError, Timeout::Error, OpenSSL::SSL::SSLError ]
Instance Attribute Summary collapse
-
#action ⇒ Object
readonly
Returns the value of attribute action.
-
#config ⇒ Object
readonly
Returns the value of attribute config.
Instance Method Summary collapse
-
#initialize(action, config = Appsignal.config) ⇒ Transmitter
constructor
A new instance of Transmitter.
- #transmit(payload) ⇒ Object
- #uri ⇒ Object
Constructor Details
#initialize(action, config = Appsignal.config) ⇒ Transmitter
Returns a new instance of Transmitter.
26 27 28 29 |
# File 'lib/appsignal/transmitter.rb', line 26 def initialize(action, config=Appsignal.config) @action = action @config = config end |
Instance Attribute Details
#action ⇒ Object (readonly)
Returns the value of attribute action.
24 25 26 |
# File 'lib/appsignal/transmitter.rb', line 24 def action @action end |
#config ⇒ Object (readonly)
Returns the value of attribute config.
24 25 26 |
# File 'lib/appsignal/transmitter.rb', line 24 def config @config end |
Instance Method Details
#transmit(payload) ⇒ Object
43 44 45 46 |
# File 'lib/appsignal/transmitter.rb', line 43 def transmit(payload) config.logger.debug "Transmitting payload to #{uri}" http_client.request(http_post(payload)).code end |
#uri ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/appsignal/transmitter.rb', line 31 def uri @uri ||= URI("#{config[:endpoint]}/1/#{action}").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 |