-
-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathsentry.rb
More file actions
56 lines (48 loc) · 1.4 KB
/
sentry.rb
File metadata and controls
56 lines (48 loc) · 1.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# frozen_string_literal: true
module Html2rss
module Web
module Boot
##
# Configures Sentry boot-time error and structured log capture.
module Sentry
class << self
# @return [void]
def configure!
return unless configure?
Bundler.require(:sentry)
require 'sentry-ruby'
initialize_sentry!
end
private
# @return [Boolean]
def configure?
RuntimeEnv.sentry_enabled? && !sentry_initialized?
end
# @return [void]
def initialize_sentry!
::Sentry.init do |config|
apply_settings(config)
end
end
# @param config [Object]
# @return [void]
def apply_settings(config)
config.dsn = RuntimeEnv.sentry_dsn
config.environment = RuntimeEnv.rack_env
config.enable_logs = RuntimeEnv.sentry_logs_enabled?
config.send_default_pii = false
config.release = release_name
end
# @return [String]
def release_name
"#{RuntimeEnv.build_tag}+#{RuntimeEnv.git_sha}"
end
# @return [Boolean]
def sentry_initialized?
defined?(::Sentry) && ::Sentry.respond_to?(:initialized?) && ::Sentry.initialized?
end
end
end
end
end
end