Class: ForgeOpsTracker::Configuration

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/forge_ops_tracker/configuration.rb', line 11

def initialize
  @dsn = ENV["FORGE_OPS_DSN"]
  @environment = ENV["RAILS_ENV"] || ENV["RACK_ENV"] || "development"
  @release = ENV["FORGE_OPS_RELEASE"]
  @server_name = safe_hostname
  @enabled_environments = %w[production staging]
  @queue_size = 1000
  @open_timeout = 2
  @read_timeout = 2
  @logger = nil
  # See PiiScrubber -- redacts likely-sensitive content (emails,
  # credit cards, known API key formats, anything under a
  # suspiciously-named key) before a payload ever leaves this
  # process. ForgeOps itself scrubs again on arrival regardless, so
  # this is a second, earlier layer, not the only one -- but "on" is
  # the only sane default.
  @scrub_pii = true
end

Instance Attribute Details

#app_rootObject

A single Sentry-style DSN string carries both the ingestion URL and the project's api_key: "https://<api_key>@host/api/v1/events".



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

def app_root
  @app_root
end

#dsnObject

A single Sentry-style DSN string carries both the ingestion URL and the project's api_key: "https://<api_key>@host/api/v1/events".



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

def dsn
  @dsn
end

#enabled_environmentsObject

Returns the value of attribute enabled_environments.



9
10
11
# File 'lib/forge_ops_tracker/configuration.rb', line 9

def enabled_environments
  @enabled_environments
end

#environmentObject

A single Sentry-style DSN string carries both the ingestion URL and the project's api_key: "https://<api_key>@host/api/v1/events".



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

def environment
  @environment
end

#loggerObject

A single Sentry-style DSN string carries both the ingestion URL and the project's api_key: "https://<api_key>@host/api/v1/events".



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

def logger
  @logger
end

#open_timeoutObject

Returns the value of attribute open_timeout.



9
10
11
# File 'lib/forge_ops_tracker/configuration.rb', line 9

def open_timeout
  @open_timeout
end

#queue_sizeObject

Returns the value of attribute queue_size.



9
10
11
# File 'lib/forge_ops_tracker/configuration.rb', line 9

def queue_size
  @queue_size
end

#read_timeoutObject

Returns the value of attribute read_timeout.



9
10
11
# File 'lib/forge_ops_tracker/configuration.rb', line 9

def read_timeout
  @read_timeout
end

#releaseObject

A single Sentry-style DSN string carries both the ingestion URL and the project's api_key: "https://<api_key>@host/api/v1/events".



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

def release
  @release
end

#scrub_piiObject

Returns the value of attribute scrub_pii.



9
10
11
# File 'lib/forge_ops_tracker/configuration.rb', line 9

def scrub_pii
  @scrub_pii
end

#server_nameObject

A single Sentry-style DSN string carries both the ingestion URL and the project's api_key: "https://<api_key>@host/api/v1/events".



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

def server_name
  @server_name
end

Instance Method Details

#api_keyObject



30
31
32
# File 'lib/forge_ops_tracker/configuration.rb', line 30

def api_key
  parsed_dsn&.user
end

#enabled?Boolean

Returns:

  • (Boolean)


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

def enabled?
  !blank?(dsn) && !blank?(api_key) && enabled_environments.map(&:to_s).include?(environment.to_s)
end

#ingestion_uriObject

The ingestion URL with credentials stripped out (they travel as the Authorization header instead, not embedded in the request URI).



36
37
38
39
40
41
42
43
# File 'lib/forge_ops_tracker/configuration.rb', line 36

def ingestion_uri
  return nil unless parsed_dsn

  uri = parsed_dsn.dup
  uri.user = nil
  uri.password = nil
  uri
end