How to exclude a specific service from miniprofile

2019-07-24 18:15发布

问题:

I am using miniprofiler to assess performance of my MVC6 application. Everything is working fine but I am looking for an option to exclude (mute) a particular service (requests) from my application.

For example: My application is polling user authentication every second using some polling service. I don't want to include that in my miniprofiler results. Is there a way to exclude it?

Why I want this? I want to exclude this redundant service, so that I can focus on other results which needs more attention. Also, this polling service is filling fast my results-index page.

Thanks for help.

回答1:

There are several ways to do this, when you are initializing MiniProfiler:

Ignore the path

var ignored = MiniProfiler.Settings.IgnoredPaths.ToList();
ignored.Add("/__browserLink/");
ignored.Add("/path/to/ignore");
MiniProfiler.Settings.IgnoredPaths = ignored.ToArray();

Exclude the Type, Assembly or Method

MiniProfiler.Settings.ExcludeType("SessionFactory"); 
MiniProfiler.Settings.ExcludeAssembly("NHibernate"); 
MiniProfiler.Settings.ExcludeMethod("Flush");