public virtual void ExtractContextAndRedisCommand(ClrThread thread, ThreadStackEnumerator threadStackObjectEnumerator, IModelMapperFactory factory, IDictionary <string, List <HttpContextMappingModel> > contextsByRedisCommands) { string command = null; HttpContextMappingModel httpContext = null; foreach (var clrObj in threadStackObjectEnumerator.Enumerate(thread)) { ExtractCommandOrContext(clrObj, factory, ref command, ref httpContext); // already extracted both from the thread stack. if (!string.IsNullOrEmpty(command) && (httpContext != null)) { break; } } List <HttpContextMappingModel> httpContextsForGivenRedisCommand = null; if (!string.IsNullOrEmpty(command)) { if (!contextsByRedisCommands.ContainsKey(command)) { httpContextsForGivenRedisCommand = new List <HttpContextMappingModel>(); contextsByRedisCommands.Add(command, httpContextsForGivenRedisCommand); } else { httpContextsForGivenRedisCommand = contextsByRedisCommands[command]; } } if (httpContext?.HasURL == true && httpContext?.Request != null) { if (httpContextsForGivenRedisCommand != null) { httpContextsForGivenRedisCommand.Add(httpContext); } else { if (!contextsByRedisCommands.ContainsKey("NoCommand")) { contextsByRedisCommands.Add("NoCommand", new List <HttpContextMappingModel>()); } var noCommand = contextsByRedisCommands["NoCommand"]; noCommand.Add(httpContext); } } }
private static string FormatLine(HttpContextMappingModel context) { return($"{context.URL} executed for {context.ExecutionDuration.TotalSeconds:F2} sec. AspNet session: {context.Request.AspNetSessionId}"); }
protected virtual void ExtractCommandOrContext(ClrObject clrObj, IModelMapperFactory factory, ref string command, ref HttpContextMappingModel httpContext) { if (clrObj.Type?.IsString == true) { command = clrObj.GetStringSafeFromSelf(); } else { httpContext = factory.BuildModel(clrObj) as HttpContextMappingModel; } }
protected virtual bool IsValid(HttpContextMappingModel context) { return(context?.HasURL == true);//&& context.HasThreadAssigned; }