Skip to main content

Go errors from sentry-go on your machine

Set the sentry-go DSN to http://sentry@127.0.0.1:8000/1. Errors you capture and panics you recover then show up in Buggregator on your machine, each with its stack trace. The DSN is the only change: your sentry.CaptureException calls stay as they are.

Steps

1. Start Buggregator

bash
docker run --pull always \
  -p 127.0.0.1:8000:8000 \
  ghcr.io/buggregator/server:latest

2. Init the SDK with Buggregator's DSN

The number at the end puts events into the default project, which the UI shows from the start. In Docker Compose, use the Buggregator service name instead of 127.0.0.1.

bash
go get github.com/getsentry/sentry-go
go
err := sentry.Init(sentry.ClientOptions{
    Dsn:              "http://sentry@127.0.0.1:8000/1",
    EnableTracing:    true,
    TracesSampleRate: 1.0,
})
if err != nil {
    log.Fatal(err)
}
defer sentry.Flush(2 * time.Second)

Leave Dsn empty and the SDK reads SENTRY_DSN from the environment instead.

3. Send errors and panics

Capture an error where you handle it. Recover a panic with a deferred call.

go
if err := chargeCard(order); err != nil {
    sentry.CaptureException(err)
}

func worker() {
    defer sentry.Recover()
    // code that may panic
}

4. Catch panics in HTTP handlers

For net/http, wrap handlers with the sentryhttp package.

go
import sentryhttp "github.com/getsentry/sentry-go/http"

sentryHandler := sentryhttp.New(sentryhttp.Options{Repanic: true})
http.HandleFunc("/checkout", sentryHandler.HandleFunc(checkout))

5. Open the error

Trigger it, then open http://127.0.0.1:8000. The error shows its message and the stack trace frame by frame. With tracing on, the request's trace is on the Sentry page, Traces tab.

Why it works

Buggregator accepts the Sentry protocol, and it was tested with real requests from sentry-go 0.50. It stores errors, messages, transactions and logs. sentry.Flush waits until queued events are sent, so a short-lived program does not exit before they leave.

Checked on with Buggregator v2.13.0

Setup in 60 seconds

No registration. No account. Start it and point your app at it.

1

Start Buggregator

One file, installed with one command. The web UI opens on port 8000. Prefer containers? Use the Docker tab.

$ curl -fsSL https://raw.githubusercontent.com/buggregator/server/master/scripts/install.sh | sh
$ HTTP_ADDR=127.0.0.1:8000 \
  SMTP_ADDR=127.0.0.1:1025 \
  VAR_DUMPER_ADDR=127.0.0.1:9912 \
  MONOLOG_ADDR=127.0.0.1:9913 \
  PROXY_ADDR=127.0.0.1:8080 \
  ~/.local/bin/buggregator

The script picks the file for your CPU: Intel/AMD or ARM.

One file for Linux, macOS and Windows, about 40 MB. Nothing else to install.

This run line keeps it on this computer. Without the *_ADDR settings it listens on all network interfaces

Rather not run a script? Download the file yourself

Runs on Windows, macOS and Linux, on Intel/AMD and ARM.

Prefer not to do it yourself? Your AI agent can set Buggregator up for you