Skip to content

Commit fb42fc0

Browse files
authored
Add diagnostic listener to interop client (#1513)
1 parent 16a1bb4 commit fb42fc0

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

test/Shared/HttpEventSourceListener.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,11 @@ protected override void OnEventWritten(EventWrittenEventArgs eventData)
7373
_messageBuilder.Append(" - ");
7474
_messageBuilder.Append(eventData.EventName);
7575
_messageBuilder.Append(" : ");
76+
#if !NET472
7677
_messageBuilder.AppendJoin(',', eventData.Payload!);
78+
#else
79+
_messageBuilder.Append(string.Join(",", eventData.Payload!.ToArray()));
80+
#endif
7781
_messageBuilder.Append(" ->");
7882
message = _messageBuilder.ToString();
7983
_messageBuilder.Clear();

testassets/InteropTestsClient/InteropTestsClient.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
<Compile Include="..\Shared\IChannelWrapper.cs" Link="IChannelWrapper.cs" />
1919
<Compile Include="..\Shared\InteropClient.cs" Link="InteropClient.cs" />
2020
<Compile Include="..\Shared\TestCredentials.cs" Link="TestCredentials.cs" />
21+
<Compile Include="..\..\test\Shared\HttpEventSourceListener.cs" Link="HttpEventSourceListener.cs" />
2122

2223
<Protobuf Include="..\Proto\echo.proto" GrpcServices="Client" Link="Protos\echo.proto" />
2324
<Protobuf Include="..\Proto\grpc\testing\test.proto" GrpcServices="Client" Link="Protos\test.proto" />

testassets/InteropTestsClient/Program.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
using System.CommandLine.Invocation;
2121
using System.Reflection;
2222
using Grpc.Shared.TestAssets;
23+
using Grpc.Tests.Shared;
2324
using Microsoft.Extensions.DependencyInjection;
2425
using Microsoft.Extensions.Logging;
2526

@@ -66,8 +67,11 @@ public static async Task<int> Main(string[] args)
6667
});
6768

6869
using var serviceProvider = services.BuildServiceProvider();
70+
var loggerFactory = serviceProvider.GetRequiredService<ILoggerFactory>();
6971

70-
var interopClient = new InteropClient(options, serviceProvider.GetRequiredService<ILoggerFactory>());
72+
using var httpEventListener = new HttpEventSourceListener(loggerFactory);
73+
74+
var interopClient = new InteropClient(options, loggerFactory);
7175
await interopClient.Run();
7276
});
7377

0 commit comments

Comments
 (0)