Skip to content
This repository has been archived by the owner on Jun 9, 2023. It is now read-only.

Latest commit

 

History

History
99 lines (62 loc) · 5.52 KB

README.md

File metadata and controls

99 lines (62 loc) · 5.52 KB

New Relic Open Source archived project banner.

Archival Notice

❗Notice: This project has been archived as is and is no longer actively maintained.

New Relic has released an official Xamarin Agent: https://docs.newrelic.com/docs/mobile-monitoring/new-relic-mobile-xamarin/monitor-your-xamarin-application/.

Please use this for monitoring your Xamarin applications.

New Relic Mobile Agent - Xamarin Bindings

Xamarin binding for New Relic mobile agents - iOS https://docs.newrelic.com/docs/mobile-monitoring/new-relic-mobile-ios and Android SDK's https://docs.newrelic.com/docs/mobile-monitoring/new-relic-mobile-android

Installation

The Xamarin binding depends on the mobile SDK's. There is a Makefile under ios and android directories that downloads the SDK's and builds the binding for iOS and Android.

Building and Getting Started for iOS and Android

iOS:

There is a Makefile for iOS that you can use (make) to build the NewRelicXamarin.iOS.dll that can be included in your Xamarin project. make will download a specific version of iOS SDK for New Relic Mobile, unzip the agent zip file and use it to build NewRelicXamarin.iOS.dll.

After the build is succesfull you need to add the NewRelicXamarin.iOS.dll file as a reference to your project. Make sure you add it in the iOS section.

Alternatively, you could use this project inside the Xamarian project and reference it.

  1. The Makefile uses Microsoft's build tool, msbuild (as xbuild is getting deprecated and replaced by msbuild). You can replace it with xbuild (Xamarin's build tool) if you are on older version of Xamarin.

If you are still using xbuild, replace MONOXBUILD=/Library/Frameworks/Mono.framework/Commands/msbuild with MONOXBUILD=/Library/Frameworks/Mono.framework/Commands/xbuild

  1. Add the Newrelic license key and start up command in your Xamarin code after you reference this library.

Open AppDelegate.cs and add the following to the top of the file:

using NewRelicXamarin;

Next, inside the class AppDelegate you need to add the following to the FinishedLaunching function:

NRLogger.SetLogLevels((uint)NRLogLevels.All);
NewRelicXamarin.NewRelic.StartWithApplicationToken("new_relic_license_key");

Make sure you replace the new_relic_license_key with your own. You can find your own license key by creating a Mobile app within the New Relic UI. Go to Mobile > Add a new app > Choose your platform > Give your App a name > Your license key is now visible lower down the page.

  1. Launch the application and check the New Relic UI for instrumentation data. It can take a couple of minutes before it's visible.

Android:

  1. There is a Makefile for Android that you can use (make) to build the NewRelicXamarin.Android.dll that can be included in your Xamarin project. make will:

     a. Download a specific version of Android SDK for New Relic Mobile
    
     b. Unzip the agent zip file and use it to build NewRelicXamarin.Android.dll
    

After the build is succesfull you need to add the NewRelicXamarin.Android.dll file as a reference to your project. Make sure you add it in the Android section.

  1. Add the Newrelic license key and start up command in your Xamarin code after you reference this library.

In the MainActivity class or equivalent

var config = new NewRelicXamarin.Android.AgentConfiguration();
//config.ReportCrashes = true;
//config.ReportHandledExceptions = true;
//var log = new NewRelicXamarin.Android.Logging.DefaultAgentLog();
config.ApplicationToken = "new_relic_license_key";
NewRelicXamarin.Android.AndroidAgentImpl.Init(this, config);
NewRelicXamarin.Android.Agent.Start();

//Alternatively, you can also start the agent with higher log level (for debugging)
using NewRelicXamarin.Android;

var config = new NewRelicXamarin.Android.AgentConfiguration();
config.ReportCrashes = true;
config.ApplicationToken = "new_relic_license_key";

var newRelic = NewRelic
.WithApplicationToken("new_relic_license_key")
.WithLoggingEnabled(true).WithLogLevel(6);
AndroidAgentImpl.Init(this, config);

Make sure you replace the new_relic_license_key with your own. You can find your own license key by creating a Mobile app within the New Relic UI. Go to Mobile > Add a new app > Choose your platform > Give your App a name > Your license key is now visible lower down the page.

  1. Launch the application and check the New Relic UI for instrumentation data. It can take a couple of minutes before it's visible.

Contributing

We encourage your contributions to improve the New Relic Xamarin Binding! Keep in mind when you submit your pull request, you'll need to sign the CLA via the click-through using CLA-Assistant. You only have to sign the CLA one time per project. If you have any questions, or to execute our corporate CLA, required if your contribution is on behalf of a company, please drop us an email at opensource@newrelic.com.

License

newrelic-xamarin-binding is licensed under the Apache 2.0 License.