The ability to trace asynchronous segments with the NewGoroutine
API is available as of Go agent version 2.6.0. If you do not have version 2.6.0 or higher, update your Go agent to the latest version.
NewGoroutine
The Transaction.NewGoroutine() Transaction
method allows transactions to create segments in multiple goroutines.
NewGoroutine
returns a new reference to the Transaction
. This must be called any time you are passing the Transaction
to another goroutine which makes segments. Each segment-creating goroutine must have its own Transaction
reference. It does not matter if you call this before or after the other goroutine has started.
All Transaction
methods can be used in any Transaction
reference. The Transaction
will end when End()
is called in any goroutine.
Example passing a new Transaction
reference directly to another goroutine:
go func(txn *newrelic.Transaction) { defer txn.StartSegment("async").End() time.Sleep(100 * time.Millisecond)}(txn.NewGoroutine())
Example passing a new Transaction
reference on a channel to another goroutine:
ch := make(chan *newrelic.Transaction)go func() { txn := <-ch defer txn.StartSegment("async").End() time.Sleep(100 * time.Millisecond)}()ch <- txn.NewGoroutine()
その他のヘルプ
さらに支援が必要な場合は、これらのサポートと学習リソースを確認してください:
- Explorers Hubでは、コミュニティからのサポートを受けたり、ディスカッションに参加したりすることができます。
- 当社サイトで答えを見つけて、サポートポータルの使用方法を確認してください。
- Linux、Windows、およびmacOS向けトラブルシューティングツールであるNew Relic Diagnosticsを実行してください。
- New Relicのデータセキュリティとライセンスドキュメント をご確認ください。