From dfa51220a53930d087e1be2613e0ae7ba21d3032 Mon Sep 17 00:00:00 2001 From: Timothy Mothra Date: Fri, 9 Jul 2021 10:26:22 -0700 Subject: [PATCH] log to indicated Authentication Policy caught the response from ingestion (#2319) --- .../Implementation/TelemetryChannelEventSource.cs | 6 ++++++ .../TransmissionPolicy/AuthenticationTransmissionPolicy.cs | 5 +++++ 2 files changed, 11 insertions(+) diff --git a/BASE/src/ServerTelemetryChannel/Implementation/TelemetryChannelEventSource.cs b/BASE/src/ServerTelemetryChannel/Implementation/TelemetryChannelEventSource.cs index 849c7558c3..4b78dd2b45 100644 --- a/BASE/src/ServerTelemetryChannel/Implementation/TelemetryChannelEventSource.cs +++ b/BASE/src/ServerTelemetryChannel/Implementation/TelemetryChannelEventSource.cs @@ -565,6 +565,12 @@ public void TransmissionFlushAsyncWarning(string exception, string appDomainName this.WriteEvent(77, exception ?? string.Empty, this.ApplicationName); } + [Event(78, Message = "AuthenticatedTransmissionError. Received a failed ingestion response. TransmissionId: {0}. Status Code: {1}. Status Description: {2}", Level = EventLevel.Warning)] + public void AuthenticationPolicyCaughtFailedIngestion(string transmissionId, string statusCode, string statusDescription, string appDomainName = "Incorrect") + { + this.WriteEvent(78, transmissionId ?? string.Empty, statusCode ?? string.Empty, statusDescription ?? string.Empty, this.ApplicationName); + } + private static string GetApplicationName() { //// We want to add application name to all events BUT diff --git a/BASE/src/ServerTelemetryChannel/Implementation/TransmissionPolicy/AuthenticationTransmissionPolicy.cs b/BASE/src/ServerTelemetryChannel/Implementation/TransmissionPolicy/AuthenticationTransmissionPolicy.cs index 0dc78e8cf6..4444a32ee4 100644 --- a/BASE/src/ServerTelemetryChannel/Implementation/TransmissionPolicy/AuthenticationTransmissionPolicy.cs +++ b/BASE/src/ServerTelemetryChannel/Implementation/TransmissionPolicy/AuthenticationTransmissionPolicy.cs @@ -1,6 +1,7 @@ namespace Microsoft.ApplicationInsights.WindowsServer.TelemetryChannel.Implementation.TransmissionPolicy { using System; + using System.Globalization; using System.Threading.Tasks; using Microsoft.ApplicationInsights.Channel.Implementation; @@ -65,6 +66,10 @@ private void HandleTransmissionSentEvent(object sender, TransmissionProcessedEve { case ResponseStatusCodes.Unauthorized: case ResponseStatusCodes.Forbidden: + TelemetryChannelEventSource.Log.AuthenticationPolicyCaughtFailedIngestion( + transmissionId: e.Transmission.Id, + statusCode: e.Response.StatusCode.ToString(CultureInfo.InvariantCulture), + statusDescription: e.Response.StatusDescription); this.ApplyThrottlePolicy(e); break; }