private static void CallOnAllCounters(string methodName, Message message, Uri listenUri, bool includeOperations) { if (((message != null) && (message.Headers != null)) && ((null != message.Headers.To) && (null != listenUri))) { ServiceModelPerformanceCountersEntry serviceModelPerformanceCountersBaseUri = GetServiceModelPerformanceCountersBaseUri(listenUri.AbsoluteUri.ToUpperInvariant()); if (serviceModelPerformanceCountersBaseUri != null) { InvokeMethod(serviceModelPerformanceCountersBaseUri.ServicePerformanceCounters, methodName); if (Scope == PerformanceCounterScope.All) { foreach (ServiceModelPerformanceCounters counters in serviceModelPerformanceCountersBaseUri.CounterList) { if (counters.EndpointPerformanceCounters != null) { InvokeMethod(counters.EndpointPerformanceCounters, methodName); } if (includeOperations) { OperationPerformanceCountersBase operationPerformanceCountersFromMessage = counters.GetOperationPerformanceCountersFromMessage(message); if (operationPerformanceCountersFromMessage != null) { InvokeMethod(operationPerformanceCountersFromMessage, methodName); } } } } } } }
static ServiceModelPerformanceCountersEntry GetServiceModelPerformanceCountersBaseUri(string uri) { ServiceModelPerformanceCountersEntry counters = null; if (!String.IsNullOrEmpty(uri)) { PerformanceCounters.PerformanceCountersForBaseUri.TryGetValue(uri, out counters); } return(counters); }
private static ServiceModelPerformanceCountersEntry GetServiceModelPerformanceCountersBaseUri(string uri) { ServiceModelPerformanceCountersEntry entry = null; if (!string.IsNullOrEmpty(uri)) { PerformanceCountersForBaseUri.TryGetValue(uri, out entry); } return(entry); }
internal static void MsmqRejectedMessage(string uri) { if (PerformanceCounters.Scope == PerformanceCounterScope.All) { ServiceModelPerformanceCountersEntry counters = PerformanceCounters.GetServiceModelPerformanceCountersBaseUri(uri); if (null != counters) { counters.ServicePerformanceCounters.MsmqRejectedMessage(); } } }
internal static void MsmqRejectedMessage(string uri) { if (Scope == PerformanceCounterScope.All) { ServiceModelPerformanceCountersEntry serviceModelPerformanceCountersBaseUri = GetServiceModelPerformanceCountersBaseUri(uri); if (serviceModelPerformanceCountersBaseUri != null) { serviceModelPerformanceCountersBaseUri.ServicePerformanceCounters.MsmqRejectedMessage(); } } }
internal static void AddPerformanceCountersForEndpoint(ServiceHostBase serviceHost, ContractDescription contractDescription, EndpointDispatcher endpointDispatcher) { if ((PerformanceCountersEnabled || MinimalPerformanceCountersEnabled) && endpointDispatcher.SetPerfCounterId()) { ServiceModelPerformanceCounters counters; lock (perfCounterDictionarySyncObject) { if (!PerformanceCountersForEndpoint.TryGetValue(endpointDispatcher.PerfCounterId, out counters)) { counters = new ServiceModelPerformanceCounters(serviceHost, contractDescription, endpointDispatcher); if (!counters.Initialized) { return; } PerformanceCountersForEndpoint.Add(endpointDispatcher.PerfCounterId, counters); int num = PerformanceCountersForEndpointList.FindIndex(c => c == null); if (num >= 0) { PerformanceCountersForEndpointList[num] = counters; } else { PerformanceCountersForEndpointList.Add(counters); num = PerformanceCountersForEndpointList.Count - 1; } endpointDispatcher.PerfCounterInstanceId = num; } } lock (perfCounterDictionarySyncObject) { ServiceModelPerformanceCountersEntry entry; if (!PerformanceCountersForBaseUri.TryGetValue(endpointDispatcher.PerfCounterBaseId, out entry)) { if (PerformanceCountersEnabled) { entry = new ServiceModelPerformanceCountersEntry(serviceHost.Counters); } else if (MinimalPerformanceCountersEnabled) { entry = new ServiceModelPerformanceCountersEntry(serviceHost.DefaultCounters); } PerformanceCountersForBaseUri.Add(endpointDispatcher.PerfCounterBaseId, entry); } entry.Add(counters); } } }
internal static void SessionFaulted(string uri) { ServiceModelPerformanceCountersEntry serviceModelPerformanceCountersBaseUri = GetServiceModelPerformanceCountersBaseUri(uri); if (serviceModelPerformanceCountersBaseUri != null) { serviceModelPerformanceCountersBaseUri.ServicePerformanceCounters.SessionFaulted(); if (Scope == PerformanceCounterScope.All) { foreach (ServiceModelPerformanceCounters counters in serviceModelPerformanceCountersBaseUri.CounterList) { if (counters.EndpointPerformanceCounters != null) { counters.EndpointPerformanceCounters.SessionFaulted(); } } } } }
internal static void MessageDropped(string uri) { ServiceModelPerformanceCountersEntry counters = PerformanceCounters.GetServiceModelPerformanceCountersBaseUri(uri); if (null != counters) { counters.ServicePerformanceCounters.MessageDropped(); if (PerformanceCounters.Scope == PerformanceCounterScope.All) { List <ServiceModelPerformanceCounters> counters2 = counters.CounterList; foreach (ServiceModelPerformanceCounters sCounters in counters2) { if (sCounters.EndpointPerformanceCounters != null) { sCounters.EndpointPerformanceCounters.MessageDropped(); } } } } }
static void CallOnAllCounters(string methodName, Message message, Uri listenUri, bool includeOperations) { Fx.Assert(null != message, "message must not be null"); Fx.Assert(null != listenUri, "listenUri must not be null"); if (null != message && null != message.Headers && null != message.Headers.To && null != listenUri) { string uri = listenUri.AbsoluteUri.ToUpperInvariant(); ServiceModelPerformanceCountersEntry counters = PerformanceCounters.GetServiceModelPerformanceCountersBaseUri(uri); if (null != counters) { Fx.Assert(null != counters.ServicePerformanceCounters, "counters.ServicePerformanceCounters must not be null"); PerformanceCounters.InvokeMethod(counters.ServicePerformanceCounters, methodName); if (PerformanceCounters.Scope == PerformanceCounterScope.All) { List <ServiceModelPerformanceCounters> counters2 = counters.CounterList; foreach (ServiceModelPerformanceCounters sCounters in counters2) { if (sCounters.EndpointPerformanceCounters != null) { PerformanceCounters.InvokeMethod(sCounters.EndpointPerformanceCounters, methodName); } if (includeOperations) { OperationPerformanceCountersBase oCounters = sCounters.GetOperationPerformanceCountersFromMessage(message); if (oCounters != null) { PerformanceCounters.InvokeMethod(oCounters, methodName); } } } } } } }
internal static void AddPerformanceCountersForEndpoint( ServiceHostBase serviceHost, ContractDescription contractDescription, EndpointDispatcher endpointDispatcher) { Fx.Assert(serviceHost != null, "The 'serviceHost' argument must not be null."); Fx.Assert(contractDescription != null, "The 'contractDescription' argument must not be null."); Fx.Assert(endpointDispatcher != null, "The 'endpointDispatcher' argument must not be null."); bool performanceCountersEnabled = PerformanceCounters.PerformanceCountersEnabled; bool minimalPerformanceCountersEnabled = PerformanceCounters.MinimalPerformanceCountersEnabled; if (performanceCountersEnabled || minimalPerformanceCountersEnabled) { if (endpointDispatcher.SetPerfCounterId()) { ServiceModelPerformanceCounters counters; lock (PerformanceCounters.perfCounterDictionarySyncObject) { if (!PerformanceCounters.PerformanceCountersForEndpoint.TryGetValue(endpointDispatcher.PerfCounterId, out counters)) { counters = new ServiceModelPerformanceCounters(serviceHost, contractDescription, endpointDispatcher); if (counters.Initialized) { PerformanceCounters.PerformanceCountersForEndpoint.Add(endpointDispatcher.PerfCounterId, counters); int index = PerformanceCounters.PerformanceCountersForEndpointList.FindIndex(c => c == null); if (index >= 0) { PerformanceCounters.PerformanceCountersForEndpointList[index] = counters; } else { PerformanceCounters.PerformanceCountersForEndpointList.Add(counters); index = PerformanceCounters.PerformanceCountersForEndpointList.Count - 1; } endpointDispatcher.PerfCounterInstanceId = index; } else { return; } } } ServiceModelPerformanceCountersEntry countersEntry; lock (PerformanceCounters.perfCounterDictionarySyncObject) { if (!PerformanceCounters.PerformanceCountersForBaseUri.TryGetValue(endpointDispatcher.PerfCounterBaseId, out countersEntry)) { if (performanceCountersEnabled) { countersEntry = new ServiceModelPerformanceCountersEntry(serviceHost.Counters); } else if (minimalPerformanceCountersEnabled) { countersEntry = new ServiceModelPerformanceCountersEntry(serviceHost.DefaultCounters); } PerformanceCounters.PerformanceCountersForBaseUri.Add(endpointDispatcher.PerfCounterBaseId, countersEntry); } countersEntry.Add(counters); } } } }
internal static void AddPerformanceCountersForEndpoint( ServiceHostBase serviceHost, ContractDescription contractDescription, EndpointDispatcher endpointDispatcher) { Fx.Assert(serviceHost != null, "The 'serviceHost' argument must not be null."); Fx.Assert(contractDescription != null, "The 'contractDescription' argument must not be null."); Fx.Assert(endpointDispatcher != null, "The 'endpointDispatcher' argument must not be null."); bool performanceCountersEnabled = PerformanceCounters.PerformanceCountersEnabled; bool minimalPerformanceCountersEnabled = PerformanceCounters.MinimalPerformanceCountersEnabled; if (performanceCountersEnabled || minimalPerformanceCountersEnabled) { if (endpointDispatcher.SetPerfCounterId()) { ServiceModelPerformanceCounters counters; lock (PerformanceCounters.perfCounterDictionarySyncObject) { if (!PerformanceCounters.PerformanceCountersForEndpoint.TryGetValue(endpointDispatcher.PerfCounterId, out counters)) { counters = new ServiceModelPerformanceCounters(serviceHost, contractDescription, endpointDispatcher); if (counters.Initialized) { PerformanceCounters.PerformanceCountersForEndpoint.Add(endpointDispatcher.PerfCounterId, counters); int index = PerformanceCounters.PerformanceCountersForEndpointList.FindIndex(c => c == null); if (index >= 0) { PerformanceCounters.PerformanceCountersForEndpointList[index] = counters; } else { PerformanceCounters.PerformanceCountersForEndpointList.Add(counters); index = PerformanceCounters.PerformanceCountersForEndpointList.Count - 1; } endpointDispatcher.PerfCounterInstanceId = index; } else { return; } } } ServiceModelPerformanceCountersEntry countersEntry; lock (PerformanceCounters.perfCounterDictionarySyncObject) { if (!PerformanceCounters.PerformanceCountersForBaseUri.TryGetValue(endpointDispatcher.PerfCounterBaseId, out countersEntry)) { if (performanceCountersEnabled) { countersEntry = new ServiceModelPerformanceCountersEntry(serviceHost.Counters); } else if (minimalPerformanceCountersEnabled) { countersEntry = new ServiceModelPerformanceCountersEntry(serviceHost.DefaultCounters); } PerformanceCounters.PerformanceCountersForBaseUri.Add(endpointDispatcher.PerfCounterBaseId, countersEntry); } countersEntry.Add(counters); } } } }