class Sentry::Scope

Experimental RBS support (using type sampling data from the type_fusion project).

# sig/sentry/scope.rbs

class Sentry::Scope
  def add_breadcrumb: (Sentry::Breadcrumb breadcrumb) -> Array[NilClass]
  def set_transaction_name: (String transaction_name, source: Symbol) -> untyped
end

def add_breadcrumb(breadcrumb)

Experimental RBS support (using type sampling data from the type_fusion project).

def add_breadcrumb: (Sentry::Breadcrumb breadcrumb) -> NilClass | NilClass | NilClass | NilClass | NilClass | NilClass | NilClass | NilClass | NilClass | NilClass | NilClass | NilClass | NilClass | NilClass | NilClass | NilClass | NilClass | NilClass | NilClass | NilClass | NilClass | NilClass | NilClass | NilClass | NilClass | NilClass | NilClass | NilClass | NilClass | NilClass | NilClass | NilClass | NilClass | NilClass | NilClass | NilClass | NilClass | NilClass | NilClass | NilClass | NilClass | NilClass | NilClass | NilClass | NilClass | NilClass | NilClass | NilClass | NilClass | NilClass | NilClass | NilClass | NilClass | NilClass | NilClass | NilClass | NilClass | NilClass | NilClass | Sentry::Breadcrumb | Sentry::Breadcrumb | Sentry::Breadcrumb | Sentry::Breadcrumb | Sentry::Breadcrumb | Sentry::Breadcrumb | Sentry::Breadcrumb | Sentry::Breadcrumb | Sentry::Breadcrumb | Sentry::Breadcrumb | Sentry::Breadcrumb | Sentry::Breadcrumb | Sentry::Breadcrumb | Sentry::Breadcrumb | Sentry::Breadcrumb | Sentry::Breadcrumb | Sentry::Breadcrumb | Sentry::Breadcrumb | Sentry::Breadcrumb | Sentry::Breadcrumb | Sentry::Breadcrumb | Sentry::Breadcrumb | Sentry::Breadcrumb | Sentry::Breadcrumb | Sentry::Breadcrumb | Sentry::Breadcrumb | Sentry::Breadcrumb | Sentry::Breadcrumb | Sentry::Breadcrumb | Sentry::Breadcrumb | Sentry::Breadcrumb | Sentry::Breadcrumb | Sentry::Breadcrumb | Sentry::Breadcrumb | Sentry::Breadcrumb | Sentry::Breadcrumb | Sentry::Breadcrumb | Sentry::Breadcrumb | Sentry::Breadcrumb | Sentry::Breadcrumb

This signature was generated using 4 samples from 1 application.

Returns:
  • (void) -

Parameters:
  • breadcrumb (Breadcrumb) --
def add_breadcrumb(breadcrumb)
  breadcrumbs.record(breadcrumb)
end

def add_event_processor(&block)

Returns:
  • (void) -

Parameters:
  • block (Proc) --
def add_event_processor(&block)
  @event_processors << block
end

def add_global_event_processor(&block)

Returns:
  • (void) -

Parameters:
  • block (Proc) --
def add_global_event_processor(&block)
  global_event_processors << block
end

def apply_to_event(event, hint = nil)

Returns:
  • (Event) -

Parameters:
  • hint (Hash) -- the hint data that'll be passed to event processors.
  • event (Event) --
def apply_to_event(event, hint = nil)
  event.tags = tags.merge(event.tags)
  event.user = user.merge(event.user)
  event.extra = extra.merge(event.extra)
  event.contexts = contexts.merge(event.contexts)
  event.transaction = transaction_name if transaction_name
  event.transaction_info = { source: transaction_source } if transaction_source
  if span
    event.contexts[:trace] = span.get_trace_context
  end
  event.fingerprint = fingerprint
  event.level = level
  event.breadcrumbs = breadcrumbs
  event.rack_env = rack_env if rack_env
  all_event_processors = self.class.global_event_processors + @event_processors
  unless all_event_processors.empty?
    all_event_processors.each do |processor_block|
      event = processor_block.call(event, hint)
    end
  end
  event
end

def clear

Returns:
  • (void) -
def clear
  set_default_value
end

def clear_breadcrumbs

Returns:
  • (void) -
def clear_breadcrumbs
  set_new_breadcrumb_buffer
end

def dup

Returns:
  • (Scope) -
def dup
  copy = super
  copy.breadcrumbs = breadcrumbs.dup
  copy.contexts = contexts.deep_dup
  copy.extra = extra.deep_dup
  copy.tags = tags.deep_dup
  copy.user = user.deep_dup
  copy.transaction_names = transaction_names.dup
  copy.transaction_sources = transaction_sources.dup
  copy.fingerprint = fingerprint.deep_dup
  copy.span = span.deep_dup
  copy.session = session.deep_dup
  copy
end

def get_span

Returns:
  • (Span, nil) -
def get_span
  span
end

def get_transaction

Returns:
  • (Transaction, nil) -
def get_transaction
  span.transaction if span
end

def global_event_processors

Returns:
  • (Array) -
def global_event_processors
  @global_event_processors ||= []
end

def initialize(max_breadcrumbs: nil)

Parameters:
  • max_breadcrumbs (Integer) -- the maximum number of breadcrumbs to be stored in the scope.
