protected override async Task <HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) { // Log request string requestId = Guid.NewGuid().ToString(); request.Headers.Add("client-request-id", requestId); var requestLog = new GraphLogEntry(request); await requestLog.LoadBody(request); await DatabaseHelper.AddGraphLog(requestLog); try { HttpResponseMessage response = await base.SendAsync(request, cancellationToken); // Log response var responseLog = new GraphLogEntry(response); await responseLog.LoadBody(response); await DatabaseHelper.AddGraphLog(responseLog); return(response); } catch (Exception ex) { await DatabaseHelper.AddGraphLog(new GraphLogEntry(ex, requestId)); throw; } }
public static async Task <Document> AddGraphLog(GraphLogEntry entry) { Document document = await client.CreateDocumentAsync( UriFactory.CreateDocumentCollectionUri(databaseName, loggingCollectionName), entry); return(document); }