Installation steps
Install Atatus Go Agent and framework module
copygo get go.atatus.com/agent go get go.atatus.com/agent/module/atbeego
Set up tracer and add Atatus middleware
copyimport ( "github.com/astaxie/beego" "go.atatus.com/agent" "go.atatus.com/agent/module/atbeego" ) func main() { // Initialize Atatus tracer using environment variables tracer := at.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") // Register routes app := beego.NewApp() app.Handlers.Add("/", &sampleController{}) // Run Beego app with Atatus middleware app.RunWithMiddleWares("localhost:8080", atbeego.Middleware()) } func (c *sampleController) Get() { ctx:=c.Ctx.Request.Context() // c.Ctx.Request.Context() should be propagated to downstream operations such as database queries , http external API calls. _ = db.QueryContext(ctx, "SELECT 'Atatus!'").Scan(&greeting) }
Clean Up and Sync Dependencies
copygo mod tidy
Run the Application
copygo run main.go