Exemple #1
0
 private void UploadWaits(SqlConnection conn, SqlTransaction tran, IEnumerable <Interval> intervals)
 {
     lock (waitsData)
     {
         WaitStatsSnapshot.SaveToDatabase(conn, WaitStatsTargetTable, waitsData, tran, intervals);
     }
 }
Exemple #2
0
        private void CollectWaits(string serverName, SqlConnection targetConnection)
        {
            var currentSnapshot = WaitStatsSnapshot.Take(targetConnection);

            foreach (var snap in currentSnapshot)
            {
                var baseSnap = baseWaitStats.FirstOrDefault(s => s.Type == snap.Type && s.Interval.Server.Name == serverName);
                if (baseSnap != null)
                {
                    // take a copy of this snapshot
                    var tmpSnap = (WaitStatsSnapshot)snap.Clone();

                    // rebase wait stats
                    snap.Seconds         -= baseSnap.Seconds;
                    snap.ResourceSeconds -= baseSnap.ResourceSeconds;
                    snap.SignalSeconds   -= baseSnap.SignalSeconds;
                    snap.Count           -= baseSnap.Count;

                    snap.Rebased = true;

                    baseWaitStats[baseWaitStats.IndexOf(baseSnap)] = tmpSnap;
                }
                else
                {
                    // base wait not found: it needs to be added to the cache
                    baseWaitStats.Add(snap);
                }
            }

            lock (waitsData)
            {
                waitsData.AddRange(currentSnapshot.Where(t => t.Rebased));
            }
        }