From 49747f13c20eb6b3dd6b17fe787dc60cdadae6a6 Mon Sep 17 00:00:00 2001 From: Loic Sharma Date: Fri, 26 May 2017 13:11:31 -0700 Subject: [PATCH] Use ServerCommon's Response Code Processor (#3999) * Added Nuget.Services.Logging; moved to TelemetryResponseCodeProcessor * Added binding redirect for AI --- src/NuGetGallery/App_Start/OwinStartup.cs | 13 +++++-- src/NuGetGallery/NuGetGallery.csproj | 10 +++--- .../Telemetry/TelemetryResponseCodeFilter.cs | 35 ------------------- src/NuGetGallery/Web.config | 4 +++ src/NuGetGallery/packages.config | 2 +- 5 files changed, 20 insertions(+), 44 deletions(-) delete mode 100644 src/NuGetGallery/Telemetry/TelemetryResponseCodeFilter.cs diff --git a/src/NuGetGallery/App_Start/OwinStartup.cs b/src/NuGetGallery/App_Start/OwinStartup.cs index f03d16652c..e021afb78c 100644 --- a/src/NuGetGallery/App_Start/OwinStartup.cs +++ b/src/NuGetGallery/App_Start/OwinStartup.cs @@ -16,6 +16,7 @@ using Microsoft.Owin.Logging; using Microsoft.Owin.Security; using Microsoft.Owin.Security.Cookies; +using NuGet.Services.Logging; using NuGetGallery.Authentication; using NuGetGallery.Authentication.Providers; using NuGetGallery.Authentication.Providers.Cookie; @@ -64,8 +65,16 @@ public static void Configuration(IAppBuilder app) var telemetryProcessorChainBuilder = TelemetryConfiguration.Active.TelemetryProcessorChainBuilder; - // Add filters - telemetryProcessorChainBuilder.Use(next => new TelemetryResponseCodeFilter(next)); + // Add processors + telemetryProcessorChainBuilder.Use(next => + { + var processor = new TelemetryResponseCodeProcessor(next); + + processor.SuccessfulResponseCodes.Add(400); + processor.SuccessfulResponseCodes.Add(404); + + return processor; + }); // Note: sampling rate must be a factor 100/N where N is a whole number // e.g.: 50 (= 100/2), 33.33 (= 100/3), 25 (= 100/4), ... diff --git a/src/NuGetGallery/NuGetGallery.csproj b/src/NuGetGallery/NuGetGallery.csproj index 3211413e64..2f56762b04 100644 --- a/src/NuGetGallery/NuGetGallery.csproj +++ b/src/NuGetGallery/NuGetGallery.csproj @@ -429,11 +429,6 @@ ..\..\packages\NuGet.Frameworks.4.3.0-preview1-2507\lib\net45\NuGet.Frameworks.dll - - False - ..\..\packages\NuGet.Logging.3.5.0-beta-1160\lib\net45\NuGet.Logging.dll - True - ..\..\packages\NuGet.Packaging.4.3.0-preview1-2507\lib\net45\NuGet.Packaging.dll @@ -444,6 +439,10 @@ ..\..\packages\NuGet.Services.KeyVault.1.0.0.0\lib\net45\NuGet.Services.KeyVault.dll True + + ..\..\packages\NuGet.Services.Logging.2.2.1\lib\net452\NuGet.Services.Logging.dll + True + False ..\..\packages\NuGet.Services.Platform.Client.3.0.29-r-master\lib\portable-net45+wp80+win\NuGet.Services.Platform.Client.dll @@ -774,7 +773,6 @@ - diff --git a/src/NuGetGallery/Telemetry/TelemetryResponseCodeFilter.cs b/src/NuGetGallery/Telemetry/TelemetryResponseCodeFilter.cs deleted file mode 100644 index 7b4c1db73b..0000000000 --- a/src/NuGetGallery/Telemetry/TelemetryResponseCodeFilter.cs +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using Microsoft.ApplicationInsights.Extensibility; -using Microsoft.ApplicationInsights.Channel; -using Microsoft.ApplicationInsights.DataContracts; - -namespace NuGetGallery.Helpers -{ - public class TelemetryResponseCodeFilter : ITelemetryProcessor - { - public TelemetryResponseCodeFilter(ITelemetryProcessor next) - { - Next = next; - } - - private ITelemetryProcessor Next { get; set; } - - public void Process(ITelemetry item) - { - var request = item as RequestTelemetry; - int responseCode; - - if (request != null && int.TryParse(request.ResponseCode, out responseCode)) - { - if (responseCode == 400 || responseCode == 404) - { - request.Success = true; - } - } - - this.Next.Process(item); - } - } -} \ No newline at end of file diff --git a/src/NuGetGallery/Web.config b/src/NuGetGallery/Web.config index 5816b78c90..b640eed66f 100644 --- a/src/NuGetGallery/Web.config +++ b/src/NuGetGallery/Web.config @@ -436,6 +436,10 @@ + + + + diff --git a/src/NuGetGallery/packages.config b/src/NuGetGallery/packages.config index 994516b946..2b277f9381 100644 --- a/src/NuGetGallery/packages.config +++ b/src/NuGetGallery/packages.config @@ -79,11 +79,11 @@ - +