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

Custom Insturmentation of .Net Framework Console App

api

#1

Hi. I am trying to setup a new app to report to New Relic. I have setup the custom instrumentation using the attribute method on a couple of methods in my program. The .Net Agent has been running on this server for a while. It was updated back in November, so it is pretty current. However, this is the first non IIS app that I am trying to setup. I am running on a hosted windows server 2016. No containers. No Azure. I have deployed my app with the required app changes per the documents. Included below are the app and new relic configs. I installed and deployed the NuGet package. I have assigned the necessary permissions to C:\Program Files\New Relic \ .NET Agent.

When running my app, I am not seeing any logs being generated in C:\ProgramData\New Relic \ .NET Agent\Logs for the new app. My application is not showing up in the dashboard.

app.config

<appSettings>
    <add key="NewRelic.AgentEnabled" value="true" />
    <add key="NewRelic.AppName" value="My Redacted Program" />
</appSettings>

newrelic.config

<configuration xmlns="urn:newrelic-config">
  <service licenseKey="*****************************" />
  
  <log level="info" />

  <instrumentation>
    <applications>
      <application name="my.redaceted.program.exe"/>
    </applications>
  </instrumentation>

  <transactionTracer enabled="true" transactionThreshold="apdex_f" stackTraceThreshold="500" recordSql="raw" explainEnabled="true" explainThreshold="500" />
  <datastoreTracer>
    <instanceReporting enabled="true" />
    <queryParameters enabled="true" />
  </datastoreTracer>

  <distributedTracing enabled="false"/>
  <crossApplicationTracer enabled="false" />
  <browserMonitoring autoInstrument="false" />

  <errorCollector enabled="true" />
  <threadProfiling>
    <ignoreMethod>System.Threading.WaitHandle:InternalWaitOne</ignoreMethod>
    <ignoreMethod>System.Threading.WaitHandle:WaitAny</ignoreMethod>
  </threadProfiling>
</configuration>

#2

No New Relic code will run if the environment variables aren’t present for your application when it starts:

https://docs.newrelic.com/docs/agents/net-agent/configuration/net-agent-configuration#net-framework-env-variables

These will be set automatically to the System level if you install the agent with the optional Instrument All feature. You may need to go to appwiz.cpl and modify the install of the agent to add this feature and then restart your application.

You should see a matching newrelic.profiler.XXXX.log with the PID of your my.redaceted.program.exe if the environment variables are picked up regardless of your custom instrumentation. Once at least one transaction has been defined you should then also see an agent log which the connection to the New Relic servers.


#3

Thanks for the reply. I just installed the newest .Net agent and made sure that I ran the Instrument All feature. Now my application showed up in the dashboard. Nothing has been logged yet. I am looking at the logs and got a couple of things that I need to work through. I am assuming that one error caused the other.

2019-01-14 18:48:25,800 NewRelic ERROR: An error occurred parsing newrelic.config - The element 'errorCollector' in namespace 'urn:newrelic-config' has incomplete content. List of possible elements expected: 'ignoreErrors' in namespace 'urn:newrelic-config'.
2019-01-14 18:48:25,800 NewRelic ERROR: An error occurred parsing newrelic.config - The element 'configuration' in namespace 'urn:newrelic-config' has incomplete content. List of possible elements expected: 'application' in namespace 'urn:newrelic-config'.

#4

If it is showing up in your dashboard but no data is appearing then the issue is likely lack of defined transactions. Out of the box only Http requests/responses are wrapped as transactions. To define transactions you’ll need custom instrumentation: