sentry-ruby 4.1.4 → 4.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +10 -2
- metadata +21 -57
- data/.craft.yml +0 -19
- data/.gitignore +0 -11
- data/.rspec +0 -3
- data/.travis.yml +0 -6
- data/CHANGELOG.md +0 -120
- data/CODE_OF_CONDUCT.md +0 -74
- data/Gemfile +0 -16
- data/Rakefile +0 -8
- data/bin/console +0 -14
- data/bin/setup +0 -8
- data/lib/sentry-ruby.rb +0 -190
- data/lib/sentry/background_worker.rb +0 -37
- data/lib/sentry/backtrace.rb +0 -126
- data/lib/sentry/benchmarks/benchmark_transport.rb +0 -14
- data/lib/sentry/breadcrumb.rb +0 -25
- data/lib/sentry/breadcrumb/sentry_logger.rb +0 -87
- data/lib/sentry/breadcrumb_buffer.rb +0 -47
- data/lib/sentry/client.rb +0 -96
- data/lib/sentry/configuration.rb +0 -396
- data/lib/sentry/core_ext/object/deep_dup.rb +0 -57
- data/lib/sentry/core_ext/object/duplicable.rb +0 -153
- data/lib/sentry/dsn.rb +0 -48
- data/lib/sentry/event.rb +0 -171
- data/lib/sentry/hub.rb +0 -143
- data/lib/sentry/integrable.rb +0 -24
- data/lib/sentry/interface.rb +0 -22
- data/lib/sentry/interfaces/exception.rb +0 -11
- data/lib/sentry/interfaces/request.rb +0 -113
- data/lib/sentry/interfaces/single_exception.rb +0 -14
- data/lib/sentry/interfaces/stacktrace.rb +0 -90
- data/lib/sentry/linecache.rb +0 -44
- data/lib/sentry/logger.rb +0 -20
- data/lib/sentry/rack.rb +0 -4
- data/lib/sentry/rack/capture_exceptions.rb +0 -68
- data/lib/sentry/rack/deprecations.rb +0 -19
- data/lib/sentry/rake.rb +0 -17
- data/lib/sentry/scope.rb +0 -210
- data/lib/sentry/span.rb +0 -133
- data/lib/sentry/transaction.rb +0 -157
- data/lib/sentry/transaction_event.rb +0 -29
- data/lib/sentry/transport.rb +0 -88
- data/lib/sentry/transport/configuration.rb +0 -21
- data/lib/sentry/transport/dummy_transport.rb +0 -14
- data/lib/sentry/transport/http_transport.rb +0 -62
- data/lib/sentry/utils/argument_checking_helper.rb +0 -11
- data/lib/sentry/utils/exception_cause_chain.rb +0 -20
- data/lib/sentry/utils/real_ip.rb +0 -70
- data/lib/sentry/utils/request_id.rb +0 -16
- data/lib/sentry/version.rb +0 -3
- data/sentry-ruby.gemspec +0 -27
@@ -1,29 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Sentry
|
4
|
-
class TransactionEvent < Event
|
5
|
-
ATTRIBUTES = %i(
|
6
|
-
event_id level timestamp start_timestamp
|
7
|
-
release environment server_name modules
|
8
|
-
user tags contexts extra
|
9
|
-
transaction platform sdk type
|
10
|
-
)
|
11
|
-
|
12
|
-
attr_accessor(*ATTRIBUTES)
|
13
|
-
attr_accessor :spans
|
14
|
-
|
15
|
-
def start_timestamp=(time)
|
16
|
-
@start_timestamp = time.is_a?(Time) ? time.to_f : time
|
17
|
-
end
|
18
|
-
|
19
|
-
def type
|
20
|
-
"transaction"
|
21
|
-
end
|
22
|
-
|
23
|
-
def to_hash
|
24
|
-
data = super
|
25
|
-
data[:spans] = @spans.map(&:to_hash) if @spans
|
26
|
-
data
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
data/lib/sentry/transport.rb
DELETED
@@ -1,88 +0,0 @@
|
|
1
|
-
require "json"
|
2
|
-
require "base64"
|
3
|
-
|
4
|
-
module Sentry
|
5
|
-
class Transport
|
6
|
-
PROTOCOL_VERSION = '5'
|
7
|
-
USER_AGENT = "sentry-ruby/#{Sentry::VERSION}"
|
8
|
-
|
9
|
-
attr_accessor :configuration
|
10
|
-
|
11
|
-
def initialize(configuration)
|
12
|
-
@configuration = configuration
|
13
|
-
@transport_configuration = configuration.transport
|
14
|
-
@dsn = configuration.dsn
|
15
|
-
end
|
16
|
-
|
17
|
-
def send_data(data, options = {})
|
18
|
-
raise NotImplementedError
|
19
|
-
end
|
20
|
-
|
21
|
-
def send_event(event)
|
22
|
-
unless configuration.sending_allowed?
|
23
|
-
configuration.logger.debug(LOGGER_PROGNAME) { "Event not sent: #{configuration.error_messages}" }
|
24
|
-
return
|
25
|
-
end
|
26
|
-
|
27
|
-
encoded_data = prepare_encoded_event(event)
|
28
|
-
|
29
|
-
return nil unless encoded_data
|
30
|
-
|
31
|
-
send_data(encoded_data)
|
32
|
-
|
33
|
-
event
|
34
|
-
rescue => e
|
35
|
-
failed_for_exception(e, event)
|
36
|
-
nil
|
37
|
-
end
|
38
|
-
|
39
|
-
def generate_auth_header
|
40
|
-
now = Sentry.utc_now.to_i
|
41
|
-
fields = {
|
42
|
-
'sentry_version' => PROTOCOL_VERSION,
|
43
|
-
'sentry_client' => USER_AGENT,
|
44
|
-
'sentry_timestamp' => now,
|
45
|
-
'sentry_key' => @dsn.public_key
|
46
|
-
}
|
47
|
-
fields['sentry_secret'] = @dsn.secret_key if @dsn.secret_key
|
48
|
-
'Sentry ' + fields.map { |key, value| "#{key}=#{value}" }.join(', ')
|
49
|
-
end
|
50
|
-
|
51
|
-
def encode(event_hash)
|
52
|
-
event_id = event_hash[:event_id] || event_hash['event_id']
|
53
|
-
event_type = event_hash[:type] || event_hash['type']
|
54
|
-
|
55
|
-
envelope = <<~ENVELOPE
|
56
|
-
{"event_id":"#{event_id}","dsn":"#{configuration.dsn.to_s}","sdk":#{Sentry.sdk_meta.to_json},"sent_at":"#{Sentry.utc_now.iso8601}"}
|
57
|
-
{"type":"#{event_type}","content_type":"application/json"}
|
58
|
-
#{JSON.generate(event_hash)}
|
59
|
-
ENVELOPE
|
60
|
-
|
61
|
-
envelope
|
62
|
-
end
|
63
|
-
|
64
|
-
private
|
65
|
-
|
66
|
-
def prepare_encoded_event(event)
|
67
|
-
# Convert to hash
|
68
|
-
event_hash = event.to_hash
|
69
|
-
|
70
|
-
event_id = event_hash[:event_id] || event_hash["event_id"]
|
71
|
-
event_type = event_hash[:type] || event_hash["type"]
|
72
|
-
configuration.logger.info(LOGGER_PROGNAME) { "Sending #{event_type} #{event_id} to Sentry" }
|
73
|
-
encode(event_hash)
|
74
|
-
end
|
75
|
-
|
76
|
-
def failed_for_exception(e, event)
|
77
|
-
configuration.logger.warn(LOGGER_PROGNAME) { "Unable to record event with remote Sentry server (#{e.class} - #{e.message}):\n#{e.backtrace[0..10].join("\n")}" }
|
78
|
-
log_not_sending(event)
|
79
|
-
end
|
80
|
-
|
81
|
-
def log_not_sending(event)
|
82
|
-
configuration.logger.warn(LOGGER_PROGNAME) { "Failed to submit event. Unreported Event: #{Event.get_log_message(event.to_hash)}" }
|
83
|
-
end
|
84
|
-
end
|
85
|
-
end
|
86
|
-
|
87
|
-
require "sentry/transport/dummy_transport"
|
88
|
-
require "sentry/transport/http_transport"
|
@@ -1,21 +0,0 @@
|
|
1
|
-
module Sentry
|
2
|
-
class Transport
|
3
|
-
class Configuration
|
4
|
-
attr_accessor :timeout, :open_timeout, :proxy, :ssl, :ssl_ca_file, :ssl_verification, :http_adapter, :faraday_builder, :transport_class
|
5
|
-
|
6
|
-
def initialize
|
7
|
-
@ssl_verification = true
|
8
|
-
@open_timeout = 1
|
9
|
-
@timeout = 2
|
10
|
-
end
|
11
|
-
|
12
|
-
def transport_class=(klass)
|
13
|
-
unless klass.is_a?(Class)
|
14
|
-
raise Sentry::Error.new("config.transport.transport_class must a class. got: #{klass.class}")
|
15
|
-
end
|
16
|
-
|
17
|
-
@transport_class = klass
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
@@ -1,62 +0,0 @@
|
|
1
|
-
require 'faraday'
|
2
|
-
|
3
|
-
module Sentry
|
4
|
-
class HTTPTransport < Transport
|
5
|
-
CONTENT_TYPE = 'application/json'
|
6
|
-
attr_reader :conn, :adapter
|
7
|
-
|
8
|
-
def initialize(*args)
|
9
|
-
super
|
10
|
-
@adapter = @transport_configuration.http_adapter || Faraday.default_adapter
|
11
|
-
@conn = set_conn
|
12
|
-
@endpoint = @dsn.envelope_endpoint
|
13
|
-
end
|
14
|
-
|
15
|
-
def send_data(data)
|
16
|
-
conn.post @endpoint do |req|
|
17
|
-
req.headers['Content-Type'] = CONTENT_TYPE
|
18
|
-
req.headers['X-Sentry-Auth'] = generate_auth_header
|
19
|
-
req.body = data
|
20
|
-
end
|
21
|
-
rescue Faraday::Error => e
|
22
|
-
error_info = e.message
|
23
|
-
|
24
|
-
if e.response
|
25
|
-
error_info += "\nbody: #{e.response[:body]}"
|
26
|
-
error_info += " Error in headers is: #{e.response[:headers]['x-sentry-error']}" if e.response[:headers]['x-sentry-error']
|
27
|
-
end
|
28
|
-
|
29
|
-
raise Sentry::Error, error_info
|
30
|
-
end
|
31
|
-
|
32
|
-
private
|
33
|
-
|
34
|
-
def set_conn
|
35
|
-
server = @dsn.server
|
36
|
-
|
37
|
-
configuration.logger.debug(LOGGER_PROGNAME) { "Sentry HTTP Transport connecting to #{server}" }
|
38
|
-
|
39
|
-
Faraday.new(server, :ssl => ssl_configuration, :proxy => @transport_configuration.proxy) do |builder|
|
40
|
-
@transport_configuration.faraday_builder&.call(builder)
|
41
|
-
builder.response :raise_error
|
42
|
-
builder.options.merge! faraday_opts
|
43
|
-
builder.headers[:user_agent] = "sentry-ruby/#{Sentry::VERSION}"
|
44
|
-
builder.adapter(*adapter)
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
# TODO: deprecate and replace where possible w/Faraday Builder
|
49
|
-
def faraday_opts
|
50
|
-
[:timeout, :open_timeout].each_with_object({}) do |opt, memo|
|
51
|
-
memo[opt] = @transport_configuration.public_send(opt) if @transport_configuration.public_send(opt)
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
def ssl_configuration
|
56
|
-
(@transport_configuration.ssl || {}).merge(
|
57
|
-
:verify => @transport_configuration.ssl_verification,
|
58
|
-
:ca_file => @transport_configuration.ssl_ca_file
|
59
|
-
)
|
60
|
-
end
|
61
|
-
end
|
62
|
-
end
|
@@ -1,11 +0,0 @@
|
|
1
|
-
module Sentry
|
2
|
-
module ArgumentCheckingHelper
|
3
|
-
private
|
4
|
-
|
5
|
-
def check_argument_type!(argument, expected_type)
|
6
|
-
unless argument.is_a?(expected_type)
|
7
|
-
raise ArgumentError, "expect the argument to be a #{expected_type}, got #{argument.class} (#{argument.inspect})"
|
8
|
-
end
|
9
|
-
end
|
10
|
-
end
|
11
|
-
end
|
@@ -1,20 +0,0 @@
|
|
1
|
-
module Sentry
|
2
|
-
module Utils
|
3
|
-
module ExceptionCauseChain
|
4
|
-
def self.exception_to_array(exception)
|
5
|
-
if exception.respond_to?(:cause) && exception.cause
|
6
|
-
exceptions = [exception]
|
7
|
-
while exception.cause
|
8
|
-
exception = exception.cause
|
9
|
-
break if exceptions.any? { |e| e.object_id == exception.object_id }
|
10
|
-
|
11
|
-
exceptions << exception
|
12
|
-
end
|
13
|
-
exceptions
|
14
|
-
else
|
15
|
-
[exception]
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
data/lib/sentry/utils/real_ip.rb
DELETED
@@ -1,70 +0,0 @@
|
|
1
|
-
require 'ipaddr'
|
2
|
-
|
3
|
-
# Based on ActionDispatch::RemoteIp. All security-related precautions from that
|
4
|
-
# middleware have been removed, because the Event IP just needs to be accurate,
|
5
|
-
# and spoofing an IP here only makes data inaccurate, not insecure. Don't re-use
|
6
|
-
# this module if you have to *trust* the IP address.
|
7
|
-
module Sentry
|
8
|
-
module Utils
|
9
|
-
class RealIp
|
10
|
-
LOCAL_ADDRESSES = [
|
11
|
-
"127.0.0.1", # localhost IPv4
|
12
|
-
"::1", # localhost IPv6
|
13
|
-
"fc00::/7", # private IPv6 range fc00::/7
|
14
|
-
"10.0.0.0/8", # private IPv4 range 10.x.x.x
|
15
|
-
"172.16.0.0/12", # private IPv4 range 172.16.0.0 .. 172.31.255.255
|
16
|
-
"192.168.0.0/16" # private IPv4 range 192.168.x.x
|
17
|
-
].map { |proxy| IPAddr.new(proxy) }
|
18
|
-
|
19
|
-
attr_reader :ip
|
20
|
-
|
21
|
-
def initialize(
|
22
|
-
remote_addr: nil,
|
23
|
-
client_ip: nil,
|
24
|
-
real_ip: nil,
|
25
|
-
forwarded_for: nil
|
26
|
-
)
|
27
|
-
@remote_addr = remote_addr
|
28
|
-
@client_ip = client_ip
|
29
|
-
@real_ip = real_ip
|
30
|
-
@forwarded_for = forwarded_for
|
31
|
-
end
|
32
|
-
|
33
|
-
def calculate_ip
|
34
|
-
# CGI environment variable set by Rack
|
35
|
-
remote_addr = ips_from(@remote_addr).last
|
36
|
-
|
37
|
-
# Could be a CSV list and/or repeated headers that were concatenated.
|
38
|
-
client_ips = ips_from(@client_ip)
|
39
|
-
real_ips = ips_from(@real_ip)
|
40
|
-
forwarded_ips = ips_from(@forwarded_for)
|
41
|
-
|
42
|
-
ips = [client_ips, real_ips, forwarded_ips, remote_addr].flatten.compact
|
43
|
-
|
44
|
-
# If every single IP option is in the trusted list, just return REMOTE_ADDR
|
45
|
-
@ip = filter_local_addresses(ips).first || remote_addr
|
46
|
-
end
|
47
|
-
|
48
|
-
protected
|
49
|
-
|
50
|
-
def ips_from(header)
|
51
|
-
# Split the comma-separated list into an array of strings
|
52
|
-
ips = header ? header.strip.split(/[,\s]+/) : []
|
53
|
-
ips.select do |ip|
|
54
|
-
begin
|
55
|
-
# Only return IPs that are valid according to the IPAddr#new method
|
56
|
-
range = IPAddr.new(ip).to_range
|
57
|
-
# we want to make sure nobody is sneaking a netmask in
|
58
|
-
range.begin == range.end
|
59
|
-
rescue ArgumentError
|
60
|
-
nil
|
61
|
-
end
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
|
-
def filter_local_addresses(ips)
|
66
|
-
ips.reject { |ip| LOCAL_ADDRESSES.any? { |proxy| proxy === ip } }
|
67
|
-
end
|
68
|
-
end
|
69
|
-
end
|
70
|
-
end
|
@@ -1,16 +0,0 @@
|
|
1
|
-
module Sentry
|
2
|
-
module Utils
|
3
|
-
module RequestId
|
4
|
-
REQUEST_ID_HEADERS = %w(action_dispatch.request_id HTTP_X_REQUEST_ID).freeze
|
5
|
-
|
6
|
-
# Request ID based on ActionDispatch::RequestId
|
7
|
-
def self.read_from(env)
|
8
|
-
REQUEST_ID_HEADERS.each do |key|
|
9
|
-
request_id = env[key]
|
10
|
-
return request_id if request_id
|
11
|
-
end
|
12
|
-
nil
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
data/lib/sentry/version.rb
DELETED
data/sentry-ruby.gemspec
DELETED
@@ -1,27 +0,0 @@
|
|
1
|
-
require_relative "lib/sentry/version"
|
2
|
-
|
3
|
-
Gem::Specification.new do |spec|
|
4
|
-
spec.name = "sentry-ruby"
|
5
|
-
spec.version = Sentry::VERSION
|
6
|
-
spec.authors = ["Sentry Team"]
|
7
|
-
spec.description = spec.summary = "A gem that provides a client interface for the Sentry error logger"
|
8
|
-
spec.email = "accounts@sentry.io"
|
9
|
-
spec.license = 'Apache-2.0'
|
10
|
-
spec.homepage = "https://github.com/getsentry/raven-ruby"
|
11
|
-
|
12
|
-
spec.platform = Gem::Platform::RUBY
|
13
|
-
spec.required_ruby_version = '>= 2.4'
|
14
|
-
spec.extra_rdoc_files = ["README.md", "LICENSE.txt"]
|
15
|
-
spec.files = `git ls-files | grep -Ev '^(spec|benchmarks|examples)'`.split("\n")
|
16
|
-
|
17
|
-
spec.metadata["homepage_uri"] = spec.homepage
|
18
|
-
spec.metadata["source_code_uri"] = spec.homepage
|
19
|
-
spec.metadata["changelog_uri"] = "#{spec.homepage}/blob/master/CHANGELOG.md"
|
20
|
-
|
21
|
-
spec.bindir = "exe"
|
22
|
-
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
23
|
-
spec.require_paths = ["lib"]
|
24
|
-
|
25
|
-
spec.add_dependency "faraday", ">= 1.0"
|
26
|
-
spec.add_dependency "concurrent-ruby", '~> 1.0', '>= 1.0.2'
|
27
|
-
end
|