Non IIS API doesnt show the Web transactions


I’ve got a non-IIS, owin implemented .net application hosted as a windows service. When i try to configure the agent, in the APM, I only am able to see the database transactions but not any web transactions.

I’ve read in the previous old posts that, the async controllers arent supported yet, but I guess, in the latest version, they too are supported. I’m having the .Net Agent

Please note that we’ve got controllers which are all async.

BTW, in the logs I see the following entry as a WARN

NewRelic WARN: Agent API Error: An error occurred invoking API method “SetTransactionName” - "System.InvalidOperationException: The API method called is only valid from within a transaction. This error can occur if you call the API method from a thread other than the one the transaction started on.


I had a similar warning with NancyFX hosted as a windows service. In this case it was from trying to use NewRelicAgent.SetTransactionName before the agent was actually seeing the transactions in the first place. Ultimately I found Creating XML-based Custom Instrumentation for Non-IIS .NET Applications to be really helpful for walking through the agent instrumentation. The async tracerFactory is working these days, but In my case I had to start the transaction with the BackgroundThreadTracerFactory and then add async tracerFactory details to the base transaction with the DefaultWrapperAsync. Also not always covered in all the docs seems to be that you must have a metricName in the form of category and name (ex;Custom/MyTransaction). I was missing that which caused the transactions to fail which then caused the agent to fail with the same exception you are getting.
I don’t know what OWIN method to hook the transaction off. In Nancy there was a generic HandleRequest that worked well.

1 Like

Thanks so much for sharing your experience @bembree! That’s the stuff that makes a community work! :unicorn:

@ravi.garimella - does this set yo on the right path to solving your problem?

Thanks @bembree and @hross. I was basically looking for something other than custom instrumentation/transactions for my scenario. If i can’t find that, i’ll give the custom one’s a try.

1 Like

I am try for Non IIS application (Nancy, c# (Windows service)) with New Relic but i am not able to see the data. i am sharing the code and configuration below can you please tell me where i am doing wrong.

Module : Before += ctx =>
var routeDescription = ctx.ResolvedRoute.Description;

                NewRelicAgent.SetTransactionName("Custom", string.Format("{0} {1}", routeDescription.Method, routeDescription.Path));               
            catch (Exception ex)
            return null;


<?xml version="1.0"?>

<log level=“info” auditLog=“false” console=“false”
directory=“C:\PROGRAMDATA\New Relic.NET Agent\Logs” fileName=“newrelic.log” /
<application name=“ProviderSearchConsole.exe”
<transactionTracer enabled=“true” transactionThreshold=“apdex_f” stackTraceThreshold=“500” recordSql=“obfuscated” explainEnabled=“true” explainThreshold=“500” /
<crossApplicationTracer enabled=“true” /
<errorCollector enabled=“true”
<browserMonitoring autoInstrument=“true” /


‘’<add key=“NewRelic.AgentEnabled” value=“true”
<add key=“NewRelic.AppName” value=“ProviderSearchConsole”
<add key=“NewRelic.LicenseKey” value= redacted

<extension xmlns=“urn:newrelic-extension”
<match assemblyName=
“Nancy” className=“Nancy.NancyEngine”
<exactMethodMatcher methodName=“HandleRequest” /