Exemplo n.º 1
0
 public static PerfCounter[] AddDefaultCountersForClient(string clientId, PerfCounter[] existingCounters)
 {
     // TODO:    add existingCounters if they are valid counters and remove set from default.
     //          the hash for existingCounters may be stale, so need to recalc and then match.
     _clientPerformanceCounters.TryAdd(clientId, _defaultPerformanceCounters.ToList());
     // take snapshot of current counters. another client may be updating it.
     var allCounters = _perfomanceCounters.ToDictionary(x => x.Key, x => x.Value);
     // default counters should never be removed. so this is safe.
     return _defaultPerformanceCounters.Select(x => new { hash = x, counter = allCounters[x] }).Select(x => new PerfCounter() { CategoryName = x.counter.CategoryName, CounterHelp = x.counter.CounterHelp, CounterName = x.counter.CounterName, CounterType = x.counter.CounterType.ToString(), InstanceName = x.counter.InstanceName, Hash = x.hash }).ToArray();
 }
Exemplo n.º 2
0
 public object GetPerformanceCounters(PerfCounter[] existingCounters)
 {
     return new { snapshotMilliseconds = PerformanceCounterUtils.SNAPSHOT_MILLISECONDS, perfCounters = PerformanceCounterUtils.AddDefaultCountersForClient(Context.ConnectionId, existingCounters) };
 }