Class: Opbeat::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/opbeat/configuration.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/opbeat/configuration.rb', line 47

def initialize
  self.server = ENV['OPBEAT_SERVER'] || "https://opbeat.com"
  self.secret_token = ENV['OPBEAT_SECRET_TOKEN'] if ENV['OPBEAT_SECRET_TOKEN']
  self.organization_id = ENV['OPBEAT_ORGANIZATION_ID'] if ENV['OPBEAT_ORGANIZATION_ID']
  self.app_id = ENV['OPBEAT_APP_ID'] if ENV['OPBEAT_APP_ID']
  @context_lines = 3
  self.environments = %w[ development production default ]
  self.current_environment = ENV['RAILS_ENV'] || ENV['RACK_ENV'] || 'default'
  self.excluded_exceptions = []
  self.processors = [Opbeat::Processor::SanitizeData]
  self.timeout = 1
  self.backoff_multiplier = 2
  self.ssl_verification = true
  self.user_controller_method = 'current_user'
end

Instance Attribute Details

#app_idObject

App ID to use with Opbeat



14
15
16
# File 'lib/opbeat/configuration.rb', line 14

def app_id
  @app_id
end

#backoff_multiplierObject

Backoff multipler



38
39
40
# File 'lib/opbeat/configuration.rb', line 38

def backoff_multiplier
  @backoff_multiplier
end

#context_linesObject

Number of lines of code context to capture, or nil for none



20
21
22
# File 'lib/opbeat/configuration.rb', line 20

def context_lines
  @context_lines
end

#current_environmentObject

Returns the value of attribute current_environment.



43
44
45
# File 'lib/opbeat/configuration.rb', line 43

def current_environment
  @current_environment
end

#environmentsObject

Whitelist of environments that will send notifications to Opbeat



23
24
25
# File 'lib/opbeat/configuration.rb', line 23

def environments
  @environments
end

#excluded_exceptionsObject

Which exceptions should never be sent



26
27
28
# File 'lib/opbeat/configuration.rb', line 26

def excluded_exceptions
  @excluded_exceptions
end

#loggerObject

Logger to use internally



17
18
19
# File 'lib/opbeat/configuration.rb', line 17

def logger
  @logger
end

#open_timeoutObject

Timout when opening connection to the server



35
36
37
# File 'lib/opbeat/configuration.rb', line 35

def open_timeout
  @open_timeout
end

#organization_idObject

Organization ID to use with Opbeat



11
12
13
# File 'lib/opbeat/configuration.rb', line 11

def organization_id
  @organization_id
end

#processorsObject

Processors to run on data before sending upstream



29
30
31
# File 'lib/opbeat/configuration.rb', line 29

def processors
  @processors
end

#secret_tokenObject

Secret access token for authentication with Opbeat



8
9
10
# File 'lib/opbeat/configuration.rb', line 8

def secret_token
  @secret_token
end

#serverObject

Base URL of the Opbeat server



5
6
7
# File 'lib/opbeat/configuration.rb', line 5

def server
  @server
end

#ssl_verificationObject

Should the SSL certificate of the server be verified?



41
42
43
# File 'lib/opbeat/configuration.rb', line 41

def ssl_verification
  @ssl_verification
end

#timeoutObject

Timeout when waiting for the server to return data in seconds



32
33
34
# File 'lib/opbeat/configuration.rb', line 32

def timeout
  @timeout
end

#user_controller_methodObject

Returns the value of attribute user_controller_method.



45
46
47
# File 'lib/opbeat/configuration.rb', line 45

def user_controller_method
  @user_controller_method
end

Instance Method Details

#[](option) ⇒ Object

Allows config options to be read like a hash

Parameters:

  • option (Symbol)

    Key for a given attribute



66
67
68
# File 'lib/opbeat/configuration.rb', line 66

def [](option)
  send(option)
end

#send_in_current_environment?Boolean

Returns:

  • (Boolean)


74
75
76
# File 'lib/opbeat/configuration.rb', line 74

def send_in_current_environment?
  environments.include? current_environment
end