diff --git a/Vostok.Metrics.System/Host/TcpStateCollector.cs b/Vostok.Metrics.System/Host/TcpStateCollector.cs index be13b9c..074cc10 100644 --- a/Vostok.Metrics.System/Host/TcpStateCollector.cs +++ b/Vostok.Metrics.System/Host/TcpStateCollector.cs @@ -31,11 +31,11 @@ public void Collect(HostMetrics metrics) if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { - IterateOverTcpConnections(info => + IterateOverTcpConnections(state => { - if (!states.ContainsKey(info.State)) - states[info.State] = 0; - states[info.State]++; + if (!states.ContainsKey(state)) + states[state] = 0; + states[state]++; }); } else @@ -65,7 +65,7 @@ public void Collect(HostMetrics metrics) } #if NET6_0_OR_GREATER - private unsafe void IterateOverTcpConnections(Action handle) + private static unsafe void IterateOverTcpConnections(Action handle) { var size = 0U; uint result; @@ -103,9 +103,9 @@ private unsafe void IterateOverTcpConnections(Action handle) var localPort = row.localPort1 << 8 | row.localPort2; var remotePort = state == TcpState.Listen ? 0 : row.remotePort1 << 8 | row.remotePort2; - var info = new TcpInfo(state, new IPEndPoint(row.localAddr, localPort), new IPEndPoint(row.remoteAddr, remotePort)); + // var info = new TcpInfo(state, new IPEndPoint(row.localAddr, localPort), new IPEndPoint(row.remoteAddr, remotePort)); - handle(info); + handle(state); span = span[sizeof(Interop.IpHlpApi.MibTcpRow)..]; } @@ -164,12 +164,12 @@ private unsafe void IterateOverTcpConnections(Action handle) var localPort = row.localPort1 << 8 | row.localPort2; var remotePort = ((state == TcpState.Listen) ? 0 : row.remotePort1 << 8 | row.remotePort2); - var info = new TcpInfo( - state, - new IPEndPoint(new IPAddress(row.localAddrAsSpan, row.localScopeId), localPort), - new IPEndPoint(new IPAddress(row.remoteAddrAsSpan, row.remoteScopeId), remotePort)); + // var info = new TcpInfo( + // state, + // new IPEndPoint(new IPAddress(row.localAddrAsSpan, row.localScopeId), localPort), + // new IPEndPoint(new IPAddress(row.remoteAddrAsSpan, row.remoteScopeId), remotePort)); - handle(info); + handle(state); // We increment the pointer to the next row. span = span.Slice(sizeof(Interop.IpHlpApi.MibTcp6RowOwnerPid)); }