Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Print Elastic APM trace ID from new transaction
// from new transaction
func Foo(){
apmTx := apm.DefaultTracer.StartTransaction("transaction_name", "transaction_type")
fmt.Println(apmTx.TraceContext().Trace.String()) // prints TraceID
apmTx.End()
}
// from incoming http request
func FooHandler(w http.ResponseWriter, r *http.Request) {
apmTx := apm.TransactionFromContext(r.Context())
fmt.Println(apmTx.TraceContext().Trace.String()) // prints TraceID
apmTx.End()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment