Skip to content

Commit e298f59

Browse files
committed
fix(tracing): enrich client.address from remote ip
1 parent 57ba8e5 commit e298f59

3 files changed

Lines changed: 17 additions & 1 deletion

File tree

.claude/settings.local.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@
2424
"Bash(dotnet tool uninstall:*)",
2525
"WebFetch(domain:gitversion.net)",
2626
"Bash(cat:*)",
27-
"Bash(dotnet package:*)"
27+
"Bash(dotnet package:*)",
28+
"WebSearch"
2829
],
2930
"deny": []
3031
}

src/ES.FX.Ignite/Configuration/AspNetCore/AspNetCoreTracingSettings.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,11 @@ public class AspNetCoreTracingSettings : TracingSettings
88
/// Gets or sets a value indicating whether ASP.NET Core tracing will filter out health checks requests
99
/// </summary>
1010
public bool HealthChecksFiltered { get; set; } = true;
11+
12+
/// <summary>
13+
/// Gets or sets a value indicating whether the client address (client.address) tag should be set
14+
/// from the request's RemoteIpAddress. This ensures the correct client IP is reported when
15+
/// forwarded headers are used.
16+
/// </summary>
17+
public bool EnrichClientAddressFromRemoteIpAddress { get; set; } = true;
1118
}

src/ES.FX.Ignite/Hosting/IgniteHostingExtensions.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,14 @@ private static void AddOpenTelemetry(IHostApplicationBuilder builder, IgniteSett
125125
o.Filter = context =>
126126
!context.Request.Path.StartsWithSegments(settings.AspNetCore.HealthChecks.LivenessEndpointPath) &&
127127
!context.Request.Path.StartsWithSegments(settings.AspNetCore.HealthChecks.ReadinessEndpointPath);
128+
129+
if (settings.AspNetCore.Tracing.EnrichClientAddressFromRemoteIpAddress)
130+
o.EnrichWithHttpResponse = (activity, response) =>
131+
{
132+
var clientAddress = response.HttpContext.Connection.RemoteIpAddress?.ToString();
133+
if (clientAddress is not null)
134+
activity.SetTag("client.address", clientAddress);
135+
};
128136
});
129137
}
130138

0 commit comments

Comments
 (0)