-
Notifications
You must be signed in to change notification settings - Fork 260
feat: Add Spotlight integration for local development debugging #1085
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
Open
DAcodedBEAT
wants to merge
8
commits into
getsentry:master
Choose a base branch
from
DAcodedBEAT:feature/spotlight
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
ce4d336
feat: add Spotlight integration for local development debugging
DAcodedBEAT 3ce6a35
fix: two more Spotlight bugs from fresh bot review on PR #1085
DAcodedBEAT fdc0011
fix: same WaitGroup race in spotlightEnvelopeSender
DAcodedBEAT afafbb5
fix: two more Spotlight bugs from cursor bot review
DAcodedBEAT 4f7ff52
fix: pending counter bookkeeping bugs found by fable re-review
DAcodedBEAT 82be124
fix: two more bugs from fresh sentry bot review
DAcodedBEAT 7e28e5d
fix: misleading no-DSN log on the default Spotlight path
DAcodedBEAT 14b254b
fix: two more Spotlight bugs from cursor bot review
DAcodedBEAT 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
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,86 @@ | ||
| // This is an example program that demonstrates Sentry Go SDK integration | ||
| // with Spotlight for local development debugging. | ||
| // | ||
| // Spotlight allows you to see all events captured by your application in a | ||
| // local development web UI, without sending them to a Sentry server. This is | ||
| // useful for debugging during development. | ||
| // | ||
| // Try it by running: | ||
| // | ||
| // go run main.go | ||
| // | ||
| // Configuration: | ||
| // - Spotlight is enabled by default in this example (Spotlight: true) | ||
| // - Events are NOT sent to Sentry (DSN is empty) | ||
| // - To also send events to Sentry, set DSN via environment variable: | ||
| // SENTRY_DSN=https://key@sentry.io/project go run main.go | ||
| // - Or edit the DSN field below | ||
| // | ||
| // Before running this example, make sure Spotlight is running: | ||
| // | ||
| // npm install -g @spotlightjs/spotlight | ||
| // spotlight | ||
| // | ||
| // Then open http://localhost:8969 in your browser to see the Spotlight UI. | ||
| package main | ||
|
|
||
| import ( | ||
| "context" | ||
| "errors" | ||
| "log" | ||
| "time" | ||
|
|
||
| "github.com/getsentry/sentry-go" | ||
| ) | ||
|
|
||
| func main() { | ||
| err := sentry.Init(sentry.ClientOptions{ | ||
| // Either set your DSN here or set the SENTRY_DSN environment variable. | ||
| Dsn: "", | ||
| // Enable printing of SDK debug messages. | ||
| // Useful when getting started or trying to figure something out. | ||
| Debug: true, | ||
| // Enable Spotlight for local debugging. | ||
| Spotlight: true, | ||
| // Enable tracing to see performance data in Spotlight. | ||
| EnableTracing: true, | ||
| TracesSampleRate: 1.0, | ||
| }) | ||
| if err != nil { | ||
| log.Fatalf("sentry.Init: %s", err) | ||
| } | ||
| // Flush buffered events before the program terminates. | ||
| // Set the timeout to the maximum duration the program can afford to wait. | ||
| defer sentry.Flush(2 * time.Second) | ||
|
|
||
| log.Println("Sending sample events to Spotlight...") | ||
|
|
||
| // Capture a simple message | ||
| sentry.CaptureMessage("Hello from Spotlight!") | ||
|
|
||
| // Capture an exception | ||
| sentry.CaptureException(errors.New("example error for Spotlight debugging")) | ||
|
|
||
| // Capture an event with additional context | ||
| sentry.WithScope(func(scope *sentry.Scope) { | ||
| scope.SetTag("environment", "development") | ||
| scope.SetLevel(sentry.LevelWarning) | ||
| scope.SetContext("example", map[string]interface{}{ | ||
| "feature": "spotlight_integration", | ||
| "version": "1.0.0", | ||
| }) | ||
| sentry.CaptureMessage("Event with additional context") | ||
| }) | ||
|
|
||
| // Performance monitoring example | ||
| span := sentry.StartSpan(context.Background(), "example.operation") | ||
| defer span.Finish() | ||
|
|
||
| span.SetData("example", "data") | ||
| childSpan := span.StartChild("child.operation") | ||
| // Simulate some work | ||
| time.Sleep(100 * time.Millisecond) | ||
| childSpan.Finish() | ||
|
|
||
| log.Println("Events sent! Check your Spotlight UI at http://localhost:8969") | ||
| } |
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
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
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
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
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
Oops, something went wrong.
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.