Installation Steps For Echo 3.x
If you are using Echo 3.x (github.com/labstack/echo)
, use module/atecho
.
Install Atatus Go Agent and framework module
copygo get go.atatus.com/agent go get go.atatus.com/agent/module/atecho
Set up tracer and add Atatus middleware
copyimport ( "github.com/labstack/echo" "go.atatus.com/agent" "go.atatus.com/agent/module/atecho" ) func main() { // Initialize Atatus tracer using environment variables 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") e := echo.New() // Setup echo router and apply Atatus middleware (atecho) e.Use(atecho.Middleware()) e.GET("/", handleRequest) // Start server e.Fatal(e.Start(":8080")) } func handleRequest(c echo.Context) error { ctx:= c.Request().Context() // c.Request().Context() should be propagated to downstream operations such as database queries, http external API calls. // Example _ = db.QueryContext(ctx, "SELECT 'Atatus!'").Scan(&greeting) }
Clean Up and Sync Dependencies
copygo mod tidy
Run the Application
copygo run main.go