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

Allow disabling tracing through SentryOptions. #1337

Merged
merged 5 commits into from
Mar 24, 2021

Conversation

maciejwalkowiak
Copy link
Contributor

@maciejwalkowiak maciejwalkowiak commented Mar 19, 2021

📜 Description

Allow disabling tracing through SentryOptions. When both tracesSampleRate = null and tracesSampler = null tracing is disabled.

Since this behavior is in place, sentry.enable-tracing property in Spring Boot integration is not needed anymore and it gets deprecated.

💡 Motivation and Context

According to specs, users can disable tracing by setting both tracesSampleRate to null and tracesSampler to null.

💚 How did you test it?

Unit tests.

📝 Checklist

  • I reviewed the submitted code
  • I added tests to verify the changes
  • I updated the docs if needed
  • No breaking changes

Breaking change: for users who have set null on both tracesSampleRate and tracesSampler - transactions with explicit sampling decision and transactions with inherited sampling decision will not be send to Sentry anymore. To bring back the old behaviour users would have to set tracesSampleRate to 0.0.

When both tracesSampleRate = null and tracesSampler = null tracing is disabled.
Comment on lines +106 to +108
if (options.getTracesSampleRate() == null) {
options.setTracesSampleRate(0.0);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we need that here? isn't users choice to set it up?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Spring has already a property "enable-tracing" which triggers auto configuration. If we don't do this change, users would have to set both enable-tracing=true and traces-sample-rate=0.0 to enable integration.

Copy link
Contributor

@marandaneto marandaneto Mar 19, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but that's what is described here right https://docs.sentry.io/platforms/java/guides/spring-boot/performance/#enable-tracing
if it's a matter of not doing multiple things, I'd say that removing enable-tracing would be the way to go instead.
this is actually the only integration that requires more setup than traces-sample-rate or the traces callback

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can do it but it will be breaking. Probably better to do it in another PR and leave this one as it is?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wfm

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As decided on Friday, I'll deprecate enable-tracing and make traces-sample-rate turn on integration too.

Copy link
Contributor

@marandaneto marandaneto Mar 22, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@maciejwalkowiak do we need docs for this? getsentry/sentry-docs#3289

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, I'll prepare a PR

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

after deprecating enable-tracing, we should remove this right now, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think so. This keeps the old behavior - users only need to set enable-tracing=true to get tracing working. If we remove it, it is a breaking change.

@maciejwalkowiak
Copy link
Contributor Author

@marandaneto please have another look

@codecov-io
Copy link

Codecov Report

Merging #1337 (42037f8) into main (e9a865b) will increase coverage by 0.02%.
The diff coverage is 90.00%.

❗ Current head 42037f8 differs from pull request most recent head 6dd6dd3. Consider uploading reports for the commit 6dd6dd3 to get more accurate results
Impacted file tree graph

@@             Coverage Diff              @@
##               main    #1337      +/-   ##
============================================
+ Coverage     75.64%   75.67%   +0.02%     
- Complexity     1845     1848       +3     
============================================
  Files           185      185              
  Lines          6320     6330      +10     
  Branches        627      629       +2     
============================================
+ Hits           4781     4790       +9     
  Misses         1254     1254              
- Partials        285      286       +1     
Impacted Files Coverage Δ Complexity Δ
...n/java/io/sentry/spring/boot/SentryProperties.java 81.48% <ø> (ø) 8.00 <0.00> (ø)
sentry/src/main/java/io/sentry/SentryOptions.java 86.00% <0.00%> (-0.29%) 129.00 <2.00> (+2.00) ⬇️
...io/sentry/spring/boot/SentryAutoConfiguration.java 97.95% <100.00%> (+0.18%) 1.00 <0.00> (ø)
sentry/src/main/java/io/sentry/Hub.java 74.27% <100.00%> (+0.37%) 76.00 <0.00> (+1.00)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e9a865b...6dd6dd3. Read the comment docs.

Copy link
Contributor

@marandaneto marandaneto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@marandaneto
Copy link
Contributor

@maciejwalkowiak a conflict to be fixed and GG

@maciejwalkowiak maciejwalkowiak merged commit bc99848 into main Mar 24, 2021
@maciejwalkowiak maciejwalkowiak deleted the allow-disabling-tracing branch March 24, 2021 11:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants