Installation Steps For Echo 4.x

If you are using Echo 4.x (github.com/labstack/echo/v4), use module/atechov4.

  1. Install Atatus Go Agent and framework module

    copy
    icon/buttons/copy
    go get go.atatus.com/agent
    go get go.atatus.com/agent/module/atechov4
    
  2. Set up tracer and add Atatus middleware

    copy
    icon/buttons/copy
    import (
        "github.com/labstack/echo/v4"
    
        "go.atatus.com/agent" 
        "go.atatus.com/agent/module/atechov4"
    )
    
    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 (atechov4)
        e.Use(atechov4.Middleware())
    }
    
    func handleRequest(c echo.Context) error {
        // The context from c.Request().Context() should be propagated to downstream operations,
        // such as database queries and external HTTP API calls
    
        // Example 
        ctx:=c.Request().Context()
        _ = db.QueryContext(ctx, "SELECT 'Atatus!'").Scan(&greeting)
    }
    
  3. Clean Up and Sync Dependencies

    copy
    icon/buttons/copy

    go mod tidy
    
  4. Run the Application

    copy
    icon/buttons/copy

    go run main.go