Skip to content

Commit

Permalink
log to indicated Authentication Policy caught the response from inges…
Browse files Browse the repository at this point in the history
…tion (#2319)
  • Loading branch information
TimothyMothra authored Jul 9, 2021
1 parent 7c6589e commit dfa5122
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit dfa5122

Please sign in to comment.