3737using Grpc . Core ;
3838using Grpc . Net . Client ;
3939using Grpc . Testing ;
40+ using Microsoft . Crank . EventSources ;
4041using Microsoft . Extensions . Logging ;
4142
4243namespace GrpcClient
@@ -96,9 +97,9 @@ public static async Task<int> Main(string[] args)
9697 Log ( $ "{ nameof ( GCSettings . IsServerGC ) } : { isServerGC } ") ;
9798 Log ( $ "{ nameof ( Environment . ProcessorCount ) } : { processorCount } ") ;
9899
99- BenchmarksEventSource . Log . Metadata ( "NetCoreAppVersion" , "first" , "first" , ".NET Runtime Version" , ".NET Runtime Version" , "" ) ;
100- BenchmarksEventSource . Log . Metadata ( "IsServerGC" , "first" , "first" , "Server GC enabled" , "Server GC is enabled" , "" ) ;
101- BenchmarksEventSource . Log . Metadata ( "ProcessorCount" , "first" , "first" , "Processor Count" , "Processor Count" , "n0" ) ;
100+ BenchmarksEventSource . Register ( "NetCoreAppVersion" , Operations . First , Operations . First , ".NET Runtime Version" , ".NET Runtime Version" , "" ) ;
101+ BenchmarksEventSource . Register ( "IsServerGC" , Operations . First , Operations . First , "Server GC enabled" , "Server GC is enabled" , "" ) ;
102+ BenchmarksEventSource . Register ( "ProcessorCount" , Operations . First , Operations . First , "Processor Count" , "Processor Count" , "n0" ) ;
102103
103104 BenchmarksEventSource . Measure ( "NetCoreAppVersion" , runtimeVersion ) ;
104105 BenchmarksEventSource . Measure ( "IsServerGC" , isServerGC . ToString ( ) ) ;
@@ -200,7 +201,7 @@ private static async Task StopJobAsync()
200201 _lock . Release ( ) ;
201202 }
202203
203- BenchmarksEventSource . Log . Metadata ( "grpc/raw-errors" , "all" , "all" , "Raw errors" , "Raw errors" , "object" ) ;
204+ BenchmarksEventSource . Register ( "grpc/raw-errors" , Operations . All , Operations . All , "Raw errors" , "Raw errors" , "object" ) ;
204205 BenchmarksEventSource . Measure ( "grpc/raw-errors" , _errorStringBuilder . ToString ( ) ) ;
205206 }
206207
@@ -245,26 +246,26 @@ private static void CalculateStatistics()
245246 Log ( $ "Total requests: { requestDelta } ") ;
246247 Log ( $ "Total errors: { errors } ") ;
247248
248- BenchmarksEventSource . Log . Metadata ( "grpc/rps/max" , "max" , "sum" , "Max RPS" , "RPS: max" , "n0" ) ;
249- BenchmarksEventSource . Log . Metadata ( "grpc/requests" , "max" , "sum" , "Requests" , "Total number of requests" , "n0" ) ;
250- BenchmarksEventSource . Log . Metadata ( "grpc/errors/badresponses" , "max" , "sum" , "Bad responses" , "Non-2xx or 3xx responses" , "n0" ) ;
249+ BenchmarksEventSource . Register ( "grpc/rps/max;http/rps/mean " , Operations . Max , Operations . Sum , "Max RPS" , "RPS: max" , "n0" ) ;
250+ BenchmarksEventSource . Register ( "grpc/requests;http/requests " , Operations . Max , Operations . Sum , "Requests" , "Total number of requests" , "n0" ) ;
251+ BenchmarksEventSource . Register ( "grpc/errors/badresponses;http/requests/badresponses " , Operations . Max , Operations . Sum , "Bad responses" , "Non-2xx or 3xx responses" , "n0" ) ;
251252
252- BenchmarksEventSource . Measure ( "grpc/rps/max" , rps ) ;
253- BenchmarksEventSource . Measure ( "grpc/requests" , requestDelta ) ;
254- BenchmarksEventSource . Measure ( "grpc/errors/badresponses" , errors ) ;
253+ BenchmarksEventSource . Measure ( "grpc/rps/max;http/rps/mean " , rps ) ;
254+ BenchmarksEventSource . Measure ( "grpc/requests;http/requests " , requestDelta ) ;
255+ BenchmarksEventSource . Measure ( "grpc/errors/badresponses;http/requests/badresponses " , errors ) ;
255256
256257 // Latency
257258 CalculateLatency ( ) ;
258259 }
259260
260261 private static void CalculateLatency ( )
261262 {
262- BenchmarksEventSource . Log . Metadata ( "grpc/latency/mean" , "max" , "sum" , "Mean latency (ms)" , "Mean latency (ms)" , "n0 " ) ;
263- BenchmarksEventSource . Log . Metadata ( "grpc/latency/50" , "max" , "sum" , "50th percentile latency (ms)" , "50th percentile latency (ms)" , "n0 " ) ;
264- BenchmarksEventSource . Log . Metadata ( "grpc/latency/75" , "max" , "sum" , "75th percentile latency (ms)" , "75th percentile latency (ms)" , "n0 " ) ;
265- BenchmarksEventSource . Log . Metadata ( "grpc/latency/90" , "max" , "sum" , "90th percentile latency (ms)" , "90th percentile latency (ms)" , "n0 " ) ;
266- BenchmarksEventSource . Log . Metadata ( "grpc/latency/99" , "max" , "sum" , "99th percentile latency (ms)" , "99th percentile latency (ms)" , "n0 " ) ;
267- BenchmarksEventSource . Log . Metadata ( "grpc/latency/max" , "max" , "sum" , "Max latency (ms)" , "Max latency (ms)" , "n0 " ) ;
263+ BenchmarksEventSource . Register ( "grpc/latency/mean;http/latency/mean " , Operations . Max , Operations . Sum , "Mean latency (ms)" , "Mean latency (ms)" , "n2 " ) ;
264+ BenchmarksEventSource . Register ( "grpc/latency/50;http/latency/50 " , Operations . Max , Operations . Sum , "50th percentile latency (ms)" , "50th percentile latency (ms)" , "n2 " ) ;
265+ BenchmarksEventSource . Register ( "grpc/latency/75;http/latency/75 " , Operations . Max , Operations . Sum , "75th percentile latency (ms)" , "75th percentile latency (ms)" , "n2 " ) ;
266+ BenchmarksEventSource . Register ( "grpc/latency/90;http/latency/90 " , Operations . Max , Operations . Sum , "90th percentile latency (ms)" , "90th percentile latency (ms)" , "n2 " ) ;
267+ BenchmarksEventSource . Register ( "grpc/latency/99;http/latency/99 " , Operations . Max , Operations . Sum , "99th percentile latency (ms)" , "99th percentile latency (ms)" , "n2 " ) ;
268+ BenchmarksEventSource . Register ( "grpc/latency/max;http/latency/max " , Operations . Max , Operations . Sum , "Max latency (ms)" , "Max latency (ms)" , "n2 " ) ;
268269 if ( _options . Latency )
269270 {
270271 var totalCount = 0 ;
@@ -282,7 +283,7 @@ private static void CalculateLatency()
282283
283284 var mean = ( totalCount != 0 ) ? totalSum / totalCount : totalSum ;
284285
285- BenchmarksEventSource . Measure ( "grpc/latency/mean" , mean ) ;
286+ BenchmarksEventSource . Measure ( "grpc/latency/mean;http/latency/mean " , mean ) ;
286287
287288 var allConnections = new List < double > ( ) ;
288289 foreach ( var connectionLatency in _latencyPerConnection )
@@ -295,11 +296,11 @@ private static void CalculateLatency()
295296 // Or we could preserve the results for each one and record them separately
296297 allConnections . Sort ( ) ;
297298
298- BenchmarksEventSource . Measure ( "grpc/latency/50" , GetPercentile ( 50 , allConnections ) ) ;
299- BenchmarksEventSource . Measure ( "grpc/latency/75" , GetPercentile ( 75 , allConnections ) ) ;
300- BenchmarksEventSource . Measure ( "grpc/latency/90" , GetPercentile ( 90 , allConnections ) ) ;
301- BenchmarksEventSource . Measure ( "grpc/latency/99" , GetPercentile ( 99 , allConnections ) ) ;
302- BenchmarksEventSource . Measure ( "grpc/latency/max" , GetPercentile ( 100 , allConnections ) ) ;
299+ BenchmarksEventSource . Measure ( "grpc/latency/50;http/latency/50 " , GetPercentile ( 50 , allConnections ) ) ;
300+ BenchmarksEventSource . Measure ( "grpc/latency/75;http/latency/75 " , GetPercentile ( 75 , allConnections ) ) ;
301+ BenchmarksEventSource . Measure ( "grpc/latency/90;http/latency/90 " , GetPercentile ( 90 , allConnections ) ) ;
302+ BenchmarksEventSource . Measure ( "grpc/latency/99;http/latency/99 " , GetPercentile ( 99 , allConnections ) ) ;
303+ BenchmarksEventSource . Measure ( "grpc/latency/max;http/latency/max " , GetPercentile ( 100 , allConnections ) ) ;
303304
304305 Log ( $ "Mean latency: { mean : 0.###} ms") ;
305306 Log ( $ "Max latency: { GetPercentile ( 100 , allConnections ) : 0.###} ms") ;
@@ -320,8 +321,8 @@ private static void CalculateLatency()
320321
321322 var mean = ( totalCount != 0 ) ? totalSum / totalCount : totalSum ;
322323
323- BenchmarksEventSource . Measure ( "grpc/latency/mean" , mean ) ;
324- BenchmarksEventSource . Measure ( "grpc/latency/max" , _maxLatency ) ;
324+ BenchmarksEventSource . Measure ( "grpc/latency/mean;http/latency/mean " , mean ) ;
325+ BenchmarksEventSource . Measure ( "grpc/latency/max;http/latency/max " , _maxLatency ) ;
325326
326327 Log ( $ "Mean latency: { mean : 0.###} ms") ;
327328 Log ( $ "Max latency: { _maxLatency : 0.###} ms") ;
0 commit comments