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/atgoredisv8
    
  2. Configure Atatus and Set Up Database Connection

    copy
    icon/buttons/copy
    import (
        "github.com/go-redis/redis/v8"
    
        "go.atatus.com/agent"
        "go.atatus.com/agent/module/atgoredisv8"
    )
    
    var redisClient *redis.Client
    
    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")
    
        redisClient = redis.NewClient(&redis.Options{})
    
        // Redis commands will be reported as spans within the current transaction.
        redisClient.AddHook(atgoredis.NewHook())
    }
    
    func handleRequest(w http.ResponseWriter, r *http.Request) {
         ctx := r.Context () // should be propagated to downstream operations such as database queries , http external API calls.
    
        // Perform Redis GET command within request context
        val, err := redisClient.Get(ctx, "key").Result()
        ...
    }
    
  3. Clean Up Dependencies

    copy
    icon/buttons/copy
    go mod tidy
    
  4. Run the Application

    copy
    icon/buttons/copy
    go run main.go