Beispiel #1
0
        public override void OnActionExecuted(ActionExecutedContext context)
        {
            var dict = new Dictionary <string, object>();

            if (context.RouteData.Values?.Keys != null)
            {
                foreach (var key in context.RouteData.Values?.Keys)
                {
                    dict.Add($"RouteData-{key}", (string)context.RouteData.Values[key]);
                }
            }

            PioneerLogsTub.LogUsage(Message, context.HttpContext, dict);
        }
Beispiel #2
0
        private static async Task Invoke(HttpContext context, Exception ex)
        {
            context.Response.ContentType = "application/json";
            context.Response.StatusCode  = (int)HttpStatusCode.InternalServerError;

            PioneerLogsTub.LogError(ex, context);

            var errorId      = Activity.Current?.Id ?? context.TraceIdentifier;
            var jsonResponse = JsonConvert.SerializeObject(new PioneerLogsErrorResponse
            {
                CorrelationId = errorId,
                Message       = "Internal server error."
            });

            await context.Response.WriteAsync(jsonResponse, Encoding.UTF8);
        }
        public void OnActionExecuting(ActionExecutingContext context)
        {
            var request = context.HttpContext.Request;
            var message = $"{request.Path}-{request.Method}";

            var dict = new Dictionary <string, object>();

            if (context.RouteData.Values?.Keys != null)
            {
                foreach (var key in context.RouteData.Values?.Keys)
                {
                    dict.Add($"RouteData-{key}", (string)context.RouteData.Values[key]);
                }
            }

            var details = PioneerLogsTub.GetTubEcsDetail(message, LevelEnum.Performance, context.HttpContext, dict);

            _tracker = new PioneerLogsPerformanceTracker(details);
        }