Class: Appsignal::Marker

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

Constant Summary collapse

ACTION =
'markers'

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from CarefulLogger

#carefully_log_error

Constructor Details

#initialize(marker_data, config, logger) ⇒ Marker

Returns a new instance of Marker.



10
11
12
13
14
# File 'lib/appsignal/marker.rb', line 10

def initialize(marker_data, config, logger)
  @marker_data = marker_data
  @config = config
  @logger = logger
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



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

def config
  @config
end

#loggerObject (readonly)

Returns the value of attribute logger.



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

def logger
  @logger
end

#marker_dataObject (readonly)

Returns the value of attribute marker_data.



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

def marker_data
  @marker_data
end

Instance Method Details

#transmitObject



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

def transmit
  begin
    transmitter = Transmitter.new(ACTION, config)
    logger.info("Notifying Appsignal of deploy with: revision: #{marker_data[:revision]}, user: #{marker_data[:user]}")
    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
    carefully_log_error(
      "Something went wrong while trying to notify Appsignal: #{e}"
    )
  end
end