/// <summary> /// This override logs the incoming and outgoing transaction to the Microservice Data Collector. /// </summary> /// <param name="actionExecutedContext">The context.</param> /// <param name="cancellationToken">The cancellation token.</param> /// <returns>Returns the pass through task.</returns> public override async Task OnActionExecutedAsync(HttpActionExecutedContext actionExecutedContext, CancellationToken cancellationToken) { var ms = actionExecutedContext.ToMicroservice(); if (ms != null && mLevel > ApiBoundaryLoggingFilterLevel.None) { var bEvent = new ApiBoundaryEvent(actionExecutedContext, mLevel); // Retrieve the correlation id from the request and add to the response IEnumerable <string> correlationValuesOut; if (actionExecutedContext.Response.Headers.TryGetValues(mCorrelationIdKeyName, out correlationValuesOut)) { bEvent.CorrelationId = correlationValuesOut.FirstOrDefault(); } //Ok, check the outbound response if the correlation id was not set on the outgoing request. if (string.IsNullOrEmpty(bEvent.CorrelationId)) { IEnumerable <string> correlationValuesin; if (actionExecutedContext.Request.Headers.TryGetValues(mCorrelationIdKeyName, out correlationValuesin)) { bEvent.CorrelationId = correlationValuesin.FirstOrDefault(); } } ms.DataCollection.Write(bEvent, DataCollectionSupport.ApiBoundary, false); } await base.OnActionExecutedAsync(actionExecutedContext, cancellationToken); }