構文
Java
NewRelic.startInteraction(string $interactionName)
コトリン [#kotlin]
NewRelic.startInteraction(actionName: String)
説明 [#description]
Androidアプリのコードで、メソッドをインストルメントするためのインタラクションを作成します。
すでに存在し、すでに追跡されているインタラクションに名前を付けるには、を参照してください。 setInteractionName()
パラメーター [#parameters]
パラメータ | タイプ | 説明 |
---|---|---|
|
| 必須項目です。インタラクションにつけたい名前。 |
戻り値 [#return-values]
特定の時点で インタラクションを終了する ために使用できるインタラクション ID 番号を返します。
例 [#example]
RefreshContacts
という名前のインタラクションの追跡を開始する例を次に示します。
Java [#java]
public class MainActivity extends Activity { ... @Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.action_refresh: NewRelic.startInteraction("RefreshContacts"); …… return true; default: return super.onOptionsItemSelected(item); } } ...}
コトリン [#kotlin]
class MainActivity : AppCompatActivity() {
..... var client: OkHttpClient = OkHttpClient();
binding.fab.setOnClickListener { view ->
val interActionId = NewRelic.startInteraction("Getting Data From Server")
lifecycleScope.launch(Dispatchers.IO) { val result = getRequest() NewRelic.endInteraction(interActionId) } } } .... }
構文
目的-c
+ (NSString*) startInteractionWithName:(NSString*)interactionName;
迅速 [#swift]
NewRelic.startInteraction(string: "myInteractionName")
説明 [#description]
このメソッドは、 interactionName
を名前として使用して対話トレースを開始します。インタラクションは、タイムアウトが発生するかstopCurrentInteraction
が呼び出されるまで、計測されたすべてのメソッドを記録します。
パラメーター [#parameters]
パラメータ | タイプ | 説明 |
---|---|---|
|
| 必須項目です。インタラクションにつけたい名前。 |
戻り値 [#return-values]
startInteractionWithName
が呼び出された場合、戻り値はstopCurrentInteraction
に渡す必要があるinteractionIdentifier
です。ただし、 startInteractionWithName
は最終的にインテリジェントに完了するため、start の呼び出し後にstopCurrentInteraction
を呼び出す必要はありません。
例 [#examples]
Objective-C [#obj-c]
NSString *identifier = [NewRelic startInteractionWithName: @"myInteractionName"];[NewRelic stopCurrentInteraction: identifier];
迅速 [#swift]
let identifier = NewRelic.startInteraction(withName: "myInteractionName")NewRelic.stopCurrentInteraction(identifier)
構文
startInteraction(options: { value: string; }) => Promise<{ value: string; }>
説明 [#description]
メソッドをインタラクションとして追跡します。
パラメーター [#parameters]
パラメータ | タイプ | 説明 |
---|---|---|
|
| 必須項目です。インタラクションにつけたい名前。 |
例 [#example]
const badApiLoad = async () => { const id = await NewRelicCapacitorPlugin.startInteraction({ value: 'StartLoadBadApiCall' }); console.log(id); const url = 'https://fakewebsite.com/moviessssssssss.json'; fetch(url) .then((response) => response.json()) .then((responseJson) => { console.log(responseJson); NewRelicCapacitorPlugin.endInteraction({ interactionId: id.value }); }) .catch((error) => { NewRelicCapacitorPlugin.endInteraction({ interactionId: id.value }); console.error(error); }); };
構文
startInteraction(interactionName: string, cb?: function): Promise<InteractionId>;
説明 [#description]
メソッドをインタラクションとして追跡します。
パラメーター [#parameters]
パラメータ | タイプ | 説明 |
---|---|---|
|
| 必須項目です。インタラクションにつけたい名前。 |
例 [#example]
const badApiLoad = async () => { const interactionId = await NewRelic.startInteraction('StartLoadBadApiCall'); console.log(interactionId); const url = 'https://cordova.apache.org/moviessssssssss.json'; fetch(url) .then((response) => response.json()) .then((responseJson) => { console.log(responseJson); NewRelic.endInteraction(interactionId); }) .catch((error) => { NewRelic.endInteraction(interactionId); console.error(error); });
構文
StartInteraction(string interactionName): string;
説明 [#description]
メソッドをインタラクションとして追跡します。
パラメーター [#parameters]
パラメータ | タイプ | 説明 |
---|---|---|
|
| 必須項目です。インタラクションにつけたい名前。 |
例 [#example]
HttpClient myClient = new HttpClient(CrossNewRelic.Current.GetHttpMessageHandler());
string interactionId = CrossNewRelic.Current.StartInteraction("Getting data from service");
var response = await myClient.GetAsync(new Uri("https://jsonplaceholder.typicode.com/todos/1")); if (response.IsSuccessStatusCode) { var content = await response.Content.ReadAsStringAsync(); } else { Console.WriteLine("Unsuccessful response code"); }
CrossNewRelic.Current.EndInteraction(interactionId);
構文
startInteraction(String actionName);
説明 [#description]
メソッドをインタラクションとして追跡します。
パラメーター [#parameters]
パラメータ | タイプ | 説明 |
---|---|---|
|
| 必須項目です。インタラクションにつけたい名前。 |
例 [#example]
var id = await NewrelicMobile.instance.startInteraction("Getting Data from Service"); try { var dio = Dio(); var response = await dio.get( 'https://reqres.in/api/users?delay=15'); print(response); NewrelicMobile.instance.endInteraction(id); Timeline.finishSync(); } catch (e) { print(e); }
構文
startInteraction(interactionName: string): Promise<InteractionId>;
説明 [#description]
メソッドをインタラクションとして追跡します。
パラメーター [#parameters]
パラメータ | タイプ | 説明 |
---|---|---|
|
| 必須項目です。インタラクションにつけたい名前。 |
例 [#example]
const badApiLoad = async () => { const interactionId = await NewRelic.startInteraction('StartLoadBadApiCall'); console.log(interactionId); const url = 'https://facebook.github.io/react-native/moviessssssssss.json'; fetch(url) .then((response) => response.json()) .then((responseJson) => { console.log(responseJson); NewRelic.endInteraction(interactionId); }) .catch((error) => { NewRelic.endInteraction(interactionId); console.error(error); });;};
構文
StartInteraction(string interactionName): string;
説明 [#description]
メソッドをインタラクションとして追跡します。
パラメーター [#parameters]
パラメータ | タイプ | 説明 |
---|---|---|
|
| 必須項目です。インタラクションにつけたい名前。 |
例 [#example]
HttpClient myClient = new HttpClient(CrossNewRelicClient.Current.GetHttpMessageHandler());
string interactionId = CrossNewRelicClient.Current.StartInteraction("Getting data from service");
var response = await myClient.GetAsync(new Uri("https://jsonplaceholder.typicode.com/todos/1")); if (response.IsSuccessStatusCode) { var content = await response.Content.ReadAsStringAsync(); } else { Console.WriteLine("Unsuccessful response code"); }
CrossNewRelicClient.Current.EndInteraction(interactionId);