fiber
This backend SDK requires one of the Highlight frontend SDKs to be installed, so please make sure you've followed the fullstack mapping guide first.
H.init("<YOUR_PROJECT_ID>", {
tracingOrigins: ['localhost', 'example.myapp.com/backend'],
networkRecording: {
enabled: true,
recordHeadersAndBody: true,
},
});
Install the highlight-go
package with go get
.
go get -u github.com/highlight/highlight/sdk/highlight-go
H.Start
starts a goroutine for recording and sending backend errors. Setting your project id lets Highlight record errors for background tasks and processes that aren't associated with a frontend session.
import (
H "github.com/highlight/highlight/sdk/highlight-go"
)
func main() {
// ...
H.SetProjectID("<YOUR_PROJECT_ID>")
H.Start()
defer H.Stop()
// ...
}
highlightFiber.Middleware()
provides a Go Fiber middleware to automatically record and send errors to Highlight.
import (
highlightFiber "github.com/highlight/highlight/sdk/highlight-go/middleware/fiber"
)
func main() {
// ...
app := fiber.New()
app.Use(highlightFiber.Middleware())
// ...
}
If you want to explicitly send an error to Highlight, you can use the H.RecordError
method.
H.RecordError(ctx, err, attribute.String("key", "value"))
Now that you've set up the Middleware, verify that the backend error handling works by consuming an error from your handler. This is as easy as having a route handler return an error.
Start sending logs to Highlight! Follow the logging setup guide to get started.