Sha256: 230a4a080d152a2096f192411158c0a08317a02f992c7db17ef809a393d4716f
Contents?: true
Size: 1.67 KB
Versions: 33
Compression:
Stored size: 1.67 KB
Contents
# frozen_string_literal: true module Sentry class Breadcrumb DATA_SERIALIZATION_ERROR_MESSAGE = "[data were removed due to serialization issues]" # @return [String, nil] attr_accessor :category # @return [Hash, nil] attr_accessor :data # @return [String, nil] attr_accessor :level # @return [Time, Integer, nil] attr_accessor :timestamp # @return [String, nil] attr_accessor :type # @return [String, nil] attr_reader :message # @param category [String, nil] # @param data [Hash, nil] # @param message [String, nil] # @param timestamp [Time, Integer, nil] # @param level [String, nil] # @param type [String, nil] 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 # @return [Hash] def to_hash { category: @category, data: serialized_data, level: @level, message: @message, timestamp: @timestamp, type: @type } end # @param message [String] # @return [void] def message=(message) @message = (message || "").byteslice(0..Event::MAX_MESSAGE_SIZE_IN_BYTES) end private 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 end end
Version data entries
33 entries across 33 versions & 2 rubygems