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

sample-rate configuration from Manifest does not work #803

Open
cmorigaki opened this issue Dec 23, 2024 · 1 comment · May be fixed by getsentry/sentry-java#4031
Open

sample-rate configuration from Manifest does not work #803

cmorigaki opened this issue Dec 23, 2024 · 1 comment · May be fixed by getsentry/sentry-java#4031
Assignees
Labels
bug Something isn't working Platform: Android

Comments

@cmorigaki
Copy link

Gradle Version

8.11.1

AGP Version

8.7.3

Code Minifier/Optimizer

None

Version

4.14.1

Sentry SDK Version

7.18.0

Steps to Reproduce

Use the Sentry auto-init feature:

  1. Apply sentry gradle plugin 4.14.1
  2. Set the sample-rate in the AndroidManifest.xml: <meta-data android:name="io.sentry.traces.sample-rate" android:value="1.0" />
  3. Run the appplication in debug
  4. Check Logcat filtering for "Sentry" word

The issue started from 4.14.0. The version 4.13.0 is working as expected. This PR is probably the cause of the issue.

Expected Result

Successfully init the App with the Sentry configuration. The logcat will show only io.sentry.auto-init read: true when filtering for "Sentry" word.

Actual Result

The Logcat shows io.sentry.auto-init read: true and then warning messages related to the manifest configuration of float values:

Key io.sentry.traces.sample-rate expected Integer but value was a java.lang.Float.  The default value -1 was returned.
Attempt to cast generated internal exception:
java.lang.ClassCastException: java.lang.Float cannot be cast to java.lang.Integer
    at android.os.BaseBundle.getInt(BaseBundle.java:1050)
    at io.sentry.android.core.ManifestMetadataReader.readDouble(ManifestMetadataReader.java:500)
    at io.sentry.android.core.ManifestMetadataReader.applyMetadata(ManifestMetadataReader.java:294)
    at io.sentry.android.core.AndroidOptionsInitializer.loadDefaultAndMetadataOptions(AndroidOptionsInitializer.java:109)
    at io.sentry.android.core.SentryAndroid.lambda$init$1(SentryAndroid.java:116)
    at io.sentry.android.core.SentryAndroid$$ExternalSyntheticLambda0.configure(D8$$SyntheticClass:0)
    at io.sentry.Sentry.applyOptionsConfiguration(Sentry.java:196)
    at io.sentry.Sentry.init(Sentry.java:166)
    at io.sentry.android.core.SentryAndroid.init(SentryAndroid.java:93)
    at io.sentry.android.core.SentryAndroid.init(SentryAndroid.java:64)
    at io.sentry.android.core.SentryInitProvider.onCreate(SentryInitProvider.java:25)
    at android.content.ContentProvider.attachInfo(ContentProvider.java:2117)
    at android.content.ContentProvider.attachInfo(ContentProvider.java:2091)
    at io.sentry.android.core.SentryInitProvider.attachInfo(SentryInitProvider.java:43)
    at android.app.ActivityThread.installProvider(ActivityThread.java:7187)
    at android.app.ActivityThread.installContentProviders(ActivityThread.java:6670)
    at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6565)
    at android.app.ActivityThread.access$1400(ActivityThread.java:224)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1887)
    at android.os.Handler.dispatchMessage(Handler.java:107)
    at android.os.Looper.loop(Looper.java:224)
    at android.app.ActivityThread.main(ActivityThread.java:7560)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:539)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:950)
@stefanosiano
Copy link
Member

hi @cmorigaki, thanks for the feedback!
that shouldn't be a problem.
Right after that log there should be the line with the correct value, like io.sentry.traces.sample-rate read: 1.0
I agree we should improve the logcat so that it doesn't show the error in case a float is provided.

Are you having other issues, other than the log?

@getsantry getsantry bot removed the status in GitHub Issues with 👀 3 Jan 7, 2025
@stefanosiano stefanosiano moved this from Needs Discussion to In Progress in Mobile & Cross Platform SDK Jan 8, 2025
@stefanosiano stefanosiano self-assigned this Jan 8, 2025
@stefanosiano stefanosiano moved this from In Progress to Todo in Mobile & Cross Platform SDK Jan 8, 2025
@stefanosiano stefanosiano moved this from Todo to Needs Review in Mobile & Cross Platform SDK Jan 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Platform: Android
Projects
Status: No status
Status: Needs Review
Development

Successfully merging a pull request may close this issue.

2 participants