← All platforms

Echo error tracking

An Echo handler can return an error or panic outright. Use the Sentry Go SDK to keep the reports you need on your Telebugs server.

~/hoofnotes  go get github.com/getsentry/sentry-go/echo
~/hoofnotes  nvim error_tracking.go main.go
package main
import "github.com/getsentry/sentry-go"
func initErrorTracking() error {
return sentry.Init(sentry.ClientOptions{
// Copy the complete Telebugs DSN, key and path included.
Dsn: "YOUR_TELEBUGS_DSN",
})
}
package main
import (
"time"
"github.com/getsentry/sentry-go"
sentryecho "github.com/getsentry/sentry-go/echo"
"github.com/labstack/echo/v5"
"github.com/labstack/echo/v5/middleware"
)
func main() {
if err := initErrorTracking(); err != nil {
panic(err)
}
defer sentry.Flush(2 * time.Second)
app := echo.New()
app.Use(middleware.Recover())
app.Use(sentryecho.New(sentryecho.Options{Repanic: true}))
registerNotesRoutes(app)
app.Start(":3000")
}
~/hoofnotes  go run .

Space pauses or resumes. R replays. Escape shows the complete setup.

Hang on, I already use Sentry

Keep sentry-go and change its destination to your Telebugs DSN. Your error reports stay on your server. You don’t need a Sentry account.

Panics or returned errors?

The Echo middleware captures panics. Ordinary returned errors can be reported explicitly through the request’s Sentry hub, so you decide which handled failures deserve attention.

What about errors I return instead of panicking?

Go errors are values. Report one explicitly with CaptureException when it matters. A middleware connection doesn’t automatically turn every returned error into a report.