|
31 | 31 | using Grpc.Core;
|
32 | 32 | using Grpc.Net.Client;
|
33 | 33 | using Grpc.Testing;
|
| 34 | +using Grpc.Tests.Shared; |
34 | 35 | using Microsoft.Crank.EventSources;
|
35 | 36 | using Microsoft.Extensions.Logging;
|
36 | 37 |
|
@@ -103,11 +104,27 @@ public static async Task<int> Main(string[] args)
|
103 | 104 | BenchmarksEventSource.Measure("IsServerGC", isServerGC.ToString());
|
104 | 105 | BenchmarksEventSource.Measure("ProcessorCount", processorCount);
|
105 | 106 |
|
| 107 | + HttpEventSourceListener? listener = null; |
| 108 | + if (_options.LogLevel != LogLevel.None) |
| 109 | + { |
| 110 | + Log($"Setting up logging. Log level: {_options.LogLevel}"); |
| 111 | + |
| 112 | + _loggerFactory = LoggerFactory.Create(c => |
| 113 | + { |
| 114 | + c.AddConsole(); |
| 115 | + c.SetMinimumLevel(_options.LogLevel); |
| 116 | + }); |
| 117 | + |
| 118 | + listener = new HttpEventSourceListener(_loggerFactory); |
| 119 | + } |
| 120 | + |
106 | 121 | CreateChannels();
|
107 | 122 |
|
108 | 123 | await StartScenario();
|
109 | 124 |
|
110 | 125 | await StopJobAsync();
|
| 126 | + |
| 127 | + listener?.Dispose(); |
111 | 128 | }, new ReflectionBinder<ClientOptions>(options));
|
112 | 129 |
|
113 | 130 | Log("gRPC Client");
|
@@ -383,15 +400,6 @@ private static void CreateChannels()
|
383 | 400 | _latencyPerConnection = new List<List<double>>(_options.Connections);
|
384 | 401 | _latencyAverage = new List<(double sum, int count)>(_options.Connections);
|
385 | 402 |
|
386 |
| - if (_options.LogLevel != LogLevel.None) |
387 |
| - { |
388 |
| - _loggerFactory = LoggerFactory.Create(c => |
389 |
| - { |
390 |
| - c.AddConsole(); |
391 |
| - c.SetMinimumLevel(_options.LogLevel); |
392 |
| - }); |
393 |
| - } |
394 |
| - |
395 | 403 | // Channel does not care about scheme
|
396 | 404 | var initialUri = _options.Url!;
|
397 | 405 | var resolvedUri = initialUri.Authority;
|
|
0 commit comments