Beispiel #1
0
        public async Task <ServerResponse> SendAsync(ClientRequest request)
        {
            var start    = GetTimestamp();
            var response = new ServerResponse(request);

            try {
                RequestStarting?.Invoke(this, new RequestStartingEventArgs(request));
                await SendAsync(request, response);

                response.DurationMs = GetTimeSince(start);
                RequestCompleted?.Invoke(this, new RequestCompletedEventArgs(response));
            } catch (Exception ex) {
                response.Exception = ex;
                RequestCompleted?.Invoke(this, new RequestCompletedEventArgs(response));
                if (response.Exception != null)
                {
                    if (response.Exception == ex)
                    {
                        throw;
                    }
                    else
                    {
                        throw response.Exception; //throw new exception
                    }
                }
            }
            return(response);
        }
Beispiel #2
0
            public void LogRequestStarting()
            {
                var requestStarting = new RequestStarting(new HttpRequestContext(_context), out _logContext);

                _logOverheadStopwatch.Start();
                _log.Info(requestStarting);
                _logOverheadStopwatch.Stop();

                _requestStopwatch.Restart();
            }
Beispiel #3
0
 protected override void OnRequestStart(RequestDiagnosticData data)
 {
     RequestStarting?.Invoke(data.Operation, data.RequestContext);
 }
Beispiel #4
0
 // events -----------------------
 internal void OnRequestStarting(RequestContext context)
 {
     RequestStarting?.Invoke(this, new GraphQLServerEventArgs(context));
 }