public void RecordRpcStats() { var gameletData = new DeveloperLogEvent.Types.GameletData { Type = DeveloperLogEvent.Types.GameletData.Types.Type.GameletEdge }; var rpcAction = actionRecorder.CreateToolAction(MetricActionType); rpcAction.Record(delegate { rpcAction.UpdateEvent(new DeveloperLogEvent { GameletData = gameletData }); (rpcAction as RpcRecorder).Record(FakeMethod, Status.DefaultSuccess, 1000); }); var expectedRpcDetails = new GrpcServiceCallDetails { ServiceName = FakeServiceName, ServiceMethod = FakeMethodName, Status = new Status(StatusCode.OK, null), RoundtripLatency = 1000 * 1000 // 1000ms in us }; if (logEvent.GrpcCallDetails == null) { logEvent.GrpcCallDetails = new List <GrpcServiceCallDetails>(); } logEvent.GrpcCallDetails.Add(expectedRpcDetails); logEvent.GameletData = gameletData; metrics.Received(1).RecordEvent(EventType, logEvent); AssertTimerUsedCorrectly(); }
public async Task RecordAsyncSuccessAsync() { var gameletData = new DeveloperLogEvent.Types.GameletData { Type = DeveloperLogEvent.Types.GameletData.Types.Type.GameletEdge }; var action = actionRecorder.CreateToolAction(MetricActionType); await action.RecordAsync(Task.Run(() => { action.UpdateEvent(new DeveloperLogEvent { GameletData = gameletData }); action.Record(FakeMethod, Status.DefaultSuccess, 1000); })); var expectedRpcDetails = new GrpcServiceCallDetails { ServiceName = FakeServiceName, ServiceMethod = FakeMethodName, Status = new Status(StatusCode.OK, null), RoundtripLatency = 1000 * 1000 // 1000ms in us }; logEvent.GrpcCallDetails.Add(expectedRpcDetails); logEvent.GameletData = gameletData; metrics.Received(1).RecordEvent(EventType, logEvent); AssertTimerUsedCorrectly(); }
static DeveloperLogEvent RecordRpcException(RpcException e) { var logEvent = new DeveloperLogEvent(); logEvent.StatusCode = ClassifyGrpcStatus(e.Status); var serviceName = e.Data[ErrorData.ServiceNameKey] as string; var methodName = e.Data[ErrorData.MethodNameKey] as string; var details = new GrpcServiceCallDetails { Status = e.Status }; if (!string.IsNullOrEmpty(serviceName)) { details.ServiceName = serviceName; } if (!string.IsNullOrEmpty(methodName)) { details.ServiceMethod = methodName; } logEvent.GrpcErrorDetails = details; return(logEvent); }
public void Record_RpcError(StatusCode rpcCode, DeveloperEventStatus.Types.Code statusCode) { Assert.Throws <CloudException>( delegate { actionRecorder.RecordToolAction(MetricActionType, delegate { try { throw new RpcException(new Status(rpcCode, "test")); } catch (RpcException e) { if (rpcCode != StatusCode.Unknown) { e.Data[ErrorData.ServiceNameKey] = FakeServiceName; e.Data[ErrorData.MethodNameKey] = FakeMethodName; } throw new CloudException("Test", e); } }); }); var expectedDetails = new GrpcServiceCallDetails { Status = new Status(rpcCode, null) }; if (rpcCode != StatusCode.Unknown) { expectedDetails.ServiceName = FakeServiceName; expectedDetails.ServiceMethod = FakeMethodName; } logEvent.StatusCode = statusCode; logEvent.GrpcErrorDetails = expectedDetails; metrics.Received(1).RecordEvent(EventType, logEvent); AssertTimerUsedCorrectly(); }