Your data. Anywhere you go.

New Relic for iOS or Android


Download on the App Store    Android App on Google play


New Relic Insights App for iOS


Download on the App Store


Learn more

Close icon

App name with IIS Express

iis
appname

#1

I’m using .NET Framework 4.5 with New Relic .NET Agent v8.16.567.0. The app is running in IIS Express on a PC running Windows 10 Pro.

I am seeing data when IIS Express runs (permalink). However, it is not picking up the app name in newrelic.config correctly.

I have a newrelic.config file in the same location as the Web.config file. The newrelic.config file looks like this (I’ve redacted the license key):

<?xml version="1.0"?>
<configuration xmlns="urn:newrelic-config" agentEnabled="true">
 <service licenseKey="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" />
 <application>
   <name>TIS.WCF - 2</name>
   <name>Developer Local</name>
 </application>
 <log level="info" />
 <transactionTracer enabled="true" transactionThreshold="apdex_f" stackTraceThreshold="500" recordSql="obfuscated" explainEnabled="false" explainThreshold="500" />
 <crossApplicationTracer enabled="true" />
 <errorCollector enabled="true">
   <ignoreErrors>
     <exception>System.IO.FileNotFoundException</exception>
     <exception>System.Threading.ThreadAbortException</exception>
   </ignoreErrors>
   <ignoreStatusCodes>
     <code>401</code>
     <code>404</code>
   </ignoreStatusCodes>
 </errorCollector>
 <browserMonitoring autoInstrument="true" />
 <threadProfiling>
   <ignoreMethod>System.Threading.WaitHandle:InternalWaitOne</ignoreMethod>
   <ignoreMethod>System.Threading.WaitHandle:WaitAny</ignoreMethod>
 </threadProfiling>

In the agent logs, I see these lines:

2019-06-13 19:28:34,713 NewRelic INFO: Configuration file found in app/web root directory:     C:\TISProjects\Main\Source\TIS.WCF.Services\Source\TIS.WCF\TIS.WCF\newrelic.config
[...]
2019-06-13 19:28:35,992 NewRelic INFO: Reading configuration from "C:\TISProjects\Main\Source\TIS.WCF.Services\Source\TIS.WCF\TIS.WCF\newrelic.config"
2019-06-13 19:28:36,004 NewRelic INFO: Loading extensions of type 
[... cut lines about instrumentation ...]
2019-06-13 19:28:41,948 NewRelic INFO: The New Relic .NET Agent v8.16.567.0 started (pid 8900) on app domain '/'
2019-06-13 19:28:42,435 NewRelic INFO: Application name from IISEXPRESS_SITENAME Environment Variable.
2019-06-13 19:28:42,445 NewRelic INFO: Your New Relic Application Name(s): TIS.WCF

I am not sure what is happening here. I know I can set a name using environmental variables, and also that environmental variables have the highest precedence. But using environmental variables, the variable name should be NEW_RELIC_APP_NAME, not IISEXPRESS_SITENAME.

Unlike the full version of IIS, I have yet to find any way to control environmental variables in IIS Express. EDITED TO ADD: At least not if I’m using .NET Framework instead of .NET Core. I’m also not sure why the wrong environmental variable is apparently overriding my setting in the newrelic.config file.

What am I missing here?


#2

Hi @charlie.kilian - Although I haven’t tried this myself, you need the applicationPools configuration elements for monitoring an IIS based applications. In your case you would need:

<applicationPools>
  <defaultBehavior instrument="true"/>
</applicationPools>

Someone else may be able to provide assistance on the environment variables.


#3

I think instrumentation is succeeding, because I am getting data reported. It just isn’t being reported under the correct App Name.

My question, boiled down, is: How do I set the App Name under IIS Express? It seems to be using a different environmental variable (IISEXPRESS_SITENAME) than is documented (NEW_RELIC_APP_NAME). Additionally, IISEXPRESS_SITENAME is set by IIS Express itself, and I can’t find any way to control it.

Ideally, I would be setting the site name via the newrelic.config file. I thought this would be as simple as not setting the NEW_RELIC_APP_NAME environmental variable in IIS Express. However, if I’m correctly understanding what I’m seeing here, the New Relic agent seems to use a different environmental variable that is always set in IIS Express. Furthermore, that environmental variable overrides the value set in newrelic.config.

Is this what is happening? Is there any way to get the New Relic .NET Agent to ignore the IISEXPRESS_SITENAME environmental variable? If not, the IISEXPRESS_SITENAME environmental variable is essentially the only way of configuring the site name in IIS Express, because it will always override all other values by virtue of it coming from an environmental variable.


#4

I have also been investigating whether there is a way of setting the site name in IIS Express.

I have found that I can set the site name by editing the applicationhost.config file for the site (which is found in $(solutionDir)\.vs{projectName}\config\applicationhost.config in Visual Studio 2019; see here for the location in other versions, and here for a caveat).

However, this presents another problem. The files in this folder aren’t committed to source control. So if I want to set the New Relic App Name via the IIS Express site name, developers can’t just check out the site and have it set to, for example, “TIS.WCF, Development” to have anything logged in a development environment automatically roll up under the “Development” category in the Applications list of New Relic APM.

Ultimately, this is my goal:

  1. Be able to distinguish between development, test, and production environments in the New Relic APM dashboards; and
  2. Do it in a way that developers can check out fresh from source control and have the app report to New Relic correctly without needing to make extra configuration changes on their end. Because it is inevitable that they will forget.

Perhaps there is a better way to accomplish #1 that doesn’t require me to set the site name? I’m open to other options, too.


#5

@charlie.kilian -

So it’s true that IISEXPRESS_SITENAME takes precedence over NEW_RELIC_APP_NAME and naming in newrelic.config (I’m not sure why that decision was made).

However, it appears the name in web.config takes precedence over those items just mentioned.

Is it possible for you to add the following to your web.config file:

<appSettings>
    <add key="NewRelic.AppName" value="TIS.WCF - 2,Developer Local"/>
</appSettings>

#6

This works.

So if I’m understanding things correctly, there is a curious situation where:

NEW_RELIC_APP_NAME > Web.config > applocal newrelic.config

But also

IISEXPRESS_SITENAME > NEW_RELIC_APP_NAME
IISEXPRESS_SITENAME > applocal newrelic.config
Web.config > IISEXPRESS_SITENAME

Which is to say, IISEXPRESS_SITENAME doesn’t fit neatly into the precedence hierarchy.

Is that correct?


#7

@charlie.kilian

This looks to be the complete precedence hierarchy:

SetApplicationName API > Web.config > IISEXPRESS_SITENAME > NEW_RELIC_APP_NAME > RoleName > newrelic.config > APP_POOL_ID > process name

where:

RoleName is an environment variable in the Azure Cloud Services environment.

APP_POOL_ID is an environment variable set in an IIS worker process.

process name is just the name of the hosting process.

The above relation expresses precedence and also the naming technique that will be attempted if the previous item failed to provide a name. Not all items make sense in all environments.

Phew - I hope that helps.


#8

This is tremendously helpful. Thank you so much for providing it.

I think my confusion has stemmed from the .NET agent configuration page in the documentation. The graphic seems to imply a lower precedence for Web.config than you’ve listed here. Maybe I’m just misreading it.

At any rate, this has helped me solve my problem. I truly appreciate the prompt replies.