• EnglishEspañol日本語한국어Português
  • ログイン今すぐ開始

この機械翻訳は、参考として提供されています。

In the event of any inconsistency between the English version and the translated version, the English versionwill take priority. Please visit this page for more information.

問題を作成する

非同期アプリケーションのトレース

NewGoroutine API を使用して非同期セグメントをトレースする機能は、 Go エージェント バージョン 2.6.0 以降で利用できます。バージョン 2.6.0 以降を使用していない場合は、Go エージェントを最新バージョンに更新してください。

NewGoroutine(ニューゴルーチン

Transaction.NewGoroutine() Transactionメソッドにより、トランザクションは複数のゴルーチンでセグメントを作成できます。

NewGoroutine Transactionへの新しい参照を返します。セグメントを作成する別のゴルーチンにTransactionを渡すときはいつでも、これを呼び出す必要があります。各セグメントを作成するゴルーチンには、独自のTransaction参照が必要です。他のゴルーチンが開始する前または後にこれを呼び出すかどうかは問題ではありません。

すべてのTransactionメソッドは、任意のTransaction参照で使用できます。いずれかのゴルーチンでEnd()が呼び出されると、 Transactionは終了します。

新しいTransaction参照を別のゴルーチンに直接渡す例:

go func(txn *newrelic.Transaction) {
defer txn.StartSegment("async").End()
time.Sleep(100 * time.Millisecond)
}(txn.NewGoroutine())

チャネルの新しいTransaction参照を別のゴルーチンに渡す例:

ch := make(chan *newrelic.Transaction)
go func() {
txn := <-ch
defer txn.StartSegment("async").End()
time.Sleep(100 * time.Millisecond)
}()
ch <- txn.NewGoroutine()
Copyright © 2024 New Relic株式会社。

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.