[.NET] Track compile duration separately for each class methods in a .cs file in .NET

I have created the .XML file with the instrumentation but i m unable to get the required data. the log file is showing all unwanted data without the details for the methods that i have specified in the newrelic.config file. Any help is appreciated.

Below is the content of the .xml file

<?xml version="1.0" encoding="utf-8"?>
<extension xmlns="urn:newrelic-extension">
  <instrumentation>
    <!-- These methods appear in the transactions breakdown table and in transaction traces -->
    <tracerFactory metricName="Custom/Test1"> 
       <match assemblyName="DXAV" className="DXAV.Views.UserControls.Site.UCSiteDetails2"> 
			<exactMethodMatcher methodName="TabCallBackPanel_Callback" /> 
       </match>
    </tracerFactory>
	<tracerFactory metricName="Custom/Test2"> 
       <match assemblyName="DXAV" className="DXAV.Views.UserControls.Site.UCSiteDetails2"> 
			<exactMethodMatcher methodName="TabDetailsUpdate" /> 
       </match>
    </tracerFactory>
	<tracerFactory metricName="Custom/Test3"> 
       <match assemblyName="DXAV" className="DXAV.Views.UserControls.Site.UCSiteDetails2"> 
			<exactMethodMatcher methodName="BindSiteDetails" /> 
       </match>
	</tracerFactory>   
  </instrumentation>
</extension>

Hello @metering.itsupport,

My name is Brian and I’ll be happy to help you with your custom instrumentation XML. If you look in your logs can you see the agent latching onto the methods being called in your custom XML? For example: TabCallBackPanel_Callback() would look something like this:

[Info ] [DATE_STRING] Instrumenting method: ... DXAV.Views.UserControls.Site.UCSiteDetails2.TabCallBackPanel_Callback()

If so, I think your issue is with the <tracerFactory> tag in your XML. Reference this doc:

  • Adding additional methods must include the "NewRelic.Agent.Core.Tracer.Factories.BackgroundThreadTracerFactory" attribute to be defined as a transaction. Tags without this attribute will add detail to existing transactions only.

If I’m correct, your methods are not in the context of a transaction, so the agent is seeing them, but not reporting them. Without name="NewRelic.Agent.Core.Tracer.Factories.BackgroundThreadTracerFactory" the agent won’t create a transaction.

Try it like this and let us know if you continue to have problems:

<?xml version="1.0" encoding="utf-8"?>
<extension xmlns="urn:newrelic-extension">
  <instrumentation>
    <!-- These methods appear in the transactions breakdown table and in transaction traces -->
    <tracerFactory name="NewRelic.Agent.Core.Tracer.Factories.BackgroundThreadTracerFactory" metricName="Custom/Test1">
      <match assemblyName="DXAV" className="DXAV.Views.UserControls.Site.UCSiteDetails2">
        <exactMethodMatcher methodName="TabCallBackPanel_Callback" />
      </match>
    </tracerFactory>
    <tracerFactory name="NewRelic.Agent.Core.Tracer.Factories.BackgroundThreadTracerFactory" metricName="Custom/Test2">
      <match assemblyName="DXAV" className="DXAV.Views.UserControls.Site.UCSiteDetails2">
        <exactMethodMatcher methodName="TabDetailsUpdate" />
      </match>
    </tracerFactory>
    <tracerFactory name="NewRelic.Agent.Core.Tracer.Factories.BackgroundThreadTracerFactory" metricName="Custom/Test3">
      <match assemblyName="DXAV" className="DXAV.Views.UserControls.Site.UCSiteDetails2">
        <exactMethodMatcher methodName="BindSiteDetails" />
      </match>
    </tracerFactory>
  </instrumentation>
</extension>

I hope this helps!

–Brian

1 Like