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

    copy
    icon/buttons/copy
    import (
        "github.com/olivere/elastic"
    
        "go.atatus.com/agent" 
        "go.atatus.com/agent/module/atelasticsearch"
    )
    
    var client, _ = elastic.NewClient(elastic.SetHttpClient(&http.Client{
        Transport: atelasticsearch.WrapRoundTripper(http.DefaultTransport),
    }))
    
    func main() {
        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")
    }
    
    func handleRequest(w http.ResponseWriter, req *http.Request) {
        // req.Context() should be propagated to downstream operations such as database queries , http external API calls.
        result, err := client.Search("index").Query(elastic.NewMatchAllQuery()).Do(req.Context())
        ...
    }
    
  3. Clean Up Dependencies

    copy
    icon/buttons/copy

    go mod tidy
    
  4. Run the Application

    copy
    icon/buttons/copy

    go run main.go