Installation steps
Install Atatus Go Agent and logging module
copygo get go.atatus.com/agent go get go.atatus.com/agent/module/atzap
Set up tracer and configure log exporter
copyimport ( "go.atatus.com/agent" "go.atatus.com/agent/module/atzap" "go.uber.org/zap" ) // atzap.Core.WrapCore will wrap the core created by zap.NewExample // such that logs are also sent to the atzap.Core. // // atzap.Core will send "error", "panic", and "fatal" level log // messages to Atatus APM. var logger = zap.NewExample(zap.WrapCore((&atzap.Core{}).WrapCore)) func handleRequest(w http.ResponseWriter, req *http.Request) { // atzap.TraceContext extracts the transaction and span (if any) // from the given context, and returns zap.Fields containing the // trace, transaction, and span IDs. traceContextFields := atzap.TraceContext(req.Context()) logger.With(traceContextFields...).Debug("handling request") // Output: // {"level":"debug","msg":"handling request","trace.id":"67829ae467e896fb2b87ec2de50f6c0e","transaction.id":"67829ae467e896fb"} }
Clean Up Dependencies
copygo mod tidy
Run the Application
copygo run main.go