107 lines
2.1 KiB
C#
107 lines
2.1 KiB
C#
using Prometheus;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Web;
|
|
using System.Web.Http;
|
|
using System.Web.Mvc;
|
|
using System.Web.Optimization;
|
|
using System.Web.Routing;
|
|
|
|
namespace VECV_WebApi
|
|
{
|
|
// Note: For instructions on enabling IIS6 or IIS7 classic mode,
|
|
// visit http://go.microsoft.com/?LinkId=9394801
|
|
|
|
public class MvcApplication : System.Web.HttpApplication
|
|
{
|
|
|
|
// for grafana
|
|
|
|
/*private static readonly Gauge ServerStatus = Metrics.CreateGauge("app_server_status", "1=up, 0=down");
|
|
|
|
private static readonly Counter ErrorCounter = Metrics.CreateCounter("app_http_errors_total", "HTTP Errors", new[] { "status_code", "endpoint" });
|
|
|
|
protected void Application_Error()
|
|
|
|
{
|
|
|
|
var context = HttpContext.Current;
|
|
|
|
var exception = Server.GetLastError();
|
|
|
|
if (context != null && exception != null)
|
|
|
|
{
|
|
|
|
var route = context.Request.Path;
|
|
|
|
var status = "";
|
|
|
|
if (exception is HttpException httpEx)
|
|
|
|
{
|
|
|
|
status = httpEx.GetHttpCode().ToString();
|
|
|
|
}
|
|
|
|
ErrorCounter.Labels(status, route).Inc();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
protected void Application_End()
|
|
|
|
{
|
|
|
|
ServerStatus.Set(0);
|
|
|
|
}
|
|
|
|
protected void Application_Start()
|
|
|
|
{
|
|
|
|
|
|
ServerStatus.Set(1);
|
|
|
|
AreaRegistration.RegisterAllAreas();
|
|
|
|
WebApiConfig.Register(GlobalConfiguration.Configuration);
|
|
|
|
FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
|
|
|
|
RouteConfig.RegisterRoutes(RouteTable.Routes);
|
|
|
|
BundleConfig.RegisterBundles(BundleTable.Bundles);
|
|
|
|
AuthConfig.RegisterAuth();
|
|
|
|
}*/
|
|
|
|
protected void Application_Start()
|
|
|
|
{
|
|
|
|
// Register Web API configuration
|
|
GlobalConfiguration.Configure(WebApiConfig.Register);
|
|
|
|
|
|
AreaRegistration.RegisterAllAreas();
|
|
|
|
//WebApiConfig.Register(GlobalConfiguration.Configuration);
|
|
|
|
FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
|
|
|
|
RouteConfig.RegisterRoutes(RouteTable.Routes);
|
|
|
|
BundleConfig.RegisterBundles(BundleTable.Bundles);
|
|
|
|
AuthConfig.RegisterAuth();
|
|
|
|
}
|
|
|
|
}
|
|
} |