Skip to content

Commit e2d86be

Browse files
committed
do not report socket.address tag
1 parent 8a3fa5f commit e2d86be

File tree

3 files changed

+8
-25
lines changed

3 files changed

+8
-25
lines changed

src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/HttpConnectionBase.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,7 @@ public HttpConnectionBase(HttpConnectionPool pool, IPEndPoint? remoteEndPoint)
5959
protocol,
6060
pool.IsSecure ? "https" : "http",
6161
pool.OriginAuthority.HostValue,
62-
port == defaultPort ? null : port,
63-
remoteEndPoint?.Address?.ToString());
62+
port == defaultPort ? null : port);
6463

6564
_connectionMetrics.ConnectionEstablished();
6665

src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/Metrics/ConnectionMetrics.cs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,9 @@ internal sealed class ConnectionMetrics
1414
private readonly object _schemeTag;
1515
private readonly object _hostTag;
1616
private readonly object? _portTag;
17-
private readonly string? _socketAddress;
1817
private bool _currentlyIdle;
1918

20-
public ConnectionMetrics(SocketsHttpHandlerMetrics metrics, string protocol, string scheme, string host, int? port, string? socketAddress)
19+
public ConnectionMetrics(SocketsHttpHandlerMetrics metrics, string protocol, string scheme, string host, int? port)
2120
{
2221
_metrics = metrics;
2322
_currentConnectionsEnabled = _metrics.CurrentConnections.Enabled;
@@ -26,7 +25,6 @@ public ConnectionMetrics(SocketsHttpHandlerMetrics metrics, string protocol, str
2625
_schemeTag = scheme;
2726
_hostTag = host;
2827
_portTag = port;
29-
_socketAddress = socketAddress;
3028
}
3129

3230
// TagList is a huge struct, so we avoid storing it in a field to reduce the amount we allocate on the heap.
@@ -43,11 +41,6 @@ private TagList GetTags()
4341
tags.Add("port", _portTag);
4442
}
4543

46-
if (_socketAddress is not null)
47-
{
48-
tags.Add("socket.address", _socketAddress);
49-
}
50-
5144
return tags;
5245
}
5346

src/libraries/System.Net.Http/tests/FunctionalTests/MetricsTest.cs

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -46,20 +46,11 @@ protected static void VerifyOptionalTag<T>(KeyValuePair<string, object?>[] tags,
4646
}
4747
}
4848

49-
private static void VerifySchemeHostPortSocketAddressTags(KeyValuePair<string, object?>[] tags, Uri uri, bool verifySocketAddress = false)
49+
private static void VerifySchemeHostPort(KeyValuePair<string, object?>[] tags, Uri uri)
5050
{
5151
VerifyOptionalTag(tags, "scheme", uri.Scheme);
5252
VerifyOptionalTag(tags, "host", uri.Host);
5353
VerifyOptionalTag(tags, "port", uri.Port);
54-
55-
if (verifySocketAddress)
56-
{
57-
string socketAddress = (string)tags.Single(t => t.Key == "socket.address").Value;
58-
IPAddress ip = IPAddress.Parse(socketAddress);
59-
Assert.True(ip.Equals(IPAddress.Loopback.MapToIPv6()) ||
60-
ip.Equals(IPAddress.Loopback) ||
61-
ip.Equals(IPAddress.IPv6Loopback));
62-
}
6354
}
6455

6556
protected static void VerifyRequestDuration(Measurement<double> measurement, Uri uri, string? protocol, int? statusCode, string method = "GET") =>
@@ -69,7 +60,7 @@ protected static void VerifyRequestDuration(string instrumentName, double measur
6960
{
7061
Assert.Equal(InstrumentNames.RequestDuration, instrumentName);
7162
Assert.InRange(measurement, double.Epsilon, 60);
72-
VerifySchemeHostPortSocketAddressTags(tags, uri);
63+
VerifySchemeHostPort(tags, uri);
7364
VerifyOptionalTag(tags, "method", method);
7465
VerifyOptionalTag(tags, "protocol", protocol);
7566
VerifyOptionalTag(tags, "status-code", statusCode);
@@ -82,7 +73,7 @@ protected static void VerifyCurrentRequest(string instrumentName, long measureme
8273
{
8374
Assert.Equal(InstrumentNames.CurrentRequests, instrumentName);
8475
Assert.Equal(expectedValue, measurement);
85-
VerifySchemeHostPortSocketAddressTags(tags, uri);
76+
VerifySchemeHostPort(tags, uri);
8677
}
8778

8879
protected static void VerifyFailedRequests(Measurement<long> measurement, long expectedValue, Uri uri, string? protocol, int? statusCode, string method = "GET")
@@ -91,7 +82,7 @@ protected static void VerifyFailedRequests(Measurement<long> measurement, long e
9182

9283
KeyValuePair<string, object?>[] tags = measurement.Tags.ToArray();
9384

94-
VerifySchemeHostPortSocketAddressTags(tags, uri);
85+
VerifySchemeHostPort(tags, uri);
9586

9687
Assert.Equal(method, tags.Single(t => t.Key == "method").Value);
9788
VerifyOptionalTag(tags, "protocol", protocol);
@@ -102,15 +93,15 @@ protected static void VerifyConnectionCounter(string expectedName, string actual
10293
{
10394
Assert.Equal(expectedName, actualName);
10495
Assert.Equal(expectedValue, Assert.IsType<long>(measurement));
105-
VerifySchemeHostPortSocketAddressTags(tags, uri, verifySocketAddress: true);
96+
VerifySchemeHostPort(tags, uri);
10697
VerifyOptionalTag(tags, "protocol", protocol);
10798
}
10899

109100
protected static void VerifyConnectionDuration(string instrumentName, double measurement, KeyValuePair<string, object?>[] tags, Uri uri, string protocol)
110101
{
111102
Assert.InRange(measurement, double.Epsilon, 60);
112103
Assert.Equal(InstrumentNames.ConnectionDuration, instrumentName);
113-
VerifySchemeHostPortSocketAddressTags(tags, uri, verifySocketAddress: true);
104+
VerifySchemeHostPort(tags, uri);
114105
VerifyOptionalTag(tags, "protocol", protocol);
115106
}
116107

0 commit comments

Comments
 (0)