class Sentry::Breadcrumb

Constants

DATA_SERIALIZATION_ERROR_MESSAGE

Attributes

category[RW]
data[RW]
level[RW]
message[R]
timestamp[RW]
type[RW]

Public Class Methods

new(category: nil, data: nil, message: nil, timestamp: nil, level: nil, type: nil) click to toggle source
# File lib/sentry/breadcrumb.rb, line 8
def initialize(category: nil, data: nil, message: nil, timestamp: nil, level: nil, type: nil)
  @category = category
  @data = data || {}
  @level = level
  @timestamp = timestamp || Sentry.utc_now.to_i
  @type = type
  self.message = message
end

Public Instance Methods

message=(msg) click to toggle source
# File lib/sentry/breadcrumb.rb, line 28
def message=(msg)
  @message = (msg || "").byteslice(0..Event::MAX_MESSAGE_SIZE_IN_BYTES)
end
to_hash() click to toggle source
# File lib/sentry/breadcrumb.rb, line 17
def to_hash
  {
    category: @category,
    data: serialized_data,
    level: @level,
    message: @message,
    timestamp: @timestamp,
    type: @type
  }
end

Private Instance Methods

serialized_data() click to toggle source
# File lib/sentry/breadcrumb.rb, line 34
    def serialized_data
      begin
        ::JSON.parse(::JSON.generate(@data))
      rescue Exception => e
        Sentry.logger.debug(LOGGER_PROGNAME) do
          <<~MSG
can't serialize breadcrumb data because of error: #{e}
data: #{@data}
          MSG
        end

        DATA_SERIALIZATION_ERROR_MESSAGE
      end
    end