Module: Raven

Extended by:
Forwardable
Defined in:
lib/raven/backtrace.rb,
lib/raven/cli.rb,
lib/raven/base.rb,
lib/raven/event.rb,
lib/raven/client.rb,
lib/raven/logger.rb,
lib/raven/context.rb,
lib/raven/version.rb,
lib/raven/instance.rb,
lib/raven/interface.rb,
lib/raven/linecache.rb,
lib/raven/processor.rb,
lib/raven/transports.rb,
lib/raven/breadcrumbs.rb,
lib/raven/breadcrumbs.rb,
lib/raven/configuration.rb,
lib/raven/utils/real_ip.rb,
lib/raven/interfaces/http.rb,
lib/raven/transports/http.rb,
lib/raven/transports/dummy.rb,
lib/raven/utils/deep_merge.rb,
lib/raven/integrations/rack.rb,
lib/raven/processor/cookies.rb,
lib/raven/breadcrumbs/logger.rb,
lib/raven/integrations/rails.rb,
lib/raven/interfaces/message.rb,
lib/raven/processor/post_data.rb,
lib/raven/integrations/sidekiq.rb,
lib/raven/interfaces/exception.rb,
lib/raven/interfaces/stack_trace.rb,
lib/raven/processor/http_headers.rb,
lib/raven/processor/sanitizedata.rb,
lib/raven/processor/utf8conversion.rb,
lib/raven/breadcrumbs/activesupport.rb,
lib/raven/processor/removestacktrace.rb,
lib/raven/interfaces/single_exception.rb,
lib/raven/integrations/rails/active_job.rb,
lib/raven/processor/removecircularreferences.rb,
lib/raven/integrations/rails/controller_methods.rb,
lib/raven/integrations/rails/controller_transaction.rb,
lib/raven/integrations/rails/overrides/streaming_reporter.rb,
lib/raven/integrations/rails/overrides/debug_exceptions_catcher.rb

Overview

Based on ActionDispatch::RemoteIp. All security-related precautions from that middleware have been removed, because the Event IP just needs to be accurate, and spoofing an IP here only makes data inaccurate, not insecure. Don’t re-use this module if you have to trust the IP address.

Defined Under Namespace

Modules: ActiveSupportBreadcrumbs, BreadcrumbLogger, OldBreadcrumbLogger, RackInterface, Transports, Utils Classes: Backtrace, Breadcrumb, BreadcrumbBuffer, CLI, Client, ClientState, Configuration, Context, Error, Event, ExceptionInterface, HttpInterface, Instance, Interface, LineCache, Logger, MessageInterface, Processor, Rack, Rails, SidekiqCleanupMiddleware, SidekiqErrorHandler, SingleExceptionInterface, StacktraceInterface

Constant Summary collapse

AVAILABLE_INTEGRATIONS =
%w(delayed_job railties sidekiq rack rack-timeout rake).freeze
VERSION =

Freezing this constant breaks in 1.9.x

"2.7.2"

Class Method Summary collapse

Class Method Details

.injectObject

Injects various integrations. Default behavior: inject all available integrations



59
60
61
# File 'lib/raven/base.rb', line 59

def inject
  inject_only(*Raven::AVAILABLE_INTEGRATIONS)
end

.inject_only(*only_integrations) ⇒ Object



68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# File 'lib/raven/base.rb', line 68

def inject_only(*only_integrations)
  only_integrations = only_integrations.map(&:to_s)
  integrations_to_load = Raven::AVAILABLE_INTEGRATIONS & only_integrations
  not_found_integrations = only_integrations - integrations_to_load
  if not_found_integrations.any?
    logger.warn "Integrations do not exist: #{not_found_integrations.join ', '}"
  end
  integrations_to_load &= Gem.loaded_specs.keys
  # TODO(dcramer): integrations should have some additional checks baked-in
  # or we should break them out into their own repos. Specifically both the
  # rails and delayed_job checks are not always valid (i.e. Rails 2.3) and
  # https://github.com/getsentry/raven-ruby/issues/180
  integrations_to_load.each do |integration|
    load_integration(integration)
  end
end

.inject_without(*exclude_integrations) ⇒ Object



63
64
65
66
# File 'lib/raven/base.rb', line 63

def inject_without(*exclude_integrations)
  include_integrations = Raven::AVAILABLE_INTEGRATIONS - exclude_integrations.map(&:to_s)
  inject_only(*include_integrations)
end

.instanceObject



40
41
42
# File 'lib/raven/base.rb', line 40

def instance
  @instance ||= Raven::Instance.new
end

.load_integration(integration) ⇒ Object



85
86
87
88
89
# File 'lib/raven/base.rb', line 85

def load_integration(integration)
  require "raven/integrations/#{integration}"
rescue Exception => error
  logger.warn "Unable to load raven/integrations/#{integration}: #{error}"
end

.safely_prepend(module_name, opts = {}) ⇒ Object



91
92
93
94
95
96
97
98
# File 'lib/raven/base.rb', line 91

def safely_prepend(module_name, opts = {})
  return if opts[:to].nil? || opts[:from].nil?
  if opts[:to].respond_to?(:prepend, true)
    opts[:to].send(:prepend, opts[:from].const_get(module_name))
  else
    opts[:to].send(:include, opts[:from].const_get("Old" + module_name))
  end
end

.sys_command(command) ⇒ Object



100
101
102
103
104
# File 'lib/raven/base.rb', line 100

def sys_command(command)
  result = `#{command} 2>&1` rescue nil
  return if result.nil? || result.empty? || $CHILD_STATUS.exitstatus != 0
  result.strip
end