public static void AddOperation(ResourceExecutingContext context, string serviceComponent) { var actionDescriptor = (ControllerActionDescriptor)context.ActionDescriptor; var operationData = OperationData.CreateGeneric(serviceComponent, actionDescriptor.ActionName); Operation operation = Logger.StartOperation(operationData); operation.AddProperty("HttpRequestPort", context.HttpContext.Request.Host.Port ?? -1); operation.AddProperty("HttpRequestIsHttps", context.HttpContext.Request.IsHttps); // Set CorrelationId and traffic source at Task level such that it will be available to all downstream operations in the context of the request Logger.SetCorrelationId(GetCorrolationId(context.HttpContext.Request.Headers)); if (context.HttpContext.Request.Headers.TryGetValue( HttpHeader.TestTrafficToken, out StringValues trafficSourceString)) { Logger.SetTrafficSource(trafficSourceString); } // If we are expecting failure (in case of negative test), we won't log this operation as failed if (context.HttpContext.Request.Headers.ContainsKey(HttpHeader.ExpectingFail)) { operation.AddProperty(HttpHeader.ExpectingFail, "true"); operation.ExpectedToFail = true; } context.HttpContext.Items.Add(OperationPropertyName, operation); }