Instrument non-IIS apps

By default, the New Relic .NET agent instruments IIS-hosted ASP.NET applications. In some cases, you can also instrument other (non-IIS) .NET applications, such as standalone Windows Communication Foundation (WCF) services, console apps, and other Windows services, provided they meet New Relic's requirements.

Requirements

The .NET agent depends on HttpContext objects being instantiated to properly instrument and report on web transactions. These objects are created and populated as part of the ASP.NET HTTP pipeline, but they may not be created in other environments. For those environments, custom transactions must be created. Additionally, database queries, external calls, and custom instrumented methods must be called within a custom transaction in order for the agent to collect these metrics.

New Relic's harvest cycle is 60 seconds. If the non-IIS app does not run for a minimum of 60 seconds, you will need to add the sendDataOnExit and sendDataOnExitThreshold service elements to your newrelic.config to ensure that New Relic collects and receives your metrics properly. Make sure to set your sendDataOnExitThreshold value to less time than the process takes.

Enable instrumentation

To enable instrumentation of custom applications:

  1. If you are running any IIS-hosted applications, stop IIS.
  2. From the New Relic menu bar, select (your account name) > Account settings.
  3. Download the .NET 64-bit or .NET 32-bit installer, as appropriate for your Windows version.
  4. Run the installer to enable the Instrument All .NET Applications feature:
    New installation

    If you have not installed the .NET agent before:

    1. When prompted, enter your New Relic license key.
    2. From the Custom Setup screen, enable the Instrument All .NET Applications option.
    3. Change the default application name to a meaningful name.
    4. Specify the app you want to instrument.
    5. If you are running any IIS-hosted applications, restart IIS.
    6. Restart your application.
    Existing installation

    If you have already installed the .NET agent:

    1. Select the Change option.
    2. From the Custom Setup screen, enable the Instrument All .NET Applications option.
    3. Specify the app you want to instrument and make sure you have set the default application name to a meaningful name.
    4. If you are running any IIS-hosted applications, restart IIS.
    5. Restart your application.
dotnet-no-apps-dashboard-download

Applications > (apps list): If your custom (non-IIS) .NET applications do not appear in your New Relic APM's Applications list, make sure you have enabled the installer's Instrument All .NET Applications feature, and then define your app in your app.config file or your newrelic.config file.

Define target applications

After enabling instrumentation for your custom app, tell the agent which processes to instrument. You can define this in one of two places:

Enable in the app's config file

In the config file, add a new appSetting with a key named NewRelic.AgentEnabled and a value of true. For example, if the application name is DataServices.exe, you would edit DataServices.exe.config to:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <appSettings>
    <add key="NewRelic.AgentEnabled" value="true" />
    <add key="NewRelic.AppName" value="DataServices" />
  </appSettings>
Enable in newrelic.config

In the newrelic.config configuration file, add an instrumentation element with a child application element for each application. In the instrumentation element, provide the base file name, with extension, you would like to instrument. (for example, <application name="DataServices.exe" />). Here's an example:

<instrumentation>
    <applications>
      <application name="BusinessLogicServices.exe" />
      <application name="DataServices.exe" />
    </applications>
</instrumentation>

This procedure does not name your application. It only declares that the process should be monitored by the .NET agent. The next step is to name your application.

Define custom transactions

Once the agent is targeting your application, you'll need to define at least one custom transaction in order for data from your application to begin reporting to your New Relic account.

The .NET agent depends on HttpContext objects being instantiated to properly instrument and report on web transactions. Since these objects do not typically exist in non-IIS applications, the agent does not have a built-in definition of what defines the scope of a transaction in these apps.

Custom transactions define the scope of a transaction so that the agent is able to accurately report on the important parts of your application. Metrics created outside of a transaction are not recorded in your New Relic account.

For more help

Additional documentation resources include:

Join the discussion about .NET monitoring in the New Relic Online Technical Community! The Technical Community is a public platform to discuss and troubleshoot your New Relic toolset.

If you need additional help, get support at support.newrelic.com.