Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extend diagnostics to handle tcpip diagnostics client option #2833

Merged
merged 2 commits into from
Feb 16, 2022

Conversation

mdh1418
Copy link
Member

@mdh1418 mdh1418 commented Jan 28, 2022

In effort to enable diagnostics tests for mobile (specifically Android) in dotnet/runtime#60879, it was realized that some changes to Microsoft.Diagnostics.NETCore.Client are needed in order for the eventpipe runtime tests to work (bigevent, buffersize, eventsourceerror). More specifically, DiagnosticsClient needed to handle a TCPIP option. With most of the functionality brought up by @lateralusX previously, just a new transport type is needed for the tests to work (without the new transport type, exceptions are thrown because the API only expects two type of transports)

The expectation for the shared code between this repository and Dotnet/Runtime is that any modifications to src/tests/tracing/eventpipe/common/Microsoft.Diagnostics.NETCore.Client in Dotnet/Runtime must first be made here in Dotnet/Diagnostics and once passed, will then be downstreamed to Dotnet/Runtime.

This pr accomplishes the following:

  1. Introduces Dotnet/Runtime-specific PropertyGroup and ItemGroup into Microsoft.Diagnostics.NETCore.Client.csproj to define DIAGNOSTICS_RUNTIME constant, ignore compiler warnings, and compile the source code.
  2. Adds a new transport type TcpSocket for TCP/IP case yet wraps it under a DIAGNOSTICS_RUNTIME #if directive to limit modifications to this repository. Also extends IpcTransport.Connect with TcpClient to handle the TCP/IP transport.
  3. Adds a new file AssemblyInfo.cs completely wrapped under the above mentioned directive in order for internals to be visible on dotnet/runtime/src/tests/tracing/eventpipe/common/.
  4. Wraps IpcSocket.AcceptAsync and IpcSocket.ConnectAsync in a #if !NET6_0 preprocessor directive because .NET 6 implements the methods directly and throws on Dotnet/Runtime
  5. Adds a TCP/IP comment for the expectation of IpcEndpointConfig.Address

@mdh1418 mdh1418 requested a review from a team as a code owner January 28, 2022 14:04
@mdh1418 mdh1418 changed the title Diagnostics tcpclient cleanup Extend diagnostics to handle tcpip diagnostics client option Jan 28, 2022
Copy link
Member

@noahfalk noahfalk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is fine in principle - suggested a few changes and agreed with @josalem that the constructor should be internal.

@mdh1418 mdh1418 force-pushed the diagnostics_tcpclient_cleanup branch 2 times, most recently from a9db366 to 0bfbb2e Compare February 14, 2022 16:38
@mdh1418
Copy link
Member Author

mdh1418 commented Feb 14, 2022

@noahfalk @hoyosjs @josalem This PR captures the entirety of expected changes to Microsoft.Diagnostics.NETCore.Client source code in order to get Dotnet/Runtime diagnostics tests working on Android. It'll be easier to see just the changes than on dotnet/runtime#64358

Copy link
Member

@noahfalk noahfalk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM modulo a few minor comments inline

@@ -13,6 +13,11 @@
<IsShipping>true</IsShipping>
</PropertyGroup>

<PropertyGroup Condition="'$(GitHubRepositoryName)' == 'runtime'">
<DefineConstants>$(DefineConstants);DIAGNOSTICS_RUNTIME</DefineConstants>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to define NET_6 here, or does that happen somewhere else?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NET_6 should be defined iff compiling against net6.0+ TFMs.

@mdh1418
Copy link
Member Author

mdh1418 commented Feb 16, 2022

@noahfalk @hoyosjs I'll need help with the merge 😅 I dont have merge permissions in this repo

@hoyosjs hoyosjs merged commit 3128b54 into dotnet:main Feb 16, 2022
@@ -23,6 +22,8 @@ public IpcSocket(AddressFamily addressFamily, SocketType socketType, ProtocolTyp
{
}

// .NET 6 implements this method directly on Socket, but for earlier runtimes we need a polyfill
#if !NET6_0
public async Task<Socket> AcceptAsync(CancellationToken token)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI - this override will always be used at runtime given our compilation modes, regardless of the runtime version that gets used.

@mdh1418 mdh1418 deleted the diagnostics_tcpclient_cleanup branch May 19, 2022 18:18
@github-actions github-actions bot locked and limited conversation to collaborators Jan 13, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants