-
Notifications
You must be signed in to change notification settings - Fork 643
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
3316: Filter out 400 and 404 response codes from failed requests tele…
…metry (#3399)
- Loading branch information
1 parent
acde497
commit 4a325ed
Showing
3 changed files
with
39 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
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); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters