Create a customized transaction for any function or code


Is it possible to create/trigger a transaction for any given part of the code (apart from http or gRPC request).
I know it is possible in python custom code instrumentation

E.g. I want to instrument this function

func hello(){
transaction := apm.DefaultTracer.StartTransaction("hello", "code")
defer transaction.End()
fmt.Println("Hello World")

Apm agent does not start the transaction when the above function is called.

Thanks for your feedback

@karim-pai welcome to the forum!

Is your program short-lived? If so, you will need to run the tracer's Flush method before exiting to give a chance for the events to be sent to the server first. Add apm.DefaultTracer.Flush(nil) somewhere in your program and see if that helps.

Hi @axw ,

Indeed, flushing the tracer works. Go Apm agent does not send immediately the transaction to Apm Server as python agent does.

Thanks for your help.

1 Like