def initialize(max_breadcrumbs: nil)
  @max_breadcrumbs = max_breadcrumbs
  set_default_value
end

def os_context

Returns:
  • (Hash) -
def os_context
  @os_context ||=
    begin
      uname = Etc.uname
      {
        name: uname[:sysname] || RbConfig::CONFIG["host_os"],
        version: uname[:version],
        build: uname[:release],
        kernel_version: uname[:version],
        machine: uname[:machine]
      }
    end
end

def runtime_context

Returns:
  • (Hash) -
def runtime_context
  @runtime_context ||= {
    name: RbConfig::CONFIG["ruby_install_name"],
    version: RUBY_DESCRIPTION || Sentry.sys_command("ruby -v")
  }
end

def set_context(key, value)

@!macro set_context
def set_context(key, value)
  check_argument_type!(value, Hash)
  set_contexts(key => value)
end

def set_contexts(contexts_hash)

Returns:
  • (Hash) -

Parameters:
  • contexts (Hash) --
def set_contexts(contexts_hash)
  check_argument_type!(contexts_hash, Hash)
  contexts_hash.values.each do |val|
    check_argument_type!(val, Hash)
  end
  @contexts.merge!(contexts_hash) do |key, old, new|
    old.merge(new)
  end
end

def set_default_value

def set_default_value
  @contexts = { :os => self.class.os_context, :runtime => self.class.runtime_context }
  @extra = {}
  @tags = {}
  @user = {}
  @level = :error
  @fingerprint = []
  @transaction_names = []
  @transaction_sources = []
  @event_processors = []
  @rack_env = {}
  @span = nil
  @session = nil
  set_new_breadcrumb_buffer
end

def set_extra(key, value)

Returns:
  • (Hash) -

Parameters:
  • value (Object) --
  • key (String, Symbol) --
def set_extra(key, value)
  set_extras(key => value)
end

def set_extras(extras_hash)

@!macro set_extras
def set_extras(extras_hash)
  check_argument_type!(extras_hash, Hash)
  @extra.merge!(extras_hash)
end

def set_fingerprint(fingerprint)

Returns:
  • (Array) -

Parameters:
  • fingerprint (Array) --
def set_fingerprint(fingerprint)
  check_argument_type!(fingerprint, Array)
  @fingerprint = fingerprint
end

def set_level(level)

Returns:
  • (void) -

Parameters:
  • level (String, Symbol) --
def set_level(level)
  @level = level
end

def set_new_breadcrumb_buffer

def set_new_breadcrumb_buffer
  @breadcrumbs = BreadcrumbBuffer.new(@max_breadcrumbs)
end

def set_rack_env(env)

Returns:
  • (Hash) -

Parameters:
  • env (Hash) --
def set_rack_env(env)
  env = env || {}
  @rack_env = env
end

def set_session(session)

Returns:
  • (void) -

Parameters:
  • session (Session, nil) --
def set_session(session)
  @session = session
end

def set_span(span)

Returns:
  • (Span) -

Parameters:
  • span (Span) --
def set_span(span)
  check_argument_type!(span, Span)
  @span = span
end

def set_tag(key, value)

Returns:
  • (Hash) -

Parameters:
  • value (Object) --
  • key (String, Symbol) --
def set_tag(key, value)
  set_tags(key => value)
end

def set_tags(tags_hash)

@!macro set_tags
def set_tags(tags_hash)
  check_argument_type!(tags_hash, Hash)
  @tags.merge!(tags_hash)
end

def set_transaction_name(transaction_name, source: :custom)

Experimental RBS support (using type sampling data from the type_fusion project).

def set_transaction_name: (String transaction_name, source: Symbol) -> untyped

This signature was generated using 1 sample from 1 application.

Returns:
  • (void) -

Parameters:
  • transaction_name (String) --
def set_transaction_name(transaction_name, source: :custom)
  @transaction_names << transaction_name
  @transaction_sources << source
end

def set_user(user_hash)

@!macro set_user
def set_user(user_hash)
  check_argument_type!(user_hash, Hash)
  @user = user_hash
end

def transaction_name

Returns:
  • (String, nil) -
def transaction_name
  @transaction_names.last
end

def transaction_source

Returns:
  • (String, nil) -
def transaction_source
  @transaction_sources.last
end

def update_from_options(

Returns:
  • (void) -

Parameters:
  • fingerprint (Array) --
  • level (String, Symbol) --
  • user (Hash) --
  • tags (Hash) --
  • extras (Hash) --
  • contexts (Hash) --
def update_from_options(
  contexts: nil,
  extra: nil,
  tags: nil,
  user: nil,
  level: nil,
  fingerprint: nil
)
  self.contexts.merge!(contexts) if contexts
  self.extra.merge!(extra) if extra
  self.tags.merge!(tags) if tags
  self.user = user if user
  self.level = level if level
  self.fingerprint = fingerprint if fingerprint
end

def update_from_scope(scope)

Returns:
  • (void) -

Parameters:
  • scope (Scope) --
def update_from_scope(scope)
  self.breadcrumbs = scope.breadcrumbs
  self.contexts = scope.contexts
  self.extra = scope.extra
  self.tags = scope.tags
  self.user = scope.user
  self.transaction_names = scope.transaction_names
  self.transaction_sources = scope.transaction_sources
  self.fingerprint = scope.fingerprint
  self.span = scope.span
end