Class: DebugBundle::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/debugbundle/config.rb

Constant Summary collapse

DEFAULT_ENDPOINT =
'https://api.debugbundle.com/v1/events'
DEFAULT_PROJECT_MODE =
:connected
DEFAULT_BATCH_SIZE =
25
DEFAULT_FLUSH_INTERVAL =
5
DEFAULT_SAMPLE_RATE =
1.0
DEFAULT_LOG_LEVEL =
:warning
DEFAULT_LOCAL_EVENTS_DIR =
'.debugbundle/local/events'
DEFAULT_SPOOL_DIR =
'.debugbundle/local/browser-relay-spool'
DEFAULT_RELAY_RATE_LIMIT_PER_MINUTE =
60
DEFAULT_MAX_PROBE_LABELS =
50
DEFAULT_MAX_PROBE_ENTRIES_PER_LABEL =
10
DEFAULT_PROBE_FLUSH_ON_ERROR =
true
DEFAULT_PROBES_POLL_INTERVAL =
60
DEFAULT_REDACT_FIELDS =
[].freeze
VALID_PROJECT_MODES =
%i[connected local_only].freeze
VALID_STATUSES =
%i[healthy degraded disconnected].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(project_token: nil, enabled: true, environment: nil, service: nil, endpoint: DEFAULT_ENDPOINT, project_mode: DEFAULT_PROJECT_MODE, local_events_dir: DEFAULT_LOCAL_EVENTS_DIR, spool_dir: DEFAULT_SPOOL_DIR, batch_size: DEFAULT_BATCH_SIZE, flush_interval: DEFAULT_FLUSH_INTERVAL, sample_rate: DEFAULT_SAMPLE_RATE, log_level: DEFAULT_LOG_LEVEL, relay_enabled: true, relay_rate_limit_per_minute: DEFAULT_RELAY_RATE_LIMIT_PER_MINUTE, relay_durable_write: true, redact_fields: DEFAULT_REDACT_FIELDS, max_probe_labels: DEFAULT_MAX_PROBE_LABELS, max_probe_entries_per_label: DEFAULT_MAX_PROBE_ENTRIES_PER_LABEL, probe_flush_on_error: DEFAULT_PROBE_FLUSH_ON_ERROR, probes_poll_interval: DEFAULT_PROBES_POLL_INTERVAL) ⇒ Config

Returns a new instance of Config.



44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# File 'lib/debugbundle/config.rb', line 44

def initialize(
  project_token: nil,
  enabled: true,
  environment: nil,
  service: nil,
  endpoint: DEFAULT_ENDPOINT,
  project_mode: DEFAULT_PROJECT_MODE,
  local_events_dir: DEFAULT_LOCAL_EVENTS_DIR,
  spool_dir: DEFAULT_SPOOL_DIR,
  batch_size: DEFAULT_BATCH_SIZE,
  flush_interval: DEFAULT_FLUSH_INTERVAL,
  sample_rate: DEFAULT_SAMPLE_RATE,
  log_level: DEFAULT_LOG_LEVEL,
  relay_enabled: true,
  relay_rate_limit_per_minute: DEFAULT_RELAY_RATE_LIMIT_PER_MINUTE,
  relay_durable_write: true,
  redact_fields: DEFAULT_REDACT_FIELDS,
  max_probe_labels: DEFAULT_MAX_PROBE_LABELS,
  max_probe_entries_per_label: DEFAULT_MAX_PROBE_ENTRIES_PER_LABEL,
  probe_flush_on_error: DEFAULT_PROBE_FLUSH_ON_ERROR,
  probes_poll_interval: DEFAULT_PROBES_POLL_INTERVAL
)
  @project_token = project_token
  @enabled = enabled
  @environment = environment
  @service = service
  @endpoint = endpoint
  @project_mode = normalize_project_mode(project_mode)
  @local_events_dir = local_events_dir
  @spool_dir = spool_dir
  @batch_size = normalize_positive_integer(batch_size, DEFAULT_BATCH_SIZE)
  @flush_interval = normalize_positive_number(flush_interval, DEFAULT_FLUSH_INTERVAL)
  @sample_rate = normalize_sample_rate(sample_rate)
  @log_level = log_level
  @relay_enabled = relay_enabled
  @relay_rate_limit_per_minute = normalize_positive_integer(
    relay_rate_limit_per_minute,
    DEFAULT_RELAY_RATE_LIMIT_PER_MINUTE
  )
  @relay_durable_write = relay_durable_write
  @redact_fields = normalize_redact_fields(redact_fields)
  @max_probe_labels = normalize_positive_integer(max_probe_labels, DEFAULT_MAX_PROBE_LABELS)
  @max_probe_entries_per_label = normalize_positive_integer(
    max_probe_entries_per_label,
    DEFAULT_MAX_PROBE_ENTRIES_PER_LABEL
  )
  @probe_flush_on_error = probe_flush_on_error
  @probes_poll_interval = normalize_positive_number(probes_poll_interval, DEFAULT_PROBES_POLL_INTERVAL)
  freeze
