public static IEnumerable <IClrObjMappingModel> ExtractFromHeap(this IModelMapperFactory factory, IObjectEnumerationFacade objectEnumeration, ClrRuntime runtime)
 {
     foreach (var clrObject in objectEnumeration.ExtractFromRuntime(runtime))
     {
         yield return(factory.BuildModel(clrObject));
     }
 }
 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;
     }
 }
Exemplo n.º 3
0
        public override IEnumerable <ClrObject> EnumerateObjectsFromSource([NotNull] ClrRuntime runtime)
        {
            var cacheManagerLazyResetableStream = base.EnumerateObjectsFromSource(runtime);

            foreach (var cacheManagerLazyResetable in cacheManagerLazyResetableStream)
            {
                ClrObject cacheManager = ExtractCacheManager(cacheManagerLazyResetable);
                if (cacheManager.Type?.GetFieldByName("cacheReferences") != null)
                {
                    var cacheReferences = cacheManager.GetRefFld("cacheReferences");
                    var cachesByNames   = (IEnumerable)modelMapper.BuildModel(cacheReferences);

                    foreach (DictionaryEntry cacheByNameModel in cachesByNames)
                    {
                        var cachesRegisteredByName = (IEnumerable)cacheByNameModel.Value;
                        foreach (IClrObjMappingModel cache in cachesRegisteredByName)
                        {
                            yield return(cache.Obj);
                        }
                    }
                }
            }
        }
 public static T BuildOfType <T>(this IModelMapperFactory factory, [CanBeNullObject] ClrObject obj) where T : class, IClrObjMappingModel
 {
     return(factory.BuildModel(obj) as T);
 }
Exemplo n.º 5
0
        public virtual IOrderedEnumerable <ContactInfo> ExtractRequestsByContact(ClrRuntime runtime, IModelMapperFactory modelMapperFactory)
        {
            var httpContextStreamClrObject = ObjectFilter.ExtractFromRuntime(runtime, ObjectEnumerator);


            var requestsGroupedByContactID = from clrObject in httpContextStreamClrObject
                                             let context = modelMapperFactory.BuildModel(clrObject) as HttpContextMappingModel
                                                           where IsValid(context)

                                                           let request = context._request as HttpRequestMappingModel
                                                                         where request != null

                                                                         let cookies = request._cookies.Value as HashtableMappingModel
                                                                                       where cookies != null

                                                                                       where cookies.Elements.ContainsKey(TextConstants.CookieNames.SitecoreAnalyticsGlobal)
                                                                                       // where cookies.Elements.ContainsKey(TextConstants.CookieNames.AspNetSession)

                                                                                       let analyticsCookie = cookies[TextConstants.CookieNames.SitecoreAnalyticsGlobal] as HttpCookieModel

                                                                                                             let sessionCookie = cookies[TextConstants.CookieNames.AspNetSession] as HttpCookieModel

                                                                                                                                 where !string.IsNullOrEmpty(analyticsCookie.Value)
                                                                                                                                 // where !string.IsNullOrEmpty(sessionCookie.Value)

                                                                                                                                 let workerRequest = context._wr as IIS7WorkerRequestModel

                                                                                                                                                     where workerRequest != null

                                                                                                                                                     let metadata = new
            {
                context.URL,
                TotalSeconds = Math.Round(context.ExecutionDuration.TotalSeconds, 2),
                analyticsId  = analyticsCookie.Value,
                aspSession   = sessionCookie?.Value ?? "[NoSession]",
                context      = context.HexAddress,
                request      = request.HexAddress
            }

            where metadata.TotalSeconds > 0

            group metadata by metadata.request into uniqueRequests

            let uniqueRequest = uniqueRequests.First()

                                group uniqueRequest by uniqueRequest.analyticsId into grouped

                                orderby grouped.Count() descending

                                let contactInfo = new ContactInfo
            {
                ContactId      = grouped.Key,
                Count          = grouped.Count(),
                DistinctAspNet = grouped.Select(g => g.aspSession).Distinct().Count(),
                Requests       = grouped.Select(requestInfo => new RequestInfo
                {
                    URL          = requestInfo.URL,
                    TotalSeconds = requestInfo.TotalSeconds,
                    aspSession   = requestInfo.aspSession,
                    context      = requestInfo.context,
                    request      = requestInfo.request
                }).OrderByDescending(g => g.TotalSeconds),
            }

            select contactInfo;

            return(requestsGroupedByContactID.OrderByDescending(t => t.Count));
        }