Skip to content

feat(ndk): add traces_sample_rate synchronization #1176

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

Merged
merged 17 commits into from
Mar 28, 2025

Conversation

JoshuaMoelans
Copy link
Member

@JoshuaMoelans JoshuaMoelans commented Mar 12, 2025

Fixes #1167

  • add option
  • write test(s) for the NDK <- done in this PR add NDK testing setup #1180
  • add to docs (on the Android side)
  • add to changelog
  • bump native + open up PR on sentry-Java (e.g. updating options in sentryNDK.java)
    -> also have an integration test to make sure sending transactions works.

Since the NDK has no transport, we expect the Android side to pick up any envelopes (see this comment)

Copy link

github-actions bot commented Mar 12, 2025

Fails
🚫 Please consider adding a changelog entry for the next release.
Messages
📖 Do not forget to update Sentry-docs with your feature once the pull request gets approved.

Instructions and example for changelog

Please add an entry to CHANGELOG.md to the "Unreleased" section. Make sure the entry includes this PR's number.

Example:

## Unreleased

- add `traces_sample_rate` synchronization ([#1176](https://github.com/getsentry/sentry-native/pull/1176))

If none of the above apply, you can opt out of this check by adding #skip-changelog to the PR description.

Generated by 🚫 dangerJS against 031e949

@@ -22,4 +22,29 @@ JNIEXPORT void JNICALL Java_io_sentry_ndk_sample_NdkSample_message(JNIEnv *env,
sentry_capture_event(event);
}

JNIEXPORT void JNICALL Java_io_sentry_ndk_sample_NdkSample_transaction(JNIEnv *env, jclass cls) {
Copy link
Member Author

@JoshuaMoelans JoshuaMoelans Mar 12, 2025

Choose a reason for hiding this comment

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

Since the NDK has no transport, we can't really test this just by looking at Sentry dashboards/intercepting HTTP. A way to check if the envelope is created properly, is by looking at data/data/io.sentry.ndk.sample/files/outbox on the emulated device's storage.

This envelope-check is probably how we want to this test on the native repo (and then have a integration test similar to this one from native on the java-SDK side)

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yeah, this is fine. The outbox is the primary interface back to sentry-android and, as such, the ideal test boundary. Adding additional machinery beyond parsing the output won't provide better feedback.

@JoshuaMoelans JoshuaMoelans marked this pull request as ready for review March 24, 2025 15:15
@JoshuaMoelans
Copy link
Member Author

back to draft, forgot to change the new variable to getter-setter only (it should not be part of constructor)

@JoshuaMoelans JoshuaMoelans marked this pull request as draft March 24, 2025 15:24
@JoshuaMoelans JoshuaMoelans marked this pull request as ready for review March 25, 2025 11:39
@JoshuaMoelans
Copy link
Member Author

I'm not sure if there is a proper place to add this feature to the native docs, or if it makes more sense to only add it to the Android docs once we implement the feature to pass through the tracesSampleRate over there.

@supervacuus
Copy link
Collaborator

I'm not sure if there is a proper place to add this feature to the native docs, or if it makes more sense to only add it to the Android docs once we implement the feature to pass through the tracesSampleRate over there.

Currently, this doesn't require much documentation. The ask is primarily for sentry-native to honor the setting from the sentry-android layer. Most people would expect it just to work, and it only pops up because it doesn't. Of course, the core question remains: Do we think it should work?

So, the getter/setter doesn't require attention from the docs. What should be documented, and probably on the Android side (but not necessarily by their team alone), is how transactions should work if enabled on both layers. This PR doesn't answer this since it only opens the pass-through down and back up (which is fine, but as such, it can't provide any clarifying insights either).

JoshuaMoelans and others added 8 commits March 25, 2025 17:20
* Add dependencies to allow running unit tests as well as instrumented android tests

* add ndk test into CI

* moved NDK check+test into `test` job

* add conditional check for ANDROID_API in NDK test/check jobs

* trying to fix CI

* trying to fix CI 2

* Add Java/Gradle setup steps

* Apply checks to NDK lib only

* Apply code formatting

* run tests on reactivecircus emulator

* remove KVM enable step

* update CI (remove NDK test)

---------

Co-authored-by: Markus Hintersteiner <[email protected]>
@JoshuaMoelans JoshuaMoelans force-pushed the joshua/feat/sync_android_tracessamplerate branch from 9bf3c1a to f2cf32d Compare March 25, 2025 16:32
Copy link
Member

@markushi markushi left a comment

Choose a reason for hiding this comment

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

Looking good, nice! I left a few minor/medium comments, just ping me as soon as I should take a second look 🚀

@JoshuaMoelans JoshuaMoelans requested a review from markushi March 27, 2025 14:57
Copy link
Member

@markushi markushi left a comment

Choose a reason for hiding this comment

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

LGTM!

@JoshuaMoelans JoshuaMoelans merged commit 20d5d5f into master Mar 28, 2025
30 checks passed
@JoshuaMoelans JoshuaMoelans deleted the joshua/feat/sync_android_tracessamplerate branch March 28, 2025 10:10
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.

Unable to use the Native SDK to set up Sentry Tracing custom instrumentation for Android
3 participants