Remove Azure App Insights; Fix-up error handling

This commit is contained in:
Thomas Hounsell 2017-04-26 12:26:18 +01:00
parent e244c823ab
commit a16dcb7a8e
7 changed files with 8 additions and 128 deletions

View File

@ -1,5 +1,4 @@
using System.Web.Mvc; using System.Web.Mvc;
using BuildFeed.Code;
namespace BuildFeed namespace BuildFeed
{ {
@ -7,7 +6,7 @@ public class FilterConfig
{ {
public static void RegisterGlobalFilters(GlobalFilterCollection filters) public static void RegisterGlobalFilters(GlobalFilterCollection filters)
{ {
filters.Add(new AiHandleErrorAttribute()); filters.Add(new HandleErrorAttribute());
} }
} }
} }

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\packages\Microsoft.Net.Compilers.2.0.1\build\Microsoft.Net.Compilers.props" Condition="Exists('..\packages\Microsoft.Net.Compilers.2.0.1\build\Microsoft.Net.Compilers.props')" /> <Import Project="..\packages\Microsoft.Net.Compilers.2.1.0\build\Microsoft.Net.Compilers.props" Condition="Exists('..\packages\Microsoft.Net.Compilers.2.1.0\build\Microsoft.Net.Compilers.props')" />
<Import Project="..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.3\build\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props" Condition="Exists('..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.3\build\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props')" /> <Import Project="..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.3\build\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props" Condition="Exists('..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.3\build\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props')" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\TypeScript\Microsoft.TypeScript.Default.props" Condition="Exists('$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\TypeScript\Microsoft.TypeScript.Default.props')" /> <Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\TypeScript\Microsoft.TypeScript.Default.props" Condition="Exists('$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\TypeScript\Microsoft.TypeScript.Default.props')" />
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
@ -70,27 +70,6 @@
<HintPath>..\packages\Humanizer.Core.2.1.0\lib\netstandard1.0\Humanizer.dll</HintPath> <HintPath>..\packages\Humanizer.Core.2.1.0\lib\netstandard1.0\Humanizer.dll</HintPath>
<Private>True</Private> <Private>True</Private>
</Reference> </Reference>
<Reference Include="Microsoft.AI.Agent.Intercept, Version=2.0.7.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.ApplicationInsights.Agent.Intercept.2.0.7\lib\net45\Microsoft.AI.Agent.Intercept.dll</HintPath>
</Reference>
<Reference Include="Microsoft.AI.DependencyCollector, Version=2.3.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.ApplicationInsights.DependencyCollector.2.3.0\lib\net45\Microsoft.AI.DependencyCollector.dll</HintPath>
</Reference>
<Reference Include="Microsoft.AI.PerfCounterCollector, Version=2.3.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.ApplicationInsights.PerfCounterCollector.2.3.0\lib\net45\Microsoft.AI.PerfCounterCollector.dll</HintPath>
</Reference>
<Reference Include="Microsoft.AI.ServerTelemetryChannel, Version=2.3.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.ApplicationInsights.WindowsServer.TelemetryChannel.2.3.0\lib\net45\Microsoft.AI.ServerTelemetryChannel.dll</HintPath>
</Reference>
<Reference Include="Microsoft.AI.Web, Version=2.3.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.ApplicationInsights.Web.2.3.0\lib\net45\Microsoft.AI.Web.dll</HintPath>
</Reference>
<Reference Include="Microsoft.AI.WindowsServer, Version=2.3.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.ApplicationInsights.WindowsServer.2.3.0\lib\net45\Microsoft.AI.WindowsServer.dll</HintPath>
</Reference>
<Reference Include="Microsoft.ApplicationInsights, Version=2.3.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.ApplicationInsights.2.3.0\lib\net46\Microsoft.ApplicationInsights.dll</HintPath>
</Reference>
<Reference Include="Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL"> <Reference Include="Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.3\lib\net45\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.dll</HintPath> <HintPath>..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.3\lib\net45\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.dll</HintPath>
</Reference> </Reference>
@ -194,7 +173,6 @@
<Compile Include="Areas\admin\Controllers\baseController.cs" /> <Compile Include="Areas\admin\Controllers\baseController.cs" />
<Compile Include="Areas\admin\Controllers\metaController.cs" /> <Compile Include="Areas\admin\Controllers\metaController.cs" />
<Compile Include="Areas\admin\Models\ViewModel\MetaListing.cs" /> <Compile Include="Areas\admin\Models\ViewModel\MetaListing.cs" />
<Compile Include="Code\AiHandleErrorAttribute.cs" />
<Compile Include="Code\Base32Encoding.cs" /> <Compile Include="Code\Base32Encoding.cs" />
<Compile Include="Code\CustomContentTypeAttribute.cs" /> <Compile Include="Code\CustomContentTypeAttribute.cs" />
<Compile Include="Code\DateTimeModelBinder.cs" /> <Compile Include="Code\DateTimeModelBinder.cs" />
@ -249,10 +227,6 @@
<Content Include="Areas\admin\Views\_ViewStart.cshtml" /> <Content Include="Areas\admin\Views\_ViewStart.cshtml" />
<Content Include="content\Web.config" /> <Content Include="content\Web.config" />
<Content Include="Areas\admin\Views\base\index.cshtml" /> <Content Include="Areas\admin\Views\base\index.cshtml" />
<Content Include="ApplicationInsights.config">
<SubType>Designer</SubType>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Areas\admin\Views\users\admins.cshtml" /> <Content Include="Areas\admin\Views\users\admins.cshtml" />
<Content Include="Areas\admin\Views\meta\index.cshtml" /> <Content Include="Areas\admin\Views\meta\index.cshtml" />
<Content Include="Areas\admin\Views\meta\create.cshtml" /> <Content Include="Areas\admin\Views\meta\create.cshtml" />
@ -502,7 +476,7 @@
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText> <ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup> </PropertyGroup>
<Error Condition="!Exists('..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.3\build\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.3\build\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props'))" /> <Error Condition="!Exists('..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.3\build\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.3\build\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props'))" />
<Error Condition="!Exists('..\packages\Microsoft.Net.Compilers.2.0.1\build\Microsoft.Net.Compilers.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.Net.Compilers.2.0.1\build\Microsoft.Net.Compilers.props'))" /> <Error Condition="!Exists('..\packages\Microsoft.Net.Compilers.2.1.0\build\Microsoft.Net.Compilers.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.Net.Compilers.2.1.0\build\Microsoft.Net.Compilers.props'))" />
</Target> </Target>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets. Other similar extension points exist, see Microsoft.Common.targets.