end

Instance Attribute Details

#batch_sizeObject (readonly)

Returns the value of attribute batch_size.



23
24
25
# File 'lib/debugbundle/config.rb', line 23

def batch_size
  @batch_size
end

#enabledObject (readonly)

Returns the value of attribute enabled.



23
24
25
# File 'lib/debugbundle/config.rb', line 23

def enabled
  @enabled
end

#endpointObject (readonly)

Returns the value of attribute endpoint.



23
24
25
# File 'lib/debugbundle/config.rb', line 23

def endpoint
  @endpoint
end

#environmentObject (readonly)

Returns the value of attribute environment.



23
24
25
# File 'lib/debugbundle/config.rb', line 23

def environment
  @environment
end

#flush_intervalObject (readonly)

Returns the value of attribute flush_interval.



23
24
25
# File 'lib/debugbundle/config.rb', line 23

def flush_interval
  @flush_interval
end

#local_events_dirObject (readonly)

Returns the value of attribute local_events_dir.



23
24
25
# File 'lib/debugbundle/config.rb', line 23

def local_events_dir
  @local_events_dir
end

#log_levelObject (readonly)

Returns the value of attribute log_level.



23
24
25
# File 'lib/debugbundle/config.rb', line 23

def log_level
  @log_level
end

#max_probe_entries_per_labelObject (readonly)

Returns the value of attribute max_probe_entries_per_label.



23
24
25
# File 'lib/debugbundle/config.rb', line 23

def max_probe_entries_per_label
  @max_probe_entries_per_label
end

#max_probe_labelsObject (readonly)

Returns the value of attribute max_probe_labels.



23
24
25
# File 'lib/debugbundle/config.rb', line 23

def max_probe_labels
  @max_probe_labels
end

#probe_flush_on_errorObject (readonly)

Returns the value of attribute probe_flush_on_error.



23
24
25
# File 'lib/debugbundle/config.rb', line 23

def probe_flush_on_error
  @probe_flush_on_error
end

#probes_poll_intervalObject (readonly)

Returns the value of attribute probes_poll_interval.



23
24
25
# File 'lib/debugbundle/config.rb', line 23

def probes_poll_interval
  @probes_poll_interval
end

#project_modeObject (readonly)

Returns the value of attribute project_mode.



23
24
25
# File 'lib/debugbundle/config.rb', line 23

def project_mode
  @project_mode
end

#project_tokenObject (readonly)

Returns the value of attribute project_token.



23
24
25
# File 'lib/debugbundle/config.rb', line 23

def project_token
  @project_token
end

#redact_fieldsObject (readonly)

Returns the value of attribute redact_fields.



23
24
25
# File 'lib/debugbundle/config.rb', line 23

def redact_fields
  @redact_fields
end

#relay_durable_writeObject (readonly)

Returns the value of attribute relay_durable_write.



23
24
25
# File 'lib/debugbundle/config.rb', line 23

def relay_durable_write
  @relay_durable_write
end

#relay_enabledObject (readonly)

Returns the value of attribute relay_enabled.



23
24
25
# File 'lib/debugbundle/config.rb', line 23

def relay_enabled
  @relay_enabled
end

#relay_rate_limit_per_minuteObject (readonly)

Returns the value of attribute relay_rate_limit_per_minute.



23
24
25
# File 'lib/debugbundle/config.rb', line 23

def relay_rate_limit_per_minute
  @relay_rate_limit_per_minute
end

#sample_rateObject (readonly)

Returns the value of attribute sample_rate.



23
24
25
# File 'lib/debugbundle/config.rb', line 23

def sample_rate
  @sample_rate
end

#serviceObject (readonly)

Returns the value of attribute service.



23
24
25
# File 'lib/debugbundle/config.rb', line 23

def service
  @service
end

#spool_dirObject (readonly)

Returns the value of attribute spool_dir.



23
24
25
# File 'lib/debugbundle/config.rb', line 23

def spool_dir
  @spool_dir
end

Instance Method Details

#configured?Boolean

Returns:

  • (Boolean)


99
100
101
# File 'lib/debugbundle/config.rb', line 99

def configured?
  !project_token.to_s.empty?
end

#enabled?Boolean

Returns:

  • (Boolean)


95
96
97
# File 'lib/debugbundle/config.rb', line 95

def enabled?
  enabled
end