class Sentry::Event

Please don’t use it directly. The user-facing classes are its child classes.
This is an abstract class that defines the shared attributes of an event.

def add_request_interface(env)

def add_request_interface(env)
  @request = Sentry::RequestInterface.new(env: env, send_default_pii: @send_default_pii, rack_env_whitelist: @rack_env_whitelist)
end

def calculate_real_ip_from_rack(env)

REMOTE_ADDR to determine the Event IP, and must use other headers instead.
When behind a proxy (or if the user is using a proxy), we can't use
def calculate_real_ip_from_rack(env)
  Utils::RealIp.new(
    :remote_addr => env["REMOTE_ADDR"],
    :client_ip => env["HTTP_CLIENT_IP"],
    :real_ip => env["HTTP_X_REAL_IP"],
    :forwarded_for => env["HTTP_X_FORWARDED_FOR"],
    :trusted_proxies => @trusted_proxies
  ).calculate_ip
end

def configuration

Returns:
  • (Configuration) -

Deprecated:
  • This method will be removed in v5.0.0. Please just use Sentry.configuration
def configuration
  Sentry.configuration
end

def get_log_message(event_hash)

@!visibility private
def get_log_message(event_hash)
  message = event_hash[:message] || event_hash['message']
  return message unless message.nil? || message.empty?
  message = get_message_from_exception(event_hash)
  return message unless message.nil? || message.empty?
  message = event_hash[:transaction] || event_hash["transaction"]
  return message unless message.nil? || message.empty?
  '<no message value>'
end

def get_message_from_exception(event_hash)

@!visibility private
def get_message_from_exception(event_hash)
  if exception = event_hash.dig(:exception, :values, 0)
    "#{exception[:type]}: #{exception[:value]}"
  elsif exception = event_hash.dig("exception", "values", 0)
    "#{exception["type"]}: #{exception["value"]}"
  end
end

def initialize(configuration:, integration_meta: nil, message: nil)

Parameters:
  • message (String, nil) --
  • integration_meta (Hash, nil) --
  • configuration (Configuration) --
def initialize(configuration:, integration_meta: nil, message: nil)
  # Set some simple default values
  @event_id      = SecureRandom.uuid.delete("-")
  @timestamp     = Sentry.utc_now.iso8601
  @platform      = :ruby
  @type          = self.class::TYPE
  @sdk           = integration_meta || Sentry.sdk_meta
  @user          = {}
  @extra         = {}
  @contexts      = {}
  @tags          = {}
  @fingerprint = []
  # configuration data that's directly used by events
  @server_name = configuration.server_name
  @environment = configuration.environment
  @release = configuration.release
  @modules = configuration.gem_specs if configuration.send_modules
  # configuration options to help events process data
  @send_default_pii = configuration.send_default_pii
  @trusted_proxies = configuration.trusted_proxies
  @stacktrace_builder = configuration.stacktrace_builder
  @rack_env_whitelist = configuration.rack_env_whitelist
  @message = (message || "").byteslice(0..MAX_MESSAGE_SIZE_IN_BYTES)
end

def level=(level) # needed to meet the Sentry spec

Returns:
  • (void) -

Parameters:
  • level (String, Symbol) --
def level=(level) # needed to meet the Sentry spec
  @level = level.to_s == "warn" ? :warning : level
end

def rack_env=(env)

Returns:
  • (void) -

Parameters:
  • env (Hash) --

Other tags:
    See: RequestInterface -
def rack_env=(env)
  unless request || env.empty?
    add_request_interface(env)
    if @send_default_pii
      user[:ip_address] = calculate_real_ip_from_rack(env)
    end
    if request_id = Utils::RequestId.read_from(env)
      tags[:request_id] = request_id
    end
  end
end

def serialize_attributes

def serialize_attributes
  self.class::SERIALIZEABLE_ATTRIBUTES.each_with_object({}) do |att, memo|
    if value = public_send(att)
      memo[att] = value
    end
  end
end

def timestamp=(time)

Returns:
  • (void) -

Parameters:
  • time (Time, Float) --
def timestamp=(time)
  @timestamp = time.is_a?(Time) ? time.to_f : time
end

def to_hash

Returns:
  • (Hash) -
def to_hash
  data = serialize_attributes
  data[:breadcrumbs] = breadcrumbs.to_hash if breadcrumbs
  data[:request] = request.to_hash if request
  data
end

def to_json_compatible

Returns:
  • (Hash) -
def to_json_compatible
  JSON.parse(JSON.generate(to_hash))
end