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

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

英語版と翻訳版に矛盾がある場合は、英語版が優先されます。詳細については、このページを参照してください。

問題を作成する

Androidエージェントカスタムインタラクション

重要

この機能は、 Default Interactionsが実行時に無効にされ、 ビルド時に適切に構成されている場合にのみ正しく動作します。

カスタムインタラクションの作成

カスタムインタラクションを作成し、追加情報で強化することができます。カスタムインタラクションが明示的に閉じられていない場合、New Relic エージェントはそれを自動的に閉じ、データを New Relic プラットフォームに送信します。

カスタム インタラクションを作成するには、 startInteractionを使用してインタラクションを開始し、 endInteractionを使用して終了します。システムは自動的にタイミングを測定します。

Java

// Start a custom interaction
String id = NewRelic.startInteraction("Tap on Search");
// ...do some work here...
// End the custom interaction
NewRelic.endInteraction(id);

コトリン

// Start a custom interaction
val id = NewRelic.startInteraction("Tap on Search")
// ...do some work here...
// End the custom interaction
NewRelic.endInteraction(id)

これらのメソッドを使用すると、アプリケーション内の特定のインタラクションの継続時間と詳細をキャプチャでき、インサイトでユーザーの動作とアプリケーションのパフォーマンスをより深く知ることができます。

カスタムインタラクションで子トレースを作成する

子トレースはカスタムインタラクションに似ています。親カスタムインタラクションが閉じられると、New Relic エージェントはその親カスタムインタラクションに関連付けられているすべての子メソッド トレースを自動的に閉じます。

子トレースを生成するには、 NewRelic.startMethodTrace()メソッドを使用します。親カスタムインタラクションと子トレースを実装する方法は次のとおりです。

Java

// Start a parent custom interaction
String parentId = NewRelic.startInteraction("Main Activity");
// Start a child trace
NewRelic.startMethodTrace("Load Resource From Database");
// ...do some work here...
// End the child trace
NewRelic.endMethodTrace();
// Start another child trace
NewRelic.startMethodTrace("Load Resource From Server");
// ...do some work here...
// End the child trace
NewRelic.endMethodTrace();
// End the parent interaction
NewRelic.endInteraction(parentId);

コトリン

// Start a parent custom interaction
val parentId = NewRelic.startInteraction("Main Activity")
// Start a child trace
NewRelic.startMethodTrace("Loop 1 Run")
// ...do some work here...
// End the child trace
NewRelic.endMethodTrace()
// Start another child trace
NewRelic.startMethodTrace("Loop 2 Run")
// ...do some work here...
// End the child trace
NewRelic.endMethodTrace()
// End the parent interaction
NewRelic.endInteraction(parentId)

考察

  • トレースメソッドを使用してカスタムインタラクションを作成する場合は、ユーザーの介入なしでインタラクションを開始および終了する必要があります。
  • ユーザーの介入を伴う 2 つのインタラクション間の時間を計算する場合は、これらのインタラクションの子トレースを作成しないでください。

このアプローチにより、モバイル アプリケーション内のインタラクションの詳細な追跡と測定が可能になり、アプリケーションのパフォーマンスとユーザーの行動に貴重なインサイトを提供できます。

Copyright © 2025 New Relic株式会社。

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