Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate enable_tracing in favor of traces_sample_rate #2535

Merged
merged 1 commit into from
Feb 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@

# 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 @@
end

def enable_tracing=(enable_tracing)
unless enable_tracing.nil?
log_warn <<~MSG

Check warning on line 547 in sentry-ruby/lib/sentry/configuration.rb

View check run for this annotation

Codecov / codecov/patch

sentry-ruby/lib/sentry/configuration.rb#L547

Added line #L547 was not covered by tests
`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
Loading