open-telemetry / opentelemetry-collector-contrib

Contrib repository for the OpenTelemetry Collector
https://opentelemetry.io
Apache License 2.0
2.73k stars 2.17k forks source link

The `Source` property seems to be the wrong one for mapping client IP to #33210

Open qrli opened 1 month ago

qrli commented 1 month ago

Component(s)

exporter/azuremonitor

What happened?

Description

AzureMonitor exporter, as documented in readme, is mapping client IP to the Source property. However, it does not sound like the right mapping. The value in Source does not provide value to Application Insights's "Client Ip address", leading "Country or region", "City", etc. not correctly populated.

According to https://github.com/microsoft/ApplicationInsights-dotnet/blob/99118c924d3880f3853c0b1c9ebe67289073dbfa/BASE/src/Microsoft.ApplicationInsights/DataContracts/RequestTelemetry.cs#L261 the Source is defined as "the source for the request telemetry object. This often is a hashed instrumentation key identifying the caller." It sounds like a totally different thing than client IP.

According to https://github.com/microsoft/ApplicationInsights-dotnet/blob/99118c924d3880f3853c0b1c9ebe67289073dbfa/NETCORE/src/Microsoft.ApplicationInsights.AspNetCore/TelemetryInitializers/ClientIpHeaderTelemetryInitializer.cs#L123 client IP is set in Context.Location.Ip. It should be this one in Go: https://github.com/microsoft/ApplicationInsights-Go/blob/9194eea52d6fe5313a2b109056254baca9ab3194/appinsights/contracts/contexttags.go#L237

Steps to Reproduce

As long as the application side sends http.client_ip or net.peer.name, the Source property of Application Insights is filled.

Expected Result

Application Insights' "Client Ip address" should get the value, so that "Country or region", "City", etc. are correctly populated.

Note that by default, Application Insights's clear out "Client Ip address" after populating "Country or region", "City", etc., for privacy reason. This is also a useful feature Source does not provide.

So, what is really to be seen is that "Client Ip address" is empty or 0.0.0.0 but "Country or region", "City", "State or province" have correct value inferred from IP.

Actual Result

Application Insights does not see the client IP so "Country or region", "City", "State or province" are not correctly populated, which may be empty or some default value.

Collector version

latest

Environment information

Environment

OS: (e.g., "Ubuntu 20.04") Compiler(if manually compiled): (e.g., "go 14.2")

OpenTelemetry Collector configuration

No response

Log output

No response

Additional context

No response

github-actions[bot] commented 1 month ago

Pinging code owners: