Installation steps
Install Atatus Go Agent and logging module
copygo get go.atatus.com/agent go get go.atatus.com/agent/module/atlogrus
Set up tracer and configure log exporter
copyimport ( "github.com/sirupsen/logrus" "go.atatus.com/agent" "go.atatus.com/agent/module/atlogrus" ) func main() { // atlogrus.Hook will send "error", "panic", and "fatal" level log messages to Atatus apm. logrus.AddHook(&atlogrus.Hook{}) } func handleRequest(w http.ResponseWriter, req *http.Request) { // atlogrus.TraceContext extracts the transaction and span (if any) from the given context, // and returns logrus.Fields containing the trace, transaction, and span IDs. traceContextFields := atlogrus.TraceContext(req.Context()) logrus.WithFields(traceContextFields).Debug("handling request") // Output: // {"level":"debug","msg":"handling request","time":"1970-01-01T00:00:00Z","trace.id":"67829ae467e896fb2b87ec2de50f6c0e","transaction.id":"67829ae467e896fb"} }
Clean Up Dependencies
copygo mod tidy
Run the Application
copygo run main.go