/// <summary>
        /// Start polling and saving perf counters. Period is in sec
        /// </summary>
        /// <param name="pollPeriod_sec">Poll period, ms</param>
        public void Start(HttpConfiguration httpConfiguration, int pollPeriod_sec)
        {
            PerfMonitorBase.Start(pollPeriod_sec);

            cfg = httpConfiguration;

            httpConfiguration.Filters.Add(new ExceptionCounterFilter(this.PerfMonitorBase));

            httpConfiguration.MessageHandlers.Add(new RequestPerfMonitorMessageHandler(this.PerfMonitorBase));

            //httpConfiguration.Services.Add(typeof(PerfMonitorForWebApi), this);

            httpConfiguration.Properties[EnumKeyNames.PerfMonitorLib.ToString()] = this;

            //httpConfiguration.MapHttpAttributeRoutes();
        }
Example #2
0
        /// <summary>
        /// Start polling and saving perf counters. Period is in ms
        /// </summary>
        /// <param name="pollPeriod_sec">Poll period, ms</param>
        public void Start(HttpApplication app, RouteCollection routes, int pollPeriod_sec)
        {
            PerfMonitorBase.Start(pollPeriod_sec);

            app.Application[EnumKeyNames.PerfMonitorLib.ToString()] = this;

            if (Configuration.EnablePerfApi)
            {
                var r = routes.MapRoute(
                    name: "PerfMonitor",
                    url: "api/perfcounters/",
                    defaults: new { controller = "PerfCounters", action = "Get" }
                    );
                routes.Remove(r);
                routes.Insert(0, r);
            }

            GlobalFilters.Filters.Add(new PerfMonitoringFilter(PerfMonitorBase));
            GlobalFilters.Filters.Add(new ExceptionCounterFilter(PerfMonitorBase));
        }