analytics in C#
I am using Microsoft Enterprise library logging in c# to log th开发者_如何学Goe events in SQL DB and I use this records for analytics purpose.
is there any better way for analytics in c#. for example "Microsoft StreamInsight from SQL Server 2008".
another way is embedding Javascript in HTML code which google analytics is using. But in this way I should send all my logging data to the logging sever in HTTP post.
Thanks
One thing I found interesting is that if you want to track your own users is to implement an action filter.
If you are using ASP.NET MVC 3, you just need to register this filter as a global filter and you will be able to record every access to an action in each controllers.
The whole HttpContext is available in those methods.
public class TrackerFilterAttribute : ActionFilterAttribute
{
public TrackerFilterAttribute()
{
}
public override void OnActionExecuting(ActionExecutingContext filterContext)
{
base.OnActionExecuting(filterContext);
//TODO: Do my tracking here.
}
}
And this can be invoked in the following way:
public class MvcApplication : System.Web.HttpApplication
{
public static void RegisterGlobalFilters(GlobalFilterCollection filters)
{
filters.Add(new HandleErrorAttribute());
filters.Add(new TrackerFilterAttribute());
}
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults
);
}
protected void Application_Start()
{
AreaRegistration.RegisterAllAreas();
RegisterGlobalFilters(GlobalFilters.Filters);
RegisterRoutes(RouteTable.Routes);
}
}
Analytics is a server based tool - you don't normally do it in C# as it involves massive amounts of data, which server utilities are much better at.
You can use StreamInsight to perform analytics on your web site. You can have custom code in your pages that sends messages to SI as well as collect perfmon counters from the web servers that you are interested in. You could then analyze this information in real time to provide pro-active monitoring of performance and load. That said, StreamInsight is for real-time analytics only. For long-term analytics, you'd want to utilize another tool.
精彩评论