Skip to content

Commit

Permalink
Deprecate enable_tracing in favor of traces_sample_rate (#2535)
Browse files Browse the repository at this point in the history
  • Loading branch information
sl0thentr0py authored Feb 6, 2025
1 parent 1111acb commit cfd5059
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 6 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## Unreleased

### Miscellaneous

- Deprecate `enable_tracing` in favor of `traces_sample_rate = 1.0` [#2535](https://github.com/getsentry/sentry-ruby/pull/2535)

## 5.22.4

### Bug Fixes
Expand Down
2 changes: 1 addition & 1 deletion sentry-rails/lib/generators/sentry_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def copy_initializer_file
Sentry.init do |config|
config.breadcrumbs_logger = [:active_support_logger]
config.dsn = #{dsn}
config.enable_tracing = true
config.traces_sample_rate = 1.0
end
RUBY
end
Expand Down
4 changes: 2 additions & 2 deletions sentry-rails/spec/sentry/generator_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
Sentry.init do |config|
config.breadcrumbs_logger = [:active_support_logger]
config.dsn = ENV['SENTRY_DSN']
config.enable_tracing = true
config.traces_sample_rate = 1.0
end
RUBY
end
Expand Down Expand Up @@ -87,7 +87,7 @@
Sentry.init do |config|
config.breadcrumbs_logger = [:active_support_logger]
config.dsn = 'foobarbaz'
config.enable_tracing = true
config.traces_sample_rate = 1.0
end
RUBY
end
Expand Down
7 changes: 7 additions & 0 deletions sentry-ruby/lib/sentry/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,7 @@ def capture_exception_frame_locals=(value)

# Easier way to use performance tracing
# If set to true, will set traces_sample_rate to 1.0
# @deprecated It will be removed in the next major release.
# @return [Boolean, nil]
attr_reader :enable_tracing

Expand Down Expand Up @@ -542,6 +543,12 @@ def instrumenter=(instrumenter)
end

def enable_tracing=(enable_tracing)
unless enable_tracing.nil?
log_warn <<~MSG
`enable_tracing` is now deprecated in favor of `traces_sample_rate = 1.0`.
MSG
end

@enable_tracing = enable_tracing
@traces_sample_rate ||= 1.0 if enable_tracing
end
Expand Down
11 changes: 11 additions & 0 deletions sentry-ruby/spec/sentry/configuration_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,17 @@

expect(subject.tracing_enabled?).to eq(false)
end

it "prints deprecation message when being assigned" do
string_io = StringIO.new
subject.logger = Logger.new(string_io)

subject.enable_tracing = true

expect(string_io.string).to include(
"WARN -- sentry: `enable_tracing` is now deprecated in favor of `traces_sample_rate = 1.0`."
)
end
end
end

Expand Down
4 changes: 2 additions & 2 deletions sentry-ruby/spec/sentry/metrics/aggregator_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
before do
perform_basic_setup do |config|
config.metrics.enabled = true
config.enable_tracing = true
config.traces_sample_rate = 1.0
config.release = 'test-release'
config.environment = 'test'
config.logger = Logger.new(string_io)
Expand Down Expand Up @@ -194,7 +194,7 @@
before do
perform_basic_setup do |config|
config.metrics.enabled = true
config.enable_tracing = true
config.traces_sample_rate = 1.0
config.release = 'test-release'
config.environment = 'test'
config.logger = Logger.new(string_io)
Expand Down
2 changes: 1 addition & 1 deletion sentry-ruby/spec/sentry/metrics_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@

before do
perform_basic_setup do |config|
config.enable_tracing = true
config.traces_sample_rate = 1.0
config.metrics.enabled = true
end

Expand Down

0 comments on commit cfd5059

Please sign in to comment.