View File

@ -1,25 +0,0 @@
using System;
using System.Web.Mvc;
using Microsoft.ApplicationInsights;
namespace BuildFeed.Code
{
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = true)]
public class AiHandleErrorAttribute : HandleErrorAttribute
{
public override void OnException(ExceptionContext filterContext)
{
if (filterContext?.HttpContext != null && filterContext.Exception != null)
{
//If customError is Off, then AI HTTPModule will report the exception
if (filterContext.HttpContext.IsCustomErrorEnabled)
{
// Note: A single instance of telemetry client is sufficient to track multiple telemetry items.
TelemetryClient ai = new TelemetryClient();
ai.TrackException(filterContext.Exception);
}
}
base.OnException(filterContext);
}
}
}

View File

@ -57,16 +57,6 @@
} }
}]); }]);
</script> </script>
<script type="text/javascript">
var appInsights = window.appInsights || function (config) {
function i(config) { t[config] = function () { var i = arguments; t.queue.push(function () { t[config].apply(t, i) }) } } var t = { config: config }, u = document, e = window, o = "script", s = "AuthenticatedUserContext", h = "start", c = "stop", l = "Track", a = l + "Event", v = l + "Page", y = u.createElement(o), r, f; y.src = config.url || "https://az416426.vo.msecnd.net/scripts/a/ai.0.js"; u.getElementsByTagName(o)[0].parentNode.appendChild(y); try { t.cookie = u.cookie } catch (p) { } for (t.queue = [], t.version = "1.0", r = ["Event", "Exception", "Metric", "PageView", "Trace", "Dependency"]; r.length;)i("track" + r.pop()); return i("set" + s), i("clear" + s), i(h + a), i(c + a), i(h + v), i(c + v), i("flush"), config.disableExceptionTracking || (r = "onerror", i("_" + r), f = e[r], e[r] = function (config, i, u, e, o) { var s = f && f(config, i, u, e, o); return s !== !0 && t["_" + r](config, i, u, e, o), s }), t
}({
instrumentationKey: "4632419f-7a2f-4ab5-8374-34384b650f42"
});
window.appInsights = appInsights;
appInsights.trackPageView();
</script>
</head> </head>
<body> <body>
<script> <script>

View File

