Syntax
Java
NewRelic.startInteraction(string $interactionName)
Kotlin
NewRelic.startInteraction(actionName: String)
Description
Create an interaction to instrument a method in your Android app code.
To name an interaction that already exists and is already being tracked, see setInteractionName()
.
Parameters
Parameter | Type | Description |
---|---|---|
|
| Required. The name you want to give to the interaction. |
Return values
Returns an interaction ID number which can be used for ending the interaction at a certain point.
Example
Here's an example of starting to track an interaction named RefreshContacts
:
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) } } } ...
Syntax
Objective-c
+ (NSString*) startInteractionWithName:(NSString*)interactionName;
Swift
NewRelic.startInteraction(string: "myInteractionName")
Description
This method will start an interaction trace using interactionName
as the name. The interaction will record all instrumented methods until a timeout occurs or stopCurrentInteraction
is called.
To name an interaction that already exists and is already being tracked, see setInteractionName()
.
Sugerencia
If you use these methods, the instrumented interactions will not show up on the Interactions page, but they can be still found with a NRQL query, such as:
SELECT name FROM Mobile SINCE 7 DAYS AGO
Parameters
Parameter | Type | Description |
---|---|---|
|
| Required. The name you want to give to the interaction. |
Return values
If startInteractionWithName
is called, the return value is an interactionIdentifier
that must be passed to stopCurrentInteraction
. But it's not required to call stopCurrentInteraction
after calling start because startInteractionWithName
will eventually complete intelligently.
Examples
Objective-C
NSString *identifier = [NewRelic startInteractionWithName: @"myInteractionName"];[NewRelic stopCurrentInteraction: identifier];
Swift
let identifier = NewRelic.startInteraction(withName: "myInteractionName")NewRelic.stopCurrentInteraction(identifier)
Syntax
startInteraction(options: { value: string; }) => Promise<{ value: string; }>
Description
Track a method as an interaction.
Parameters
Parameter | Type | Description |
---|---|---|
|
| Required. The name you want to give to the interaction. |
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); });};
Syntax
startInteraction(interactionName: string, cb?: function): Promise<InteractionId>;
Description
Track a method as an interaction.
Parameters
Parameter | Type | Description |
---|---|---|
|
| Required. The name you want to give to the interaction. |
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); });}
Syntax
StartInteraction(string interactionName): string;
Description
Track a method as an interaction.
Parameters
Parameter | Type | Description |
---|---|---|
|
| Required. The name you want to give to the interaction. |
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);
Syntax
startInteraction(String actionName);
Description
Track a method as an interaction.
Parameters
Parameter | Type | Description |
---|---|---|
|
| Required. The name you want to give to the interaction. |
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);}
Syntax
startInteraction(interactionName: string): Promise<InteractionId>;
Description
Track a method as an interaction.
Parameters
Parameter | Type | Description |
---|---|---|
|
| Required. The name you want to give to the interaction. |
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); });;};
Syntax
StartInteractionWithName(string interactionName): string;
Description
Track a method as an interaction.
Parameters
Parameter | Type | Description |
---|---|---|
|
| Required. The name you want to give to the interaction. |
Example
string interActionId = NewRelicAgent.StartInteractionWithName("Unity InterAction Example");
for(int i = 0; i < 4; i++){ Thread.Sleep(1000);}
NewRelicAgent.StopCurrentInteraction(interActionId);
Syntax
startInterAction(FString interActionName):FString;
Description
Track a method as an interaction.
Parameters
Parameter | Type | Description |
---|---|---|
|
| Required. The name you want to give to the interaction. |
Example
#include "NewRelicBPLibrary.h"
FString id = UNewRelicBPLibrary::startInterAction("test Unreal InterAction");
FPlatformProcess::Sleep(6.0);
UNewRelicBPLibrary::endInterAction(id);
Syntax
StartInteraction(string interactionName): string;
Description
Track a method as an interaction.
Parameters
Parameter | Type | Description |
---|---|---|
|
| Required. The name you want to give to the interaction. |
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);