Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,18 @@ internal sealed class ConnectionMetrics
private readonly object _schemeTag;
private readonly object _hostTag;
private readonly object? _portTag;
private readonly object? _socketAddressTag;
private readonly object? _peerAddressTag;
private bool _currentlyIdle;

public ConnectionMetrics(SocketsHttpHandlerMetrics metrics, string protocolVersion, string scheme, string host, int? port, string? socketAddress)
public ConnectionMetrics(SocketsHttpHandlerMetrics metrics, string protocolVersion, string scheme, string host, int? port, string? peerAddress)
{
_metrics = metrics;
_openConnectionsEnabled = _metrics.OpenConnections.Enabled;
_protocolVersionTag = protocolVersion;
_schemeTag = scheme;
_hostTag = host;
_portTag = port;
_socketAddressTag = socketAddress;
_peerAddressTag = peerAddress;
}

// TagList is a huge struct, so we avoid storing it in a field to reduce the amount we allocate on the heap.
Expand All @@ -42,9 +42,9 @@ private TagList GetTags()
tags.Add("server.port", _portTag);
}

if (_socketAddressTag is not null)
if (_peerAddressTag is not null)
{
tags.Add("server.socket.address", _socketAddressTag);
tags.Add("network.peer.address", _peerAddressTag);
}

return tags;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ protected static void VerifyTag<T>(KeyValuePair<string, object?>[] tags, string
}
}

private static void VerifySocketAddress(KeyValuePair<string, object?>[] tags)
private static void VerifyPeerAddress(KeyValuePair<string, object?>[] tags)
{
string ipString = (string)tags.Single(t => t.Key == "server.socket.address").Value;
string ipString = (string)tags.Single(t => t.Key == "network.peer.address").Value;
IPAddress ip = IPAddress.Parse(ipString);
Assert.True(ip.Equals(IPAddress.Loopback.MapToIPv6()) ||
ip.Equals(IPAddress.Loopback) ||
Expand Down Expand Up @@ -122,7 +122,7 @@ protected static void VerifyOpenConnections(string actualName, object measuremen
VerifySchemeHostPortTags(tags, uri);
VerifyTag(tags, "network.protocol.version", GetVersionString(protocolVersion));
VerifyTag(tags, "http.connection.state", state);
VerifySocketAddress(tags);
VerifyPeerAddress(tags);
}

protected static void VerifyConnectionDuration(string instrumentName, object measurement, KeyValuePair<string, object?>[] tags, Uri uri, Version? protocolVersion)
Expand All @@ -132,7 +132,7 @@ protected static void VerifyConnectionDuration(string instrumentName, object mea
Assert.InRange(value, double.Epsilon, 60);
VerifySchemeHostPortTags(tags, uri);
VerifyTag(tags, "network.protocol.version", GetVersionString(protocolVersion));
VerifySocketAddress(tags);
VerifyPeerAddress(tags);
}

protected static void VerifyTimeInQueue(string instrumentName, object measurement, KeyValuePair<string, object?>[] tags, Uri uri, Version? protocolVersion, string method = "GET")
Expand Down