Class: SolidOps::Configuration

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



10
11
12
13
14
15
16
17
18
19
# File 'lib/solid_ops/configuration.rb', line 10

def initialize
  @enabled = true
  @max_payload_bytes = 10_000
  @redactor = nil
  @retention_period = 7.days       # Auto-purge events older than this
  @sample_rate = 1.0               # 1.0 = capture everything, 0.1 = 10%
  @tenant_resolver = nil           # ->(request) { request.subdomain }
  @actor_resolver = nil            # ->(request) { request.env["warden"]&.user&.id }
  @auth_check = nil                # ->(controller) { controller.current_user&.admin? }
end

Instance Attribute Details

#actor_resolverObject

Returns the value of attribute actor_resolver.



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

def actor_resolver
  @actor_resolver
end

#auth_checkObject

Returns the value of attribute auth_check.



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

def auth_check
  @auth_check
end

#enabledObject

Returns the value of attribute enabled.



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

def enabled
  @enabled
end

#max_payload_bytesObject

Returns the value of attribute max_payload_bytes.



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

def max_payload_bytes
  @max_payload_bytes
end

#redactorObject

Returns the value of attribute redactor.



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

def redactor
  @redactor
end

#retention_periodObject

Returns the value of attribute retention_period.



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

def retention_period
  @retention_period
end

#sample_rateObject

Returns the value of attribute sample_rate.



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

def sample_rate
  @sample_rate
end

#tenant_resolverObject

Returns the value of attribute tenant_resolver.



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

def tenant_resolver
  @tenant_resolver
end

Instance Method Details

#sample?Boolean

Returns:

  • (Boolean)


21
22
23
24
25
26
# File 'lib/solid_ops/configuration.rb', line 21

def sample?
  return true if sample_rate >= 1.0
  return false if sample_rate <= 0.0

  rand < sample_rate
end