Skip to content

Commit ccd044f

Browse files
Merge pull request #211240 from toddfoust/patch-3
Adding a new sample initializer for client ip
2 parents 59b331b + 8d895f1 commit ccd044f

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

articles/azure-monitor/app/api-filtering-sampling.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -479,6 +479,21 @@ public void Initialize(ITelemetry telemetry)
479479
}
480480
}
481481
```
482+
483+
#### Control the client IP address used for gelocation mappings
484+
485+
The following sample initializer sets the client IP which will be used for geolocation mapping, instead of the client socket IP address, during telemetry ingestion.
486+
487+
```csharp
488+
public void Initialize(ITelemetry telemetry)
489+
{
490+
var request = telemetry as RequestTelemetry;
491+
if (request == null) return true;
492+
request.Context.Location.Ip = "{client ip address}"; // Could utilize System.Web.HttpContext.Current.Request.UserHostAddress;
493+
return true;
494+
}
495+
```
496+
482497
## ITelemetryProcessor and ITelemetryInitializer
483498

484499
What's the difference between telemetry processors and telemetry initializers?

0 commit comments

Comments
 (0)