Esempio n. 1
0
 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);
                         }
                     }
                 }
             }
         }
     }
 }
Esempio n. 2
0
        static ServiceModelPerformanceCountersEntry GetServiceModelPerformanceCountersBaseUri(string uri)
        {
            ServiceModelPerformanceCountersEntry counters = null;

            if (!String.IsNullOrEmpty(uri))
            {
                PerformanceCounters.PerformanceCountersForBaseUri.TryGetValue(uri, out counters);
            }
            return(counters);
        }
Esempio n. 3
0
        private static ServiceModelPerformanceCountersEntry GetServiceModelPerformanceCountersBaseUri(string uri)
        {
            ServiceModelPerformanceCountersEntry entry = null;

            if (!string.IsNullOrEmpty(uri))
            {
                PerformanceCountersForBaseUri.TryGetValue(uri, out entry);
            }
            return(entry);
        }
Esempio n. 4
0
 internal static void MsmqRejectedMessage(string uri)
 {
     if (PerformanceCounters.Scope == PerformanceCounterScope.All)
     {
         ServiceModelPerformanceCountersEntry counters = PerformanceCounters.GetServiceModelPerformanceCountersBaseUri(uri);
         if (null != counters)
         {
             counters.ServicePerformanceCounters.MsmqRejectedMessage();
         }
     }
 }
Esempio n. 5
0
 internal static void MsmqRejectedMessage(string uri)
 {
     if (Scope == PerformanceCounterScope.All)
     {
         ServiceModelPerformanceCountersEntry serviceModelPerformanceCountersBaseUri = GetServiceModelPerformanceCountersBaseUri(uri);
         if (serviceModelPerformanceCountersBaseUri != null)
         {
             serviceModelPerformanceCountersBaseUri.ServicePerformanceCounters.MsmqRejectedMessage();
         }
     }
 }
Esempio n. 6
0
 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);
         }
     }
 }
Esempio n. 7
0
        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();
                        }
                    }
                }
            }
        }
Esempio n. 8
0
        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();
                        }
                    }
                }
            }
        }
Esempio n. 9
0
        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);
                                }
                            }
                        }
                    }
                }
            }
        }
Esempio n. 10
0
        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);
                    }
                }
            }
        }