Go with AllStak

Add error tracking, HTTP middleware, and tracing to your Go service with the AllStak Go SDK.

Source repository:
AllStak/allstak-go
Source README:
README.md
SDK version:
v0.4.0
Installation source:
Go modules
Last verified:
2026-05-31

Installation

Install with go get.

go get github.com/AllStak/allstak-go

Configuration

Construct a client with allstak.New and flush on shutdown.

import (
  "context"
  "os"
  allstak "github.com/AllStak/allstak-go"
)

client := allstak.New(allstak.Config{
    APIKey:      os.Getenv("ALLSTAK_API_KEY"),
    Environment: os.Getenv("APP_ENV"),
    Release:     os.Getenv("ALLSTAK_RELEASE"),
    ServiceName: "checkout-api",
})
defer client.Flush(context.Background())

Basic example

Or initialize from the environment with allstak.InitFromEnv().

client := allstak.InitFromEnv()
defer allstak.Close(context.Background())

Capturing errors

Capture errors with CaptureException; capture panics with Recover in a defer.

client.CaptureException(context.Background(), errors.New("example error"))

Tracking requests

Wrap your HTTP handler with allstak.Middleware for inbound requests, and use allstak.NewTransport for outbound. Gin and Echo integrations are also provided.

// inbound
http.ListenAndServe(":3000", allstak.Middleware(client)(mux))

// outbound
httpClient := &http.Client{ Transport: allstak.NewTransport(client, nil) }

Best practices

  • defer client.Flush(ctx) so buffered events are sent on exit.
  • Set Environment and Release on the Config.
  • Use the gin/echo/gorm/slog integration packages where relevant.