Last active
March 13, 2017 19:27
-
-
Save patkleef/ed22f3e1a0dbfd3e830fbd939c8a7b9e to your computer and use it in GitHub Desktop.
Application Insights Blog - ApplicationInsightsClientIpHeaderTelemetryInitializer.cs
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
/// <summary> | |
/// Implements initialization logic. | |
/// </summary> | |
/// <param name="platformContext">Http context.</param> | |
/// <param name="requestTelemetry">Request telemetry object associated with the current request.</param> | |
/// <param name="telemetry">Telemetry item to initialize.</param> | |
protected override void OnInitializeTelemetry(HttpContext platformContext, RequestTelemetry requestTelemetry, ITelemetry telemetry) | |
{ | |
if (string.IsNullOrEmpty(telemetry.Context.Location.Ip)) | |
{ | |
LocationContext location = requestTelemetry.Context.Location; | |
if (string.IsNullOrEmpty(location.Ip)) | |
{ | |
this.UpdateRequestTelemetry(platformContext, location); | |
} | |
telemetry.Context.Location.Ip = location.Ip; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment