Example #1
0
        /// <summary>
        /// 过滤条件(filter)
        /// </summary>
        /// <returns></returns>
        public virtual string GetFilter()
        {
            var filters = new Dictionary <string, string>();

            if (EntityNames?.Any() == true)
            {
                filters.Add("entity_names", string.Join(",", EntityNames));
            }

            if (ActiveTime != null)
            {
                filters.Add("active_time", ActiveTime.Value.ToUtcTicks().ToString());
            }
            else if (InactiveTime != null)
            {
                filters.Add("inactive_time", InactiveTime.Value.ToUtcTicks().ToString());
            }

            if (Columns?.Any() == true)
            {
                foreach (var c in Columns)
                {
                    filters[c.Key] = c.Value;
                }
            }
            if (filters.Any())
            {
                return(string.Join("|", filters.Select(o => $"{o.Key}:{o.Value}")));
            }
            else
            {
                return(null);
            }
        }
Example #2
0
        public bool IsInteresting(SessionConfiguration configuration = null)
        {
            if (configuration == null)
            {
                return(true);
            }
            if (!configuration.Enabled)
            {
                return(false);
            }

            var monitoredStatistics = configuration.MonitoredStatistics;
            var filterStats         = (monitoredStatistics?.Count).GetValueOrDefault(0) > 0;

            EntityDeleteCount                = GetValue(configuration, EntityDeleteCount, "EntityDeleteCount", monitoredStatistics, filterStats) as long?;
            EntityInsertCount                = GetValue(configuration, EntityInsertCount, "EntityInsertCount", monitoredStatistics, filterStats) as long?;
            EntityLoadCount                  = GetValue(configuration, EntityLoadCount, "EntityLoadCount", monitoredStatistics, filterStats) as long?;
            EntityFetchCount                 = GetValue(configuration, EntityFetchCount, "EntityFetchCount", monitoredStatistics, filterStats) as long?;
            EntityUpdateCount                = GetValue(configuration, EntityUpdateCount, "EntityUpdateCount", monitoredStatistics, filterStats) as long?;
            QueryExecutionCount              = GetValue(configuration, QueryExecutionCount, "QueryExecutionCount", monitoredStatistics, filterStats) as long?;
            QueryExecutionMaxTime            = GetValue(configuration, QueryExecutionMaxTime, "QueryExecutionMaxTime", monitoredStatistics, filterStats) as TimeSpan?;
            QueryExecutionMaxTimeQueryString = GetValue(configuration, QueryExecutionMaxTimeQueryString, "QueryExecutionMaxTimeQueryString", monitoredStatistics, filterStats) as string;

            QueryCacheHitCount        = GetValue(configuration, QueryCacheHitCount, "QueryCacheHitCount", monitoredStatistics, filterStats) as long?;
            QueryCacheMissCount       = GetValue(configuration, QueryCacheMissCount, "QueryCacheMissCount", monitoredStatistics, filterStats) as long?;
            QueryCachePutCount        = GetValue(configuration, QueryCachePutCount, "QueryCachePutCount", monitoredStatistics, filterStats) as long?;
            FlushCount                = GetValue(configuration, FlushCount, "FlushCount", monitoredStatistics, filterStats) as long?;
            ConnectCount              = GetValue(configuration, ConnectCount, "ConnectCount", monitoredStatistics, filterStats) as long?;
            SecondLevelCacheHitCount  = GetValue(configuration, SecondLevelCacheHitCount, "SecondLevelCacheHitCount", monitoredStatistics, filterStats) as long?;
            SecondLevelCacheMissCount = GetValue(configuration, SecondLevelCacheMissCount, "SecondLevelCacheMissCount", monitoredStatistics, filterStats) as long?;
            SecondLevelCachePutCount  = GetValue(configuration, SecondLevelCachePutCount, "SecondLevelCachePutCount", monitoredStatistics, filterStats) as long?;
            SessionCloseCount         = GetValue(configuration, SessionCloseCount, "SessionCloseCount", monitoredStatistics, filterStats) as long?;
            SessionOpenCount          = GetValue(configuration, SessionOpenCount, "SessionOpenCount", monitoredStatistics, filterStats) as long?;
            CollectionLoadCount       = GetValue(configuration, CollectionLoadCount, "CollectionLoadCount", monitoredStatistics, filterStats) as long?;
            CollectionFetchCount      = GetValue(configuration, CollectionFetchCount, "CollectionFetchCount", monitoredStatistics, filterStats) as long?;
            CollectionUpdateCount     = GetValue(configuration, CollectionUpdateCount, "CollectionUpdateCount", monitoredStatistics, filterStats) as long?;
            CollectionRemoveCount     = GetValue(configuration, CollectionRemoveCount, "CollectionRemoveCount", monitoredStatistics, filterStats) as long?;
            CollectionRecreateCount   = GetValue(configuration, CollectionRecreateCount, "CollectionRecreateCount", monitoredStatistics, filterStats) as long?;

            StartTime = GetValue(configuration, StartTime, "StartTime", monitoredStatistics, filterStats) as DateTime?;

            Queries                     = GetValue(configuration, Queries, "Queries", monitoredStatistics, filterStats) as string[];
            EntityNames                 = GetValue(configuration, EntityNames, "EntityNames", monitoredStatistics, filterStats) as string[];
            CollectionRoleNames         = GetValue(configuration, CollectionRoleNames, "CollectionRoleNames", monitoredStatistics, filterStats) as string[];
            SecondLevelCacheRegionNames = GetValue(configuration, SecondLevelCacheRegionNames, "SecondLevelCacheRegionNames", monitoredStatistics, filterStats) as string[];

            SuccessfulTransactionCount = GetValue(configuration, SuccessfulTransactionCount, "SuccessfulTransactionCount", monitoredStatistics, filterStats) as long?;
            TransactionCount           = GetValue(configuration, TransactionCount, "TransactionCount", monitoredStatistics, filterStats) as long?;
            PrepareStatementCount      = GetValue(configuration, PrepareStatementCount, "PrepareStatementCount", monitoredStatistics, filterStats) as long?;
            CloseStatementCount        = GetValue(configuration, CloseStatementCount, "CloseStatementCount", monitoredStatistics, filterStats) as long?;
            OptimisticFailureCount     = GetValue(configuration, OptimisticFailureCount, "OptimisticFailureCount", monitoredStatistics, filterStats) as long?;

            OperationThreshold = GetValue(configuration, OperationThreshold, "OperationThreshold", monitoredStatistics, filterStats) as TimeSpan?;

            var isInteresting = (
                EntityDeleteCount.HasValue ||
                EntityInsertCount.HasValue ||
                EntityLoadCount.HasValue ||
                EntityFetchCount.HasValue ||
                EntityUpdateCount.HasValue ||
                QueryExecutionCount.HasValue ||
                QueryExecutionMaxTime.HasValue ||
                !string.IsNullOrWhiteSpace(QueryExecutionMaxTimeQueryString) ||
                QueryCacheHitCount.HasValue ||
                QueryCacheMissCount.HasValue ||
                QueryCachePutCount.HasValue ||
                FlushCount.HasValue ||
                ConnectCount.HasValue ||
                SecondLevelCacheHitCount.HasValue ||
                SecondLevelCacheMissCount.HasValue ||
                SecondLevelCachePutCount.HasValue ||
                SessionCloseCount.HasValue ||
                SessionOpenCount.HasValue ||
                CollectionLoadCount.HasValue ||
                CollectionFetchCount.HasValue ||
                CollectionUpdateCount.HasValue ||
                CollectionRemoveCount.HasValue ||
                CollectionRecreateCount.HasValue ||
                StartTime.HasValue ||
                Queries?.Any() == true ||
                EntityNames?.Any() == true ||
                CollectionRoleNames?.Any() == true ||
                SecondLevelCacheRegionNames?.Any() == true ||
                SuccessfulTransactionCount.HasValue ||
                TransactionCount.HasValue ||
                PrepareStatementCount.HasValue ||
                CloseStatementCount.HasValue ||
                OptimisticFailureCount.HasValue ||
                OperationThreshold.HasValue
                );

            return(isInteresting);
        }