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

Java.Lang.IllegalArgumentException when setting MaxBreadcrumbs to 0 #3255

Closed
tipa opened this issue Apr 3, 2024 · 8 comments · Fixed by #3267
Closed

Java.Lang.IllegalArgumentException when setting MaxBreadcrumbs to 0 #3255

tipa opened this issue Apr 3, 2024 · 8 comments · Fixed by #3267

Comments

@tipa
Copy link

tipa commented Apr 3, 2024

Package

Sentry

.NET Flavor

.NET

.NET Version

8.0.2

OS

Android

SDK Version

4.2.1

Self-Hosted Sentry Version

No response

Steps to Reproduce

Sentry.SentrySdk.Init(o =>
{
    ....
    o.MaxBreadcrumbs = 0;
}

According to the docs:

This variable controls the total amount of breadcrumbs that should be captured. This defaults to 100, but you can set this to any number.

Expected Result

no crash and collection of breadcrumbs is disabled

Actual Result

java.lang.IllegalArgumentException: The size must be greater than 0
  at io.sentry.CircularFifoQueue.< init > (CircularFifoQueue.java:91)
  at io.sentry.Scope.createBreadcrumbsList(Scope.java:738)
  at io.sentry.Scope.< init > (Scope.java:90)
  at io.sentry.Hub.createRootStackItem(Hub.java:77)
  at io.sentry.Hub.< init > (Hub.java:43)
  at io.sentry.Sentry.init(Sentry.java:238)
  at io.sentry.Sentry.init(Sentry.java:167)
  at io.sentry.android.core.SentryAndroid.init(SentryAndroid.java:87)
@tipa
Copy link
Author

tipa commented Apr 3, 2024

Is there any other way to disable breadcrumbs completely? What I also tried:

  • Disable the breadcrumbs programmatically, like options.Native.EnableActivityLifecycleBreadcrumbs = false. However, the property to disable network events (io.sentry.breadcrumbs.network-events) is not present
  • Specify the options as meta-data tags in the AndroidManifest.xml (as documented here). However, io.sentry.auto-init is set to false by default and cannot be overwritten

@jamescrosswell
Copy link
Collaborator

jamescrosswell commented Apr 3, 2024

Hi @tipa ,

You could use the SetBeforeBreadcrumb callback. Returning null from that callback will discard the breadcrumb.

btw: I raised this with the sentry-java team as I think the issue you raised with MaxBreadcrumbs needs to be fixed in that repository.

@tipa
Copy link
Author

tipa commented Apr 4, 2024

Thanks. I thought of that workaround as well. But this would still come with the overhead at runtime of the Sentry SDK setting up all the integrations & handlers.
What is the "correct" way to disable all breadcrumbs? Settings the MaxBreadcrumbs to 0? Specifying the SetBeforeBreadcrumb callback? Manually remove the Integration?

At the moment, I don't see a way to specifically disable the NetworkBreadcrumbsIntegration in the .NET SDK.
Even when discarding the breadcrumb with the SetBeforeBreadcrumb handler, there is some overhead of registering the callback here. Is the .NET SDK missing a binding here?

@jamescrosswell
Copy link
Collaborator

Is the .NET SDK missing a binding here?

If it's just that setting you're after, this exists in the NativeOptions on the .NET SDK as well.

@tipa
Copy link
Author

tipa commented Apr 8, 2024

But does that disable all breadcrumbs?
There are different properties for different types of breadcrumbs (EnableActivityLifecycleBreadcrumbs, EnableAppComponentBreadcrumbs, ...) but the one for network events seems to be missing in the .NET bindings

@jamescrosswell
Copy link
Collaborator

There are different properties for different types of breadcrumbs (EnableActivityLifecycleBreadcrumbs, EnableAppComponentBreadcrumbs, ...) but the one for network events seems to be missing in the .NET bindings

You're quite right @tipa... my mistake. Kicked off #3267 to address.

@bitsandfoxes
Copy link
Contributor

bitsandfoxes commented Apr 8, 2024

Oddly enough, there seem to be a couple of options missing. I.e. the networking one and specifically for your ask: There is a enableAllAutoBreadcrumbs that should take care of.. all.. of them.

@jamescrosswell
Copy link
Collaborator

Oddly enough, there seem to be a couple of options missing. The networking one.
And specifically for your ask There is a enableAllAutoBreadcrumbs that should take care of.. all.. of them.

May as well do that in the same PR eh?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants