Created
July 20, 2020 18:56
-
-
Save thamizhv/6caf10c7daed0e089addedeb0f97e9cf to your computer and use it in GitHub Desktop.
Print Elastic APM trace ID from new transaction
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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