Class: Appsignal::Marker Private

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

Overview

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.

Deploy markers are used on AppSignal.com to indicate changes in an application, "Deploy markers" indicate a deploy of an application.

Incidents for exceptions and performance issues will be closed and reopened if they occur again in the new deploy.

This class will help send a request to the AppSignal Push API to create a Deploy marker for the application on AppSignal.com.

Constant Summary collapse

ACTION =

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.

Path used on the AppSignal Push API https://push.appsignal.com/1/markers

"markers".freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(marker_data, config) ⇒ Marker

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 Marker.

Parameters:

Options Hash (marker_data):

  • :environment (String)

    environment to load configuration for.

  • :name (String)

    name of the application.

  • :user (String)

    name of the user that is creating the marker.

  • :revision (String)

    the revision that has been deployed. E.g. a git commit SHA.



40
41
42
43
# File 'lib/appsignal/marker.rb', line 40

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

Instance Attribute Details

#configAppsignal::Config (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.

Returns config to use in the authentication request. Set config does not override data set in #marker_data.

Returns:



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/appsignal/marker.rb', line 24

class Marker
  # Path used on the AppSignal Push API
  # https://push.appsignal.com/1/markers
  ACTION = "markers".freeze

  attr_reader :marker_data, :config

  # @param marker_data [Hash] see {#marker_data}
  # @option marker_data :environment [String] environment to load
  #   configuration for.
  # @option marker_data :name [String] name of the application.
  # @option marker_data :user [String] name of the user that is creating the
  #   marker.
  # @option marker_data :revision [String] the revision that has been
  #   deployed. E.g. a git commit SHA.
  # @param config [Appsignal::Config]
  def initialize(marker_data, config)
    @marker_data = marker_data
    @config = config
  end

  # Send a request to create the marker.
  #
  # Prints output to STDOUT.
  #
  # @return [void]
  def transmit
    transmitter = Transmitter.new(ACTION, config)
    puts "Notifying AppSignal of deploy with: "\
      "revision: #{marker_data[:revision]}, user: #{marker_data[:user]}"

    response = transmitter.transmit(marker_data)
    unless response.code == "200"
      raise "#{response.code} at #{transmitter.uri}"
    end
    puts "AppSignal has been notified of this deploy!"
  rescue => e
    puts "Something went wrong while trying to notify AppSignal: #{e}"
  end
end

#marker_dataHash (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.

Returns marker data to send.

Returns:

  • (Hash)

    marker data to send.



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/appsignal/marker.rb', line 24

class Marker
  # Path used on the AppSignal Push API
  # https://push.appsignal.com/1/markers
  ACTION = "markers".freeze

  attr_reader :marker_data, :config

  # @param marker_data [Hash] see {#marker_data}
  # @option marker_data :environment [String] environment to load
  #   configuration for.
  # @option marker_data :name [String] name of the application.
  # @option marker_data :user [String] name of the user that is creating the
  #   marker.
  # @option marker_data :revision [String] the revision that has been
  #   deployed. E.g. a git commit SHA.
  # @param config [Appsignal::Config]
  def initialize(marker_data, config)
    @marker_data = marker_data
    @config = config
  end

  # Send a request to create the marker.
  #
  # Prints output to STDOUT.
  #
  # @return [void]
  def transmit
    transmitter = Transmitter.new(ACTION, config)
    puts "Notifying AppSignal of deploy with: "\
      "revision: #{marker_data[:revision]}, user: #{marker_data[:user]}"

    response = transmitter.transmit(marker_data)
    unless response.code == "200"
      raise "#{response.code} at #{transmitter.uri}"
    end
    puts "AppSignal has been notified of this deploy!"
  rescue => e
    puts "Something went wrong while trying to notify AppSignal: #{e}"
  end
end

Instance Method Details

#transmitvoid

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.

This method returns an undefined value.

Send a request to create the marker.

Prints output to STDOUT.



50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/appsignal/marker.rb', line 50

def transmit
  transmitter = Transmitter.new(ACTION, config)
  puts "Notifying AppSignal of deploy with: "\
    "revision: #{marker_data[:revision]}, user: #{marker_data[:user]}"

  response = transmitter.transmit(marker_data)
  unless response.code == "200"
    raise "#{response.code} at #{transmitter.uri}"
  end
  puts "AppSignal has been notified of this deploy!"
rescue => e
  puts "Something went wrong while trying to notify AppSignal: #{e}"
end