Releases: getsentry/sentry-ruby
5.4.0
Features
-
Expose
:values
inExceptionInterface
, so that it can be accessed inbefore_send
underevent.exception.values
#1843 -
Add top level
Sentry.close
API #1844- Cleans up SDK state and sets it to uninitialized
- No-ops all SDK APIs and also disables the transport layer, so nothing will be sent to Sentry after closing the SDK
-
Handle exception with large stacktrace without dropping entire item #1807
-
Capture Rails runner's exceptions before exiting #1820
-
Add
Sentry.with_exception_captured
helper #1814Usage:
Sentry.with_exception_captured do 1/1 #=> 1 will be returned end Sentry.with_exception_captured do 1/0 #=> ZeroDivisionError will be reported and re-raised end
-
Prepare for Rails 7.1's error reporter API change #1834
-
Set
sentry.error_event_id
in request env if the middleware captures errors #1849If the SDK's Rack middleware captures an error, the reported event's id will be stored in the request env. For example:
env["sentry.error_event_id"] #=> "507bd4c1a07e4355bb70bcd7afe8ab17"
Users can display this information on the error page via a middleware as proposed in #1846
Bug Fixes
- Respect
report_rescued_exceptions
config #1847- Fixes #1840
- Rescue event's to JSON conversion error #1853
- Rescue
ThreadError
inSessionFlusher
and stop creating threads if flusher is killed #1851- Fixes #1848
Refactoring
- Move envelope item processing/trimming logic to the Item class #1824
- Replace sentry-ruby-core with sentry-ruby as integration dependency #1825
Test Helpers
The SDK now provides a set of test helpers to help users setup and teardown Sentry related tests.
To get started:
require "sentry/test_helper"
# in minitest
class MyTest < Minitest::Test
include Sentry::TestHelper
# ...
end
# in RSpec
RSpec.configure do |config|
config.include Sentry::TestHelper
# ...
end
It's still an early attempt so please give us feedback in #1680.
5.3.1
5.3.0
Features
- Add
Sentry.with_child_span
for easier span recording #1783
operation_result = Sentry.with_child_span(op: "my op") do |child_span|
my_operation
end
# the "my op" span will be attached to the result of Sentry.get_current_scope.get_span
# which could be either the top-level transaction, or a span set by the user or other integrations
Bug Fixes
- Set
last_event_id
only for error events #1767- Fixes #1766
- Add
config.rails.register_error_subscriber
to control error reporter integration #1771 - Check if ActiveRecord connection exists before calling AR connection pool #1769
- Fixes #1745
- Fix
sentry-rails
's tracing spans not nesting issue - #1784- Fixes #1723
- Update
config.transport.proxy
to allow String and URI values as previously supported bysentry-ruby
versions <= 4.8 using Faraday- Fixes #1782
- Register SentryContextClientMiddleware on sidekiq workers #1774
- Add request env to sampling context when using
sentry-rails
#1792- Fixes #1791
- Fix net-http tracing's span nesting issue #1796
Refactoring
- Correct inaccurate event model relationships #1777
Miscellaneous
- Log message when shutting down/killing SDK managed components #1779
5.2.1
5.2.0
Features
-
Log Redis command arguments when sending PII is enabled #1726
-
Add request env to sampling context #1749
Example
Sentry.init do |config| config.traces_sampler = lambda do |sampling_context| env = sampling_context[:env] if env["REQUEST_METHOD"] == "GET" 0.01 else 0.1 end end end
-
Check envelope size before sending it #1747
The SDK will now check if the envelope's event items are oversized before sending the envelope. It goes like this:
- If an event is oversized (200kb), the SDK will remove its breadcrumbs (which in our experience is the most common cause).
- If the event size now falls within the limit, it'll be sent.
- Otherwise, the event will be thrown away. The SDK will also log a debug message about the event's attributes size (in bytes) breakdown. For example,
{event_id: 34, level: 7, timestamp: 22, environment: 13, server_name: 14, modules: 935, message: 5, user: 2, tags: 2, contexts: 820791, extra: 2, fingerprint: 2, platform: 6, sdk: 40, threads: 51690}
This will help users report size-related issues in the future.
-
Automatic session tracking #1715
Example:
The SDK now supports automatic session tracking / release health by default in Rack based applications.
Aggregate statistics on successful / errored requests are collected and sent to the server every minute.
To use this feature, make sure the SDK can detect your app's release. Or you have set it with:Sentry.init do |config| config.release = 'release-foo-v1' end
To disable this feature, set
config.auto_session_tracking
tofalse
.
Bug Fixes
5.1.1
5.1.0
Features
-
Support for Redis #1697
New breadcrumb logger:
redis_logger
When you opt in to the new
redis_logger
breadcrumbs logger:config.breadcrumbs_logger = [:redis_logger]
The SDK now records a new
db.redis.command
breadcrumb whenever the Redis client is called. Attributes sent are
commands
, an array of each Redis command called with the attributescommand
andkey
, as well asserver
, which is
the Redis server hostname, port and db number.Redis command spans
Calls to Redis are also wrapped in a span called
db.redis.command
and if tracing is enabled will be reported to
Sentry. The span description will be the command and key. e.g. "SET mykey". For transactions this will be in
the formatMULTI, SET mykey, INCR counter, EXEC
. -
Sync activerecord, actionview and net-http span names #1681
-
Support serializing ActiveRecord job arguments in global id form #1688
-
Register Sentry's ErrorSubscriber for Rails 7.0+ apps #1705
Users can now use the unified interfaces:
Rails.error.handle
orRails.error.record
to capture exceptions. See ActiveSupport::ErrorReporter for more information about this feature.
Bug Fixes
5.0.2
5.0.1
5.0.0
Breaking Change - Goodbye faraday
👋
TL;DR: If you are already on version 4.9
and do not use config.transport.http_adapter
and config.transport.faraday_builder
, you don't need to change anything.
This version removes the dependency of faraday and replaces related implementation with the Net::HTTP
standard library.
Why?
Since the old sentry-raven
SDK, we've been using faraday
as the HTTP client for years (see HTTPTransport). It's an amazing tool that saved us many work and allowed us to focus on SDK features.
But because many users also use faraday
themselves and have their own version requirements, managing this dependency has become harder over the past few years. Just to list a few related issues:
And with the release of faraday 2.0, we could only imagine it getting even more difficult (which it kind of did, see #1663).
So we think it's time to say goodbye to it with this release.
What's changed?
By default, the SDK used faraday
's net_http
adapter, which is also built on top of Net::HTTP
. So this change shouldn't impact most of the users.
The only noticeable changes are the removal of 2 faraday-specific transport configurations:
config.transport.http_adapter
config.transport.faraday_builder
If you are already on version 4.9
and do not use those configuration options, it'll be as simple as bundle update
.
What if I still want to use faraday
to send my events?
sentry-ruby
already allows users to set a custom transport class with:
Sentry.init do |config|
config.transport.transport_class = MyTransportClass
end
So to use a faraday-based transport, you can:
- Build a
FaradayTransport
like this:
require 'sentry/transport/http_transport'
require 'faraday'
class FaradayTransport < Sentry::HTTPTransport
attr_reader :adapter
def initialize(*args)
@adapter = :net_http
super
end
def send_data(data)
encoding = ""
if should_compress?(data)
data = Zlib.gzip(data)
encoding = GZIP_ENCODING
end
response = conn.post @endpoint do |req|
req.headers['Content-Type'] = CONTENT_TYPE
req.headers['Content-Encoding'] = encoding
req.headers['X-Sentry-Auth'] = generate_auth_header
req.body = data
end
if has_rate_limited_header?(response.headers)
handle_rate_limited_response(response.headers)
end
rescue Faraday::Error => e
error_info = e.message
if e.response
if e.response[:status] == 429
handle_rate_limited_response(e.response[:headers])
else
error_info += "\nbody: #{e.response[:body]}"
error_info += " Error in headers is: #{e.response[:headers]['x-sentry-error']}" if e.response[:headers]['x-sentry-error']
end
end
raise Sentry::ExternalError, error_info
end
private
def set_conn
server = @dsn.server
log_debug("Sentry HTTP Transport connecting to #{server}")
Faraday.new(server, :ssl => ssl_configuration, :proxy => @transport_configuration.proxy) do |builder|
builder.response :raise_error
builder.options.merge! faraday_opts
builder.headers[:user_agent] = "sentry-ruby/#{Sentry::VERSION}"
builder.adapter(*adapter)
end
end
def faraday_opts
[:timeout, :open_timeout].each_with_object({}) do |opt, memo|
memo[opt] = @transport_configuration.public_send(opt) if @transport_configuration.public_send(opt)
end
end
def ssl_configuration
{
verify: @transport_configuration.ssl_verification,
ca_file: @transport_configuration.ssl_ca_file
}.merge(@transport_configuration.ssl || {})
end
end
- Set
config.transport.transport = FaradayTransport
Please keep in mind that this may not work in the future when the SDK changes its HTTPTransport
implementation.