• /
  • EnglishEspañolFrançais日本語한국어Português
  • Se connecterDémarrer

Cette traduction automatique est fournie pour votre commodité.

En cas d'incohérence entre la version anglaise et la version traduite, la version anglaise prévaudra. Veuillez visiter cette page pour plus d'informations.

Créer un problème

Démarrer une interaction

Syntaxe

Java

NewRelic.startInteraction(string $interactionName)

Kotlin [#kotlin]

NewRelic.startInteraction(actionName: String)

Description [#description]

Créez une interaction pour instrumenter une méthode dans le code de votre application Android .

Pour nommer une interaction qui existe déjà et qui est déjà suivie, voir setInteractionName().

Paramètres [#parameters]

paramètres

Type

Description

$interactionName

string

Requis. Le nom que vous souhaitez donner à l'interaction.

Valeurs de retour [#return-values]

Renvoie un numéro d'ID d'interaction qui peut être utilisé pour mettre fin à l'interaction à un certain moment.

Exemple [#example]

Voici un exemple de démarrage du suivi d'une interaction nommée 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 [#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)
}
}
}
...

Syntaxe

Objectif-C

+ (NSString*) startInteractionWithName:(NSString*)interactionName;

Swift [#swift]

NewRelic.startInteraction(string: "myInteractionName")

Description [#description]

Cette méthode démarrera une trace d’interaction en utilisant interactionName comme nom. L' interaction enregistrera toutes les méthodes instrumentées jusqu'à ce qu'un délai d'attente se produise ou que stopCurrentInteraction soit appelé.

Pour nommer une interaction qui existe déjà et qui est déjà suivie, voir setInteractionName().

Conseil

Si vous utilisez ces méthodes, l'interaction instrumentée n'apparaîtra pas sur la page d'interaction , mais elles peuvent toujours être trouvées avec une requête NRQL , telle que :

SELECT name FROM Mobile SINCE 7 DAYS AGO

Paramètres [#parameters]

paramètres

Type

Description

interactionName

string

Requis. Le nom que vous souhaitez donner à l'interaction.

Valeurs de retour [#return-values]

Si startInteractionWithName est appelé, la valeur de retour est un interactionIdentifier qui doit être passé à stopCurrentInteraction . Mais il n'est pas nécessaire d'appeler stopCurrentInteraction après avoir appelé start car startInteractionWithName finira par se terminer intelligemment.

Exemples [#examples][#examples]

Objective-C [#obj-c]

NSString *identifier = [NewRelic startInteractionWithName: @"myInteractionName"];
[NewRelic stopCurrentInteraction: identifier];

Swift [#swift]

let identifier = NewRelic.startInteraction(withName: "myInteractionName")
NewRelic.stopCurrentInteraction(identifier)

Syntaxe

startInteraction(options: { value: string; }) => Promise<{ value: string; }>

Description [#description]

Suivre une méthode en tant qu'interaction.

Paramètres [#parameters]

paramètres

Type

Description

options

{ value: string; }

Requis. Le nom que vous souhaitez donner à l'interaction.

Exemple [#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);
});
};

Syntaxe

startInteraction(interactionName: string, cb?: function): Promise<InteractionId>;

Description [#description]

Suivre une méthode en tant qu'interaction.

Paramètres [#parameters]

paramètres

Type

Description

Interactioname

string

Requis. Le nom que vous souhaitez donner à l'interaction.

Exemple [#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);
});
}

Syntaxe

StartInteraction(string interactionName): string;

Description [#description]

Suivre une méthode en tant qu'interaction.

Paramètres [#parameters]

paramètres

Type

Description

options

{ value: string; }

Requis. Le nom que vous souhaitez donner à l'interaction.

Exemple [#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);

Syntaxe

startInteraction(String actionName);

Description [#description]

Suivre une méthode en tant qu'interaction.

Paramètres [#parameters]

paramètres

Type

Description

string actionName

string

Requis. Le nom que vous souhaitez donner à l'interaction.

Exemple [#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);
}

Syntaxe

startInteraction(interactionName: string): Promise<InteractionId>;

Description [#description]

Suivre une méthode en tant qu'interaction.

Paramètres [#parameters]

paramètres

Type

Description

interactionName

string

Requis. Le nom que vous souhaitez donner à l'interaction.

Exemple [#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);
});;
};

Syntaxe

StartInteractionWithName(string interactionName): string;

Description [#description]

Suivre une méthode en tant qu'interaction.

Paramètres [#parameters]

paramètres

Type

Description

interactionName

string

Requis. Le nom que vous souhaitez donner à l'interaction.

Exemple [#example]

string interActionId = NewRelicAgent.StartInteractionWithName("Unity InterAction Example");
for(int i = 0; i < 4; i++)
{
Thread.Sleep(1000);
}
NewRelicAgent.StopCurrentInteraction(interActionId);

Syntaxe

startInterAction(FString interActionName):FString;

Description [#description]

Suivre une méthode en tant qu'interaction.

Paramètres [#parameters]

paramètres

Type

Description

interActionName

FString

Requis. Le nom que vous souhaitez donner à l'interaction.

Exemple [#example]

#include "NewRelicBPLibrary.h"
FString id = UNewRelicBPLibrary::startInterAction("test Unreal InterAction");
FPlatformProcess::Sleep(6.0);
UNewRelicBPLibrary::endInterAction(id);
Screenshot of the Unreal Engine Plugin Start InterAction

Syntaxe

StartInteraction(string interactionName): string;

Description [#description]

Suivre une méthode en tant qu'interaction.

Paramètres [#parameters]

paramètres

Type

Description

interactionName

string

Requis. Le nom que vous souhaitez donner à l'interaction.

Exemple [#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);
Droits d'auteur © 2025 New Relic Inc.

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