Module: Gruf::Sentry::Configuration

Included in:
Gruf::Sentry
Defined in:
lib/gruf/sentry/configuration.rb

Overview

Configuration module for gruf-sentry

Constant Summary collapse

VALID_CONFIG_KEYS =
{
  grpc_error_classes: ::ENV.fetch(
    'GRUF_SENTRY_GRPC_ERROR_CLASSES',
    'GRPC::Unknown,GRPC::Internal,GRPC::DataLoss,GRPC::FailedPrecondition,GRPC::Unavailable,GRPC::DeadlineExceeded,GRPC::Cancelled'
  ).to_s.split(',').map(&:strip),
  default_error_code: ::ENV.fetch('GRUF_SENTRY_DEFAULT_ERROR_CODE', GRPC::Core::StatusCodes::INTERNAL).to_i,
  ignore_methods: ::ENV.fetch('GRUF_SENTRY_IGNORE_METHODS', '').split(',').map(&:strip) || []
}.freeze

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.extended(base) ⇒ Object

Whenever this is extended into a class, setup the defaults



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

def self.extended(base)
  base.reset
end

Instance Method Details

#configure {|_self| ... } ⇒ Gruf::Sentry::Configuration

Yield self for ruby-style initialization

Yields:

  • (_self)

Yield Parameters:

Returns:



48
49
50
# File 'lib/gruf/sentry/configuration.rb', line 48

def configure
  yield self
end

#optionsHash

Return the current configuration options as a Hash

Returns:

  • (Hash)


57
58
59
60
61
62
63
# File 'lib/gruf/sentry/configuration.rb', line 57

def options
  opts = {}
  VALID_CONFIG_KEYS.each_key do |k|
    opts.merge!(k => send(k))
  end
  opts
end

#resetHash

Set the default configuration onto the extended class

Returns:

  • (Hash)

    options The reset options hash



70
71
72
73
74
75
76
# File 'lib/gruf/sentry/configuration.rb', line 70

def reset
  VALID_CONFIG_KEYS.each do |k, v|
    send("#{k}=".to_sym, v)
  end

  options
end