Skip to content
Codeskop

Go

codeskop-go captures errors, panics, incoming requests and outgoing HTTP calls from Go 1.23 and later. Standard library only; events are batched and sent from a background goroutine.

Supported frameworks

Version 0.1. net/http (with ServeMux patterns), Gin and Echo.

Install

Terminal
go get github.com/Codeskop-io/codeskop-go

Initialize

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))

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

OptionTypeDefaultDescription
APIKeystringCODESKOP_API_KEYThe project's public key. Secret keys are refused and the SDK stays off.
EnvironmentstringproductionEnv var CODESKOP_ENVIRONMENT.
ReleasestringautoAuto-detected from common hosts and CI. Env var CODESKOP_RELEASE.
DisableRequests / DisableOutgoingboolfalseTurn off incoming request or outgoing call recording.
IgnoreRoutes[]stringhealth checksGlob patterns never recorded.
IgnoreErrors[]stringnilError type names never sent, for example *url.Error.
BeforeSendfuncnilEdit or drop any event before it's sent.
DisableUserIDboolfalseNever attach user IDs.
DebugboolfalseLog what the SDK does.

Privacy

Never captured: request or response bodies, cookies, Authorization headers and query strings. See Privacy & Security.