Installation steps

  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/atfiber
    
  2. Set up tracer and add Atatus middleware

    copy
    icon/buttons/copy
    import (
        "github.com/gofiber/fiber/v2"
    
        "go.atatus.com/agent"
        "go.atatus.com/agent/module/atfiber"
    )
    
    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 fiber router and apply Atatus middleware (atfiber)
        app := fiber.New()
        app.Use(atfiber.Middleware())
        ...
    }
    
    func handleRequest(c *fiber.Ctx)  {
        // The context from  c.UserContext() should be propagated to downstream operations,
        // such as database queries and external HTTP API calls
    
        ctx:=c.UserContext()
        _ = 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