Installation steps

  1. Install Atatus Go Agent and Required Modules

    copy
    icon/buttons/copy
    go get go.atatus.com/agent
    go get go.atatus.com/agent/module/atgorm
    
  2. Configure Atatus and Set Up Database Connection

    copy
    icon/buttons/copy
    import (
        "go.atatus.com/agent/module/atgorm"
    
        "go.atatus.com/agent"
        _ "go.atatus.com/agent/module/atgorm/dialects/mysql"
    )
    
    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")
    
          dsn := "user:password@tcp(127.0.0.1:3306)/mydb?parseTime=true"
    
          // Open GORM DB with Atatus instrumentation
          db, err := atgorm.Open(mysql.Open(dsn), &gorm.Config{})
          ...
    }
    
    func handleRequest(w http.ResponseWriter, req *http.Request) {
        // Use DB with context to get Database metrics  
        dbi:=db.WithContext(req.Context())
        dbi.Find(...) 
    }
    
  3. Clean Up Dependencies

    copy
    icon/buttons/copy

    go mod tidy
    
  4. Run the Application

    copy
    icon/buttons/copy

    go run main.go