Class: Appsignal::Marker

Inherits:
Object
  • Object
show all
Defined in:
lib/appsignal/marker.rb

Constant Summary collapse

ACTION =
'markers'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(marker_data, root_path, rails_env, logger) ⇒ Marker

Returns a new instance of Marker.



6
7
8
9
10
# File 'lib/appsignal/marker.rb', line 6

def initialize(marker_data, root_path, rails_env, logger)
  @marker_data = marker_data
  @config = Appsignal::Config.new(root_path, rails_env, logger).load
  @logger = logger
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



3
4
5
# File 'lib/appsignal/marker.rb', line 3

def config
  @config
end

#loggerObject (readonly)

Returns the value of attribute logger.



3
4
5
# File 'lib/appsignal/marker.rb', line 3

def logger
  @logger
end

#marker_dataObject (readonly)

Returns the value of attribute marker_data.



3
4
5
# File 'lib/appsignal/marker.rb', line 3

def marker_data
  @marker_data
end

Instance Method Details

#transmitObject



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/appsignal/marker.rb', line 12

def transmit
  begin
    transmitter = Transmitter.new(
      @config[:endpoint], ACTION, @config[:api_key]
    )
    @logger.info "Notifying Appsignal of deploy..."
    result = transmitter.transmit(marker_data)
    if result == '200'
      @logger.info "Appsignal has been notified of this deploy!"
    else
      raise "#{result} at #{transmitter.uri}"
    end
  rescue Exception => e
    message = "Something went wrong while trying to notify Appsignal: #{e}"
    if @logger.respond_to?(:important)
      # This is a Capistrano logger
      @logger.important message
    else
      @logger.error message
    end
  end
end