示例#1
0
        public void AddSlowSqlWarnings(string processTag, string processName, Queue <SlowSqlStatementInfo> slowSqls)
        {
            var alert = GetOrCreatePerformanceHint <SlowSqlDetails>(processTag,
                                                                    processName,
                                                                    PerformanceHintType.SqlEtl_SlowSql,
                                                                    $"Slow SQL detected (last {SlowSqlDetails.MaxNumberOfStatements} statements are shown)",
                                                                    out var details);

            foreach (var slowSql in slowSqls)
            {
                details.Add(slowSql);
            }

            _notificationCenter.Add(alert);
        }
示例#2
0
        internal void UpdateNotificationInStorage(object state)
        {
            try
            {
                if (_updateNotificationInStorageRequired == false)
                {
                    return;
                }

                var hint = GetOrCreateSlowWrites(out var details);

                foreach (var info in _slowWrites)
                {
                    details.Writes[info.Key] = info.Value;
                }

                if (details.Writes.Count > SlowWritesDetails.MaxNumberOfWrites)
                {
                    details.Writes = details.Writes.OrderBy(x => x.Value.Date).TakeLast(SlowWritesDetails.MaxNumberOfWrites).ToDictionary(x => x.Key, x => x.Value);
                }

                _notificationCenter.Add(hint);

                _updateNotificationInStorageRequired = false;
            }
            catch (Exception e)
            {
                if (_logger.IsInfoEnabled)
                {
                    _logger.Info("Error in a notification center timer", e);
                }
            }
        }
示例#3
0
        internal void UpdateNotificationInStorage(object state)
        {
            try
            {
                if (_updateNotificationInStorageRequired == false)
                {
                    return;
                }

                var hint = GetOrCreateSlowWrites(out var details);

                foreach (var info in _slowWrites)
                {
                    details.Writes[info.Key] = info.Value;
                }

                _notificationCenter.Add(hint);

                _updateNotificationInStorageRequired = false;
            }
            catch (Exception e)
            {
                if (_logger.IsInfoEnabled)
                {
                    _logger.Info("Error in a notification center timer", e);
                }
            }
        }
示例#4
0
        internal void UpdateRequestLatency(object state)
        {
            try
            {
                if (_needsSync == false)
                {
                    return;
                }

                lock (_addHintSyncObj)
                {
                    _needsSync = false;

                    _performanceHint.RefreshCreatedAt();
                    _notificationCenter.Add(_performanceHint);
                }
            }
            catch (Exception e)
            {
                if (_logger.IsInfoEnabled)
                {
                    _logger.Info("Error in a request latency timer", e);
                }
            }
        }
示例#5
0
 public void AddHint(long duration, string action, string query)
 {
     lock (_addHintSyncObj)
     {
         var requestLatencyPerformanceHint = GetOrCreatePerformanceLatencies(out var details);
         details.Update(duration, action, query);
         _notificationCenter.Add(requestLatencyPerformanceHint);
     }
 }
示例#6
0
 public void AddHint(string queryString, IQueryCollection requestQuery, long duration, string action)
 {
     lock (_addHintSyncObj)
     {
         var requestLatencyPerformanceHint = GetOrCreatePerformanceLatencies(out var details);
         details.Update(queryString, requestQuery, duration, action);
         _notificationCenter.Add(requestLatencyPerformanceHint);
     }
 }
示例#7
0
        public void Add(StorageEnvironment environment, Exception exception)
        {
            var notificationsMetadata = _notificationsMetadataTable.GetOrCreateValue(environment);

            if (notificationsMetadata.TryGetValue(exception.GetType(), out var notificationMetadata))
            {
                if (DateTime.Now - notificationMetadata.Time < _updateFrequency)
                {
                    return;
                }

                if (Interlocked.CompareExchange(ref notificationMetadata.IsInProgress, 1, 0) == 1)
                {
                    return;
                }

                notificationMetadata.Time = DateTime.Now;
            }
            else
            {
                notificationMetadata = new NotificationTime
                {
                    Time         = DateTime.Now,
                    IsInProgress = 1
                };
                if (notificationsMetadata.TryAdd(exception.GetType(), notificationMetadata) == false)
                {
                    return;
                }

                //We are in low of memory so we want to minimize allocations
                notificationMetadata.Key   = $"{environment}:{exception.GetType()}";
                notificationMetadata.Title = $"Out of memory occurred for '{environment}'";
            }

            var alert = AlertRaised.Create(
                null,
                notificationMetadata.Title,
                exception.Message,
                AlertType.OutOfMemoryException,
                NotificationSeverity.Error,
                notificationMetadata.Key,
                OutOfMemoryDetails(exception));

            _notificationsCenter.Add(alert);

            Volatile.Write(ref notificationMetadata.IsInProgress, 0);
        }
        internal void UpdateNotificationInStorage(object state)
        {
            if (_updateNotificationInStorageRequired == false)
            {
                return;
            }

            var hint = GetOrCreateSlowWrites(out var details);

            foreach (var info in _slowWrites)
            {
                details.Writes[info.Key] = info.Value;
            }

            _notificationCenter.Add(hint);

            _updateNotificationInStorageRequired = false;
        }