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

Disable instrumentation for AspNetCore.SignalR

feature-idea

#1

.NET Agent Question Template

Troubleshooting

  • Describe what you are seeing:
    We have moved from using using “ASP.NET SignalR” to “ASP.NET Core SignalR”. Previously we were able to ignore all transactions using an extension found in other threads: <?xml version="1.0" encoding="utf-8"?>

This approach does not seem to work for: Microsoft.AspNetCore.SignalR;
In ASPNetCore Signalr, “PersistentConnection” no longer even exists

I tried using “NewRelic.Api.Agent.NewRelic.IgnoreTransaction();” in OnConnectedAsync. It does seem to ignore many of the transactions, but not all.
There still are some that are messing up our stats:

I think I need an xml extension approach since it seems to just live in middleware code:

This may be helpful…
2019-06-04 20:48:32,477 NewRelic DEBUG: TransactionTraceData: [1559681227729,{},{},[0.0,45714.262,“ROOT”,{},[[0.0,45714.262,“Transaction”,{},[[0.056600000000000004,45714.240900000004,“Middleware Pipeline”,{“exclusive_duration_millis”:45713.1448},[[1.5315,2.1519,“Datastore/operation/Redis/EXISTS”,{“host”:“redis-dev-1.hrjxot.0001.usw2.cache.amazonaws.com”,“port_path_or_id”:“6379”,“database_name”:“unknown”,“exclusive_duration_millis”:0.62040000000000006},[],“StackExchange.Redis.ConnectionMultiplexer”,“ExecuteSyncImpl”],[2.2036000000000002,2.6227,“Datastore/operation/Redis/HEXISTS”,{“host”:“redis-dev-1.h…amazonaws.com”,“port_path_or_id”:“6379”,“database_name”:“unknown”,“exclusive_duration_millis”:0.41910000000000003},[],“StackExchange.Redis.ConnectionMultiplexer”,“ExecuteSyncImpl”]],“NewRelic.Providers.Wrapper.AspNetCore.WrapPipelineMiddleware”,“Invoke”]],“NewRelic.Providers.Wrapper.AspNetCore.WrapPipelineMiddleware”,“Invoke”]],“NewRelic.Providers.Wrapper.AspNetCore.WrapPipelineMiddleware”,“Invoke”],{“agentAttributes”:{“request.uri”:"/updatesHub",“response.status”:“200”,“host.displayName”:“EC2RRRZ-RQ211AC”},“userAttributes”:{},“intrinsics”:{“totalTime”:45.7141843,“trip_id”:“7DC8C7198EC2E5B7”}}]

Thanks for your help!


#2

Hi @devops51,

To effectively use XML instrumentation, the first part is to determine the names of the assembly, class, and method. The best way to do that is Building Custom Instrumentation Tracer Factories From .NET Agent Log Files, following the directions up to Putting it all together. With those names found, they can be used to Ignore a transaction using XML instrumentation.

Please let me know of any trouble with that, and when you’ve found the exact names, please share here for future reference for the community.


#3

Thank you very much for your link @bkucey and sorry about the delay. I did not see your response until now.
I was able to find a couple methods in the stack trace I could use to cause the whole transaction to get ignored.
This is what I’m currently using:

<tracerFactory name="NewRelic.Agent.Core.Tracer.Factories.IgnoreTransactionTracerFactory">
        <match assemblyName="Microsoft.AspNetCore.SignalR.Core" className="Microsoft.AspNetCore.SignalR.HubConnectionHandler`1">
            <exactMethodMatcher methodName="OnConnectedAsync"/>
        </match>
 </tracerFactory>

I also had success with:

<tracerFactory name="NewRelic.Agent.Core.Tracer.Factories.IgnoreTransactionTracerFactory">
        <match assemblyName="Microsoft.AspNetCore.SignalR.Core" className="Microsoft.AspNetCore.SignalR.HubConnectionContext">
            <exactMethodMatcher methodName="HandshakeAsync"/>
        </match>
</tracerFactory>

I’m assuming/hoping these are good class/methods to use since they should not get called by any valid web transactions that use the signalr hub for sending messages to clients.

One more question though @bkucey, that I can’t seem to figure out a way to accomplish.
Can I generally “ignore” with this method, but then add [Transaction] to the specific methods in my class (after this Ignore has already kicked in)?

To summarize Signalr will essentially make what looks to NewRelic like a single Transaction (long running web socket connection). I want to ignore this and only instrument the actual “methods” that are called. This would be huge if I could accomplish this as I currently have no visibility in to these.

Thanks for your help!


#4

Hi @devops51,

No problem, and thanks for sharing!

I can definitely see the value of having transactions of the handling methods, rather than one long transaction of a web socket connection of arbitrary session time. I talked this over with an agent developer, and currently, when a transaction is ignored, the transaction will still exist. The use of [Transaction] to Create a new transaction will then follow:

When used inside a previously started transaction, this will be treated as a [Trace] attribute.

and that new segment will be added to the current, ignored transaction.

For that reason, this functionality is currently a feature idea. The community moderators will add a feature idea poll here and get this idea to the product team. Please let me know of any questions.