Installation steps
Install Atatus Go Agent and framework module
copygo get go.atatus.com/agent go get go.atatus.com/agent/module/athttprouter
Set up tracer and add Atatus middleware
copyimport ( "github.com/julienschmidt/httprouter" "go.atatus.com/agent" "go.atatus.com/agent/module/athttprouter" ) func main() { // Initialize Atatus tracer with values from environment tracer := atatus.DefaultTracer tracer.Service.LicenseKey = os.Getenv("ATATUS_LICENSE_KEY") tracer.Service.AppName = os.Getenv("ATATUS_APP_NAME") tracer.Service.Tracing = os.Getenv("ATATUS_TRACING") tracer.Service.Analytics = os.Getenv("ATATUS_ANALYTICS") // Setup httprouter and wrap handlers with at instrumentation router := httprouter.New() const route = "/my/route" router.GET(route, athttprouter.Wrap(handleRequest, route)) http.ListenAndServe(":8080", router) } func handleRequest(w http.ResponseWriter, r *http.Request, ps httprouter.Params) { // The context from r.Context() should be propagated to downstream operations, // such as database queries and external HTTP API calls ctx := r.Context() _ = db.QueryContext(ctx, "SELECT 'Atatus!'").Scan(&greeting) }
Clean Up Dependencies
copygo mod tidy
Run the Application
copygo run main.go