Supported frameworks
Version 0.1.net/http (with ServeMux patterns), Gin and Echo.Install
Terminal
go get github.com/Codeskop-io/codeskop-goInitialize
Call Init at the start of main and Close before it returns, so queued events are sent.
main.go
import ( "os" "time" codeskop "github.com/Codeskop-io/codeskop-go") func main() { codeskop.Init(codeskop.Options{APIKey: os.Getenv("CODESKOP_API_KEY")}) // cs_live_pk_… (public key) defer codeskop.Close(2 * time.Second) // ...}Add your router
main.go
mux := http.NewServeMux()mux.HandleFunc("GET /orders/{id}", getOrder) // Routes, panics (answered with 500) and errors.http.ListenAndServe(":8080", codeskop.Middleware(mux))main.go
import codeskopgin "github.com/Codeskop-io/codeskop-go/integrations/gin" r := gin.New()r.Use(codeskopgin.Middleware()) // use instead of gin.Recovery()main.go
import codeskopecho "github.com/Codeskop-io/codeskop-go/integrations/echo" e := echo.New()e.Use(codeskopecho.Middleware())Requests are recorded by route pattern (/orders/{id}, /orders/:id becomes /orders/{id}). Health checks aren't recorded.
Outgoing calls
client := &http.Client{Transport: codeskop.Transport(http.DefaultTransport)}Errors, panics and users
if err := charge(ctx, order); err != nil { codeskop.CaptureError(ctx, err, map[string]string{"provider": "stripe"})} codeskop.CaptureMessage(ctx, "Inventory sync skipped")codeskop.SetUser(r.Context(), user.ID) // inside a wrapped handler: your own ID, never an email go func() { defer codeskop.Recover(ctx) // report panics in your own goroutines work()}()Options
| Option | Type | Default | Description |
|---|---|---|---|
| APIKey | string | CODESKOP_API_KEY | The project's public key. Secret keys are refused and the SDK stays off. |
| Environment | string | production | Env var CODESKOP_ENVIRONMENT. |
| Release | string | auto | Auto-detected from common hosts and CI. Env var CODESKOP_RELEASE. |
| DisableRequests / DisableOutgoing | bool | false | Turn off incoming request or outgoing call recording. |
| IgnoreRoutes | []string | health checks | Glob patterns never recorded. |
| IgnoreErrors | []string | nil | Error type names never sent, for example *url.Error. |
| BeforeSend | func | nil | Edit or drop any event before it's sent. |
| DisableUserID | bool | false | Never attach user IDs. |
| Debug | bool | false | Log what the SDK does. |
Privacy
Never captured: request or response bodies, cookies, Authorization headers and query strings. See Privacy & Security.