AppDynamics Xamarin SDK
4.5.2.871 (Nuget: 45.2.871)
Real user monitoring for your Xamarin app.
|
The AppDynamics Xamarin SDK is a package that allows you to monitor the performance and activities of a Xamarin.Android, Xamarin.iOS and/or a Xamarin.Forms app.
The SDK includes APIs to instrument specific methods in your own code, to measure durations of operations in your application (like application start up, for example), or to report an arbitrary metric.
NOTE: The SDK only targets Android and iOS deployments. All other targets will build and run. However, at runtime, the SDK calls are "stubbed" out and will actually do no work.
Add the Nuget Package to your project. It is called AppDynamics.Agent.<version>.nupkg
.
We use the namespace AppDynamics.Agent
. In order to use the abbreviated form of the methods below you should add a using
directive:
You must configure the agent and intialize it. The code to initialize is the same for all target platforms:
Note: See the AppDynamics.Agent.AgentConfiguration
object for more configuration options
Where to best place this code snippet depends on the desgin of the application. It is usually best to place it as early as possible in the runtime lifecycle.
In the AppDelegate.cs
file under the class AppDelegate
in the method:
You may even consider placing it in the Main.cs
int the method:
before the AppDelegate
is called.
In the MainActivity.cs
file under the class MainActivity
in the method:
Although these are usually on by default, it is important to make sure that the following "Required Permissions" are enabled in the Properties/AndroidManifest.xml
file:
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
The AppDynamics Xamarin SDK can be used to instrument methods in your own code. When you do this, you'll be able to see how often the instrumented method is invoked, and how long it takes to run. To do this, add a call at the beginning and end of the method you'd like to instrument:
Sometimes you want to time an event in your application that spans multiple methods. You can do this by calling the SDK when the event starts, and then again when it ends. For example, to track the time a user spends viewing a screen, the instrumentation looks like:
If you'd like to report some other type of data, you can use a metric. The only requirement is that the metric value must be a long integer. Reporting a metric looks like this:
You can report a Network Request by reporting via the SDK by using the AppDynamics.Agent.HTTPRequestTracker
.
Example: