Class: Appsignal::CustomMarker
Overview
Custom markers are used on AppSignal.com to indicate events in an application, to give additional context on graph timelines.
This helper class will send a request to the AppSignal public endpoint to create a Custom marker for the application on AppSignal.com.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(marker_data) ⇒ CustomMarker
constructor
private
A new instance of CustomMarker.
- #transmit ⇒ Object private
Constructor Details
#initialize(marker_data) ⇒ CustomMarker
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 CustomMarker.
36 37 38 |
# File 'lib/appsignal/custom_marker.rb', line 36 def initialize(marker_data) @marker_data = marker_data end |
Class Method Details
.report(icon: nil, message: nil, created_at: nil) ⇒ Boolean
21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/appsignal/custom_marker.rb', line 21 def self.report( icon: nil, message: nil, created_at: nil ) new( { :icon => icon, :message => , :created_at => created_at.respond_to?(:iso8601) ? created_at.iso8601 : created_at }.compact ).transmit end |
Instance Method Details
#transmit ⇒ 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.
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/appsignal/custom_marker.rb', line 41 def transmit unless Appsignal.config Appsignal.internal_logger.warn( "Did not transmit custom marker: no AppSignal config loaded" ) return false end transmitter = Transmitter.new( "#{Appsignal.config[:logging_endpoint]}/markers", Appsignal.config ) response = transmitter.transmit(@marker_data) if (200...300).include?(response.code.to_i) Appsignal.internal_logger.info("Transmitted custom marker") true else Appsignal.internal_logger.error( "Failed to transmit custom marker: #{response.code} status code" ) false end rescue => e Appsignal.internal_logger.error( "Failed to transmit custom marker: #{e.class}: #{e.}\n" \ "#{e.backtrace}" ) false end |