Go SDK Integration Guide
The github.com/algotyrnt/triage/sdk/go package provides non-blocking panic recovery middleware compatible with Go standard library net/http and all popular HTTP frameworks.
Installation
Section titled “Installation”go get github.com/algotyrnt/triage/sdk/goBasic Middleware Usage
Section titled “Basic Middleware Usage”By default, the SDK only requires your API key and the Engine URL. Repository metadata, monorepo subdirectories, and Git commit hashes are automatically resolved by the backend and the Go runtime:
package main
import ( "net/http" triage "github.com/algotyrnt/triage/sdk/go")
func main() { mux := http.NewServeMux() mux.HandleFunc("/api/v1/orders", handleOrders)
// Wrap handler with triage panic isolation middleware handler := triage.Middleware( "your_sample_api_key", "https://triage.yourcompany.com/api/v1/telemetry", )(mux)
http.ListenAndServe(":8080", handler)}How Zero-Configuration Works
Section titled “How Zero-Configuration Works”The Triage SDK is designed with zero client-side configuration boilerplate. You only pass apiKey and engineURL:
- Repository & Monorepo Subfolder Resolution: When you register a repository in the Triage dashboard (even as a subfolder in a monorepo like
/backendor/engine), your API key is uniquely bound to that project. The Triage engine looks up repository metadata automatically upon telemetry arrival. - Git Commit Detection: The SDK automatically extracts the Git commit SHA from Go’s embedded binary build info via
debug.ReadBuildInfo(). - Trace Context Propagation: The SDK automatically extracts or generates OpenTelemetry-compatible W3C
traceparentheaders (00-<trace_id>-0000000000000001-01) andX-Triage-Trace-ID.
Router Integrations
Section titled “Router Integrations”1. Go Standard Library (net/http)
Section titled “1. Go Standard Library (net/http)”mux := http.NewServeMux()mux.HandleFunc("/process", processHandler)
handler := triage.Middleware("your_sample_api_key", "http://localhost:8080/api/v1/telemetry")(mux)http.ListenAndServe(":8080", handler)2. Chi (go-chi/chi/v5)
Section titled “2. Chi (go-chi/chi/v5)”r := chi.NewRouter()r.Use(triage.Middleware("your_sample_api_key", "http://localhost:8080/api/v1/telemetry"))
r.Get("/items", getItemsHandler)http.ListenAndServe(":8080", r)3. Gin (gin-gonic/gin)
Section titled “3. Gin (gin-gonic/gin)”r := gin.New()// Use Gin's WrapH helper to adapt standard http.Handler middlewarer.Use(gin.WrapH(triage.Middleware("your_sample_api_key", "http://localhost:8080/api/v1/telemetry")(r)))
r.GET("/api/users", handleUsers)r.Run(":8080")4. Echo (labstack/echo/v4)
Section titled “4. Echo (labstack/echo/v4)”e := echo.New()e.Use(echo.WrapMiddleware(triage.Middleware("your_sample_api_key", "http://localhost:8080/api/v1/telemetry")))
e.GET("/ping", handlePing)e.Start(":8080")5. Fiber (gofiber/fiber/v2)
Section titled “5. Fiber (gofiber/fiber/v2)”app := fiber.New()app.Use(adaptor.HTTPMiddleware(triage.Middleware("your_sample_api_key", "http://localhost:8080/api/v1/telemetry")))
app.Get("/stats", handleStats)app.Listen(":8080")Trace Context & OpenTelemetry
Section titled “Trace Context & OpenTelemetry”Each recovered panic automatically propagates an OpenTelemetry-compatible trace ID:
- Header:
X-Triage-Trace-ID - Standard W3C header:
traceparent
This allows you to correlate client error reports with the corresponding Triage dashboard incident.