@ -4,6 +4,7 @@
@model HandleErrorInfo @model HandleErrorInfo
@{ @{
bool isRtl = CultureInfo.CurrentUICulture.TextInfo.IsRightToLeft; bool isRtl = CultureInfo.CurrentUICulture.TextInfo.IsRightToLeft;
Layout = null;
} }
<!DOCTYPE html> <!DOCTYPE html>
<html dir="@(isRtl <html dir="@(isRtl
@ -16,7 +17,7 @@
<meta http-equiv="X-UA-Compatible" content="IE=edge" /> <meta http-equiv="X-UA-Compatible" content="IE=edge" />
<title>@VariantTerms.Common_Error | @InvariantTerms.SiteName</title> <title>@VariantTerms.Common_Error | @InvariantTerms.SiteName</title>
<link href="/res/css/default.css" rel="stylesheet" type="text/css" /> <link href="/res/css/default.css" rel="stylesheet" type="text/css" />
<link href="@(VirtualPathUtility.ToAbsolute(((Theme)ViewBag.Theme).CssPath))" rel="stylesheet" type="text/css" /> <link href="@(VirtualPathUtility.ToAbsolute(Theme.AvailableThemes[0].CssPath))" rel="stylesheet" type="text/css" />
@if (isRtl) @if (isRtl)
{ {
<link href="/res/css/rtl.css" rel="stylesheet" type="text/css" /> <link href="/res/css/rtl.css" rel="stylesheet" type="text/css" />
@ -29,17 +30,6 @@
<meta name="theme-color" content="#373736"> <meta name="theme-color" content="#373736">
<meta name="application-name" content="@InvariantTerms.SiteName" /> <meta name="application-name" content="@InvariantTerms.SiteName" />
<meta name="twitter:site" content="@("@")buildfeed"> <meta name="twitter:site" content="@("@")buildfeed">
<script type="text/javascript">
var appInsights = window.appInsights || function (config) {
function r(config) { t[config] = function () { var i = arguments; t.queue.push(function () { t[config].apply(t, i) }) } } var t = { config: config }, u = document, e = window, o = "script", s = u.createElement(o), i, f; for (s.src = config.url || "//az416426.vo.msecnd.net/scripts/a/ai.0.js", u.getElementsByTagName(o)[0].parentNode.appendChild(s), t.cookie = u.cookie, t.queue = [], i = ["Event", "Exception", "Metric", "PageView", "Trace"]; i.length;) r("track" + i.pop()); return r("setAuthenticatedUserContext"), r("clearAuthenticatedUserContext"), config.disableExceptionTracking || (i = "onerror", r("_" + i), f = e[i], e[i] = function (config, r, u, e, o) { var s = f && f(config, r, u, e, o); return s !== !0 && t["_" + i](config, r, u, e, o), s }), t
}({
instrumentationKey: "4632419f-7a2f-4ab5-8374-34384b650f42"
});
window.appInsights = appInsights;
appInsights.trackPageView();
</script>
</head> </head>
<body> <body>
<script> <script>
@ -77,38 +67,6 @@
<i class="fa fa-fw fa-twitter"></i> @VariantTerms.Common_Twitter <i class="fa fa-fw fa-twitter"></i> @VariantTerms.Common_Twitter
</a> </a>
</li> </li>
<li class="dropdown-parent">
<a href="#">
<i class="fa fa-gear"></i>
</a>
<ul class="dropdown-menu">
<li id="settings-theme-menu" class="dropdown-menu-block">
<h4>@VariantTerms.Common_NavigationTheme</h4>
<ul>
@foreach (Theme item in Theme.AvailableThemes)
{
<li>
<a href="#" data-theme="@item.CookieValue">@item.DisplayName</a>
</li>
}
</ul>
</li>
<li id="settings-lang-menu" class="dropdown-menu-block">
<h4>@VariantTerms.Common_NavigationLanguage</h4>
<ul>
@foreach (Locale locale in Locale.AvailableLocales)
{
<li>
<a href="#" data-lang="@locale.LocaleId" dir="@(locale.Info.TextInfo.IsRightToLeft
? "rtl"
: "ltr")">
@locale.DisplayName</a>
</li>
}
</ul>
</li>
</ul>
</li>
</ul> </ul>
</div> </div>
</nav> </nav>
@ -116,7 +74,7 @@
<div class="container"> <div class="container">
<h1>@VariantTerms.Common_Error</h1> <h1>@VariantTerms.Common_Error</h1>
<p> <p>
@string.Format(VariantTerms.Common_ErrorContent, "<a href=\"https://github.com/hounsell/BuildFeed/issues\">GitHub</a>") @Html.Raw(string.Format(VariantTerms.Common_ErrorContent, "<a href=\"https://github.com/hounsell/BuildFeed/issues\">GitHub</a>"))
</p> </p>
<p> <p>
Controller: <code>@Model.ControllerName</code> Controller: <code>@Model.ControllerName</code>
@ -152,8 +110,5 @@
</div> </div>
</div> </div>
</footer> </footer>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jsrender/1.0.0-rc.70/jsrender.min.js" integrity="sha256-3UBtL0tzgKVuJU8ZZiWLXEWGEjXEr6Z023rpauMnBUE=" crossorigin="anonymous"></script>
<script type="text/javascript" src="~/res/ts/bfs.js"></script>
@RenderSection("scripts", false)
</body> </body>
</html> </html>

View File

@ -2,17 +2,11 @@
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform"> <configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<system.web> <system.web>
<customErrors mode="On" xdt:Transform="Insert" />
<compilation xdt:Transform="RemoveAttributes(debug)" /> <compilation xdt:Transform="RemoveAttributes(debug)" />
<trace enabled="false" requestLimit="40" pageOutput="false" xdt:Transform="Replace" /> <trace enabled="false" requestLimit="40" pageOutput="false" xdt:Transform="Replace" />
<httpModules>
<add name="ApplicationInsightsWebTracking" type="Microsoft.ApplicationInsights.Web.ApplicationInsightsHttpModule, Microsoft.AI.Web" xdt:Transform="Insert" />
</httpModules>
</system.web> </system.web>
<system.webServer> <system.webServer>
<modules>
<remove name="ApplicationInsightsWebTracking" xdt:Transform="Insert" />
<add name="ApplicationInsightsWebTracking" type="Microsoft.ApplicationInsights.Web.ApplicationInsightsHttpModule, Microsoft.AI.Web" preCondition="managedHandler" xdt:Transform="Insert" />
</modules>
<rewrite> <rewrite>
<rules> <rules>
<rule name="CanonicalHost" stopProcessing="true" xdt:Transform="Insert"> <rule name="CanonicalHost" stopProcessing="true" xdt:Transform="Insert">

View File

@ -47,13 +47,6 @@
<package id="jquery.TypeScript.DefinitelyTyped" version="3.1.2" targetFramework="net462" /> <package id="jquery.TypeScript.DefinitelyTyped" version="3.1.2" targetFramework="net462" />
<package id="jQuery.Validation" version="1.16.0" targetFramework="net462" /> <package id="jQuery.Validation" version="1.16.0" targetFramework="net462" />
<package id="jsrender.TypeScript.DefinitelyTyped" version="0.1.8" targetFramework="net461" /> <package id="jsrender.TypeScript.DefinitelyTyped" version="0.1.8" targetFramework="net461" />
<package id="Microsoft.ApplicationInsights" version="2.3.0" targetFramework="net462" />
<package id="Microsoft.ApplicationInsights.Agent.Intercept" version="2.0.7" targetFramework="net462" />
<package id="Microsoft.ApplicationInsights.DependencyCollector" version="2.3.0" targetFramework="net462" />
<package id="Microsoft.ApplicationInsights.PerfCounterCollector" version="2.3.0" targetFramework="net462" />
<package id="Microsoft.ApplicationInsights.Web" version="2.3.0" targetFramework="net462" />
<package id="Microsoft.ApplicationInsights.WindowsServer" version="2.3.0" targetFramework="net462" />
<package id="Microsoft.ApplicationInsights.WindowsServer.TelemetryChannel" version="2.3.0" targetFramework="net462" />
<package id="Microsoft.AspNet.Mvc" version="5.2.3" targetFramework="net462" /> <package id="Microsoft.AspNet.Mvc" version="5.2.3" targetFramework="net462" />
<package id="Microsoft.AspNet.Razor" version="3.2.3" targetFramework="net462" /> <package id="Microsoft.AspNet.Razor" version="3.2.3" targetFramework="net462" />
<package id="Microsoft.AspNet.WebApi" version="5.2.3" targetFramework="net462" /> <package id="Microsoft.AspNet.WebApi" version="5.2.3" targetFramework="net462" />
@ -64,7 +57,7 @@
<package id="Microsoft.CodeDom.Providers.DotNetCompilerPlatform" version="1.0.3" targetFramework="net462" /> <package id="Microsoft.CodeDom.Providers.DotNetCompilerPlatform" version="1.0.3" targetFramework="net462" />
<package id="Microsoft.CSharp" version="4.3.0" targetFramework="net462" /> <package id="Microsoft.CSharp" version="4.3.0" targetFramework="net462" />
<package id="Microsoft.jQuery.Unobtrusive.Validation" version="3.2.3" targetFramework="net462" /> <package id="Microsoft.jQuery.Unobtrusive.Validation" version="3.2.3" targetFramework="net462" />
<package id="Microsoft.Net.Compilers" version="2.0.1" targetFramework="net462" developmentDependency="true" /> <package id="Microsoft.Net.Compilers" version="2.1.0" targetFramework="net462" developmentDependency="true" />
<package id="Microsoft.Web.Infrastructure" version="1.0.0.0" targetFramework="net462" /> <package id="Microsoft.Web.Infrastructure" version="1.0.0.0" targetFramework="net462" />
<package id="MongoDB.Bson" version="2.4.3" targetFramework="net462" /> <package id="MongoDB.Bson" version="2.4.3" targetFramework="net462" />
<package id="MongoDB.Driver" version="2.4.3" targetFramework="net462" /> <package id="MongoDB.Driver" version="2.4.3" targetFramework="net462" />