-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
feat(java, android): Add Spotlight integration docs #16323
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
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,79 @@ | ||
| --- | ||
| title: Spotlight | ||
| description: "Learn how to use Sentry Spotlight for local development observability on Android." | ||
| --- | ||
|
|
||
| [Sentry Spotlight](https://spotlightjs.com/) is a local development tool that provides real-time observability for errors, traces, logs, and performance data during development. It allows you to see Sentry events in real-time without sending them to Sentry's servers, making it ideal for local debugging. | ||
|
|
||
| The `sentry-spotlight` module provides a `SpotlightIntegration` that sends a copy of all Sentry events to your local Spotlight instance. By using `debugImplementation`, you can ensure Spotlight is excluded from release builds, preventing insecure HTTP URLs from leaking into production APKs. | ||
|
|
||
| ## Install | ||
|
|
||
| We recommend using `debugImplementation` so the Spotlight dependency is excluded from release builds: | ||
|
|
||
| ```groovy {filename:app/build.gradle} | ||
| debugImplementation 'io.sentry:sentry-spotlight:{{@inject packages.version('sentry.java.spotlight', '8.32.0') }}' | ||
| ``` | ||
|
|
||
| ```kotlin {filename:app/build.gradle.kts} | ||
| debugImplementation("io.sentry:sentry-spotlight:{{@inject packages.version('sentry.java.spotlight', '8.32.0') }}") | ||
| ``` | ||
|
|
||
| If you need Spotlight in all build types, use `implementation` instead of `debugImplementation`. | ||
|
|
||
| ## Configure | ||
|
|
||
| ```xml {tabTitle:XML} | ||
| <application> | ||
| <!-- Enable Spotlight --> | ||
| <meta-data android:name="io.sentry.spotlight.enable" android:value="true" /> | ||
| <!-- Optional: override the default Spotlight URL --> | ||
| <meta-data android:name="io.sentry.spotlight.url" android:value="http://10.0.2.2:8969/stream" /> | ||
| </application> | ||
| ``` | ||
|
|
||
| ```java {tabTitle:Java} | ||
| import io.sentry.android.core.SentryAndroid; | ||
|
|
||
| SentryAndroid.init(this, options -> { | ||
| options.setDsn("___PUBLIC_DSN___"); | ||
| options.setEnableSpotlight(true); | ||
| // Optional: override the default Spotlight URL | ||
| options.setSpotlightConnectionUrl("http://10.0.2.2:8969/stream"); | ||
| }); | ||
| ``` | ||
|
|
||
| ```kotlin {tabTitle:Kotlin} | ||
| import io.sentry.android.core.SentryAndroid | ||
|
|
||
| SentryAndroid.init(this) { options -> | ||
| options.dsn = "___PUBLIC_DSN___" | ||
| options.isEnableSpotlight = true | ||
| // Optional: override the default Spotlight URL | ||
| options.spotlightConnectionUrl = "http://10.0.2.2:8969/stream" | ||
| } | ||
| ``` | ||
|
|
||
| <Alert level="info"> | ||
|
|
||
| The default Spotlight URL is `http://10.0.2.2:8969/stream`. The `10.0.2.2` address is the Android emulator's bridge to the host machine's `localhost`. If you're running on a physical device, replace this with your machine's local IP address. | ||
|
|
||
| </Alert> | ||
|
|
||
| ## Verify | ||
|
|
||
| To verify the integration is working, capture a test exception and check the Spotlight UI: | ||
|
|
||
| ```java | ||
| import io.sentry.Sentry; | ||
|
|
||
| Sentry.captureException(new Exception("Spotlight test from Android!")); | ||
| ``` | ||
|
|
||
| ```kotlin | ||
| import io.sentry.Sentry | ||
|
|
||
| Sentry.captureException(Exception("Spotlight test from Android!")) | ||
| ``` | ||
|
|
||
| Open the Spotlight UI and confirm that the error event appears. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,98 @@ | ||
| --- | ||
| title: Spotlight | ||
| description: "Learn how to use Sentry Spotlight for local development observability in your Java app." | ||
| --- | ||
|
|
||
| [Sentry Spotlight](https://spotlightjs.com/) is a local development tool that provides real-time observability for errors, traces, logs, and performance data during development. It allows you to see Sentry events in real-time without sending them to Sentry's servers, making it ideal for local debugging. | ||
|
|
||
| The `sentry-spotlight` module provides a `SpotlightIntegration` that sends a copy of all Sentry events to your local Spotlight instance. | ||
|
|
||
| ## Install | ||
|
|
||
| To install use: | ||
|
|
||
| ```groovy {tabTitle:Gradle} | ||
| implementation 'io.sentry:sentry-spotlight:{{@inject packages.version('sentry.java.spotlight', '8.32.0') }}' | ||
| ``` | ||
|
|
||
| ```xml {tabTitle:Maven} | ||
| <dependency> | ||
| <groupId>io.sentry</groupId> | ||
| <artifactId>sentry-spotlight</artifactId> | ||
| <version>{{@inject packages.version('sentry.java.spotlight', '8.32.0') }}</version> | ||
| </dependency> | ||
| ``` | ||
|
|
||
| ```scala {tabTitle: SBT} | ||
| libraryDependencies += "io.sentry" % "sentry-spotlight" % "{{@inject packages.version('sentry.java.spotlight', '8.32.0') }}" | ||
| ``` | ||
|
|
||
| For other dependency managers, check out the [central Maven repository](https://search.maven.org/artifact/io.sentry/sentry-spotlight). | ||
|
|
||
| ## Configure | ||
|
|
||
| <PlatformSection supported={["java.spring-boot"]}> | ||
|
|
||
| ```text {tabTitle:Properties} {filename:application.properties} | ||
sentry[bot] marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| sentry.enable-spotlight=true | ||
| # Optional: override the default Spotlight URL (defaults to http://localhost:8969/stream) | ||
| sentry.spotlight-connection-url=http://localhost:8969/stream | ||
| ``` | ||
|
|
||
| </PlatformSection> | ||
|
|
||
| <PlatformSection notSupported={["java.spring-boot"]}> | ||
|
|
||
| ```text {tabTitle:Properties} {filename:sentry.properties} | ||
| enable-spotlight=true | ||
| # Optional: override the default Spotlight URL (defaults to http://localhost:8969/stream) | ||
| spotlight-connection-url=http://localhost:8969/stream | ||
| ``` | ||
|
|
||
| </PlatformSection> | ||
|
|
||
| ```java {tabTitle:Java} | ||
| import io.sentry.Sentry; | ||
|
|
||
| Sentry.init(options -> { | ||
| options.setDsn("___PUBLIC_DSN___"); | ||
| options.setEnableSpotlight(true); | ||
| // Optional: override the default Spotlight URL (defaults to http://localhost:8969/stream) | ||
| options.setSpotlightConnectionUrl("http://localhost:8969/stream"); | ||
| }); | ||
| ``` | ||
|
|
||
| ```kotlin {tabTitle:Kotlin} | ||
| import io.sentry.Sentry | ||
|
|
||
| Sentry.init { options -> | ||
| options.dsn = "___PUBLIC_DSN___" | ||
| options.isEnableSpotlight = true | ||
| // Optional: override the default Spotlight URL (defaults to http://localhost:8969/stream) | ||
| options.spotlightConnectionUrl = "http://localhost:8969/stream" | ||
| } | ||
| ``` | ||
|
|
||
| <Alert level="info"> | ||
|
|
||
| The default Spotlight URL is `http://localhost:8969/stream`. You only need to set `spotlightConnectionUrl` if your Spotlight instance is running on a different host or port. | ||
|
|
||
| </Alert> | ||
|
|
||
| ## Verify | ||
|
|
||
| To verify the integration is working, capture a test exception and check the Spotlight UI: | ||
|
|
||
| ```java | ||
| import io.sentry.Sentry; | ||
|
|
||
| Sentry.captureException(new Exception("Spotlight test from Java!")); | ||
| ``` | ||
|
|
||
| ```kotlin | ||
| import io.sentry.Sentry | ||
|
|
||
| Sentry.captureException(Exception("Spotlight test from Java!")) | ||
| ``` | ||
|
|
||
| Open the Spotlight UI and confirm that the error event appears. | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.