コード例 #1
0
        internal static void MethodCalled(string operationName)
        {
            EndpointDispatcher el = GetEndpointDispatcher();

            if (null != el)
            {
                if (PerformanceCounters.Scope == PerformanceCounterScope.All)
                {
                    string uri = el.PerfCounterId;
                    OperationPerformanceCountersBase opCounters = PerformanceCounters.GetOperationPerformanceCounters(el.PerfCounterInstanceId, operationName);
                    if (null != opCounters)
                    {
                        opCounters.MethodCalled();
                    }
                    EndpointPerformanceCountersBase eCounters = PerformanceCounters.GetEndpointPerformanceCounters(el.PerfCounterInstanceId);
                    if (null != eCounters)
                    {
                        eCounters.MethodCalled();
                    }
                }
                ServicePerformanceCountersBase sCounters = PerformanceCounters.GetServicePerformanceCounters(el.PerfCounterInstanceId);
                if (null != sCounters)
                {
                    sCounters.MethodCalled();
                }
            }
        }
コード例 #2
0
        static internal void AuthorizationFailed(string operationName)
        {
            EndpointDispatcher el = GetEndpointDispatcher();

            if (null != el)
            {
                string uri = el.PerfCounterId;
                if (PerformanceCounters.Scope == PerformanceCounterScope.All)
                {
                    OperationPerformanceCountersBase counters = PerformanceCounters.GetOperationPerformanceCounters(el.PerfCounterInstanceId, operationName);
                    if (null != counters)
                    {
                        counters.AuthorizationFailed();
                    }

                    EndpointPerformanceCountersBase eCounters = PerformanceCounters.GetEndpointPerformanceCounters(el.PerfCounterInstanceId);
                    if (null != eCounters)
                    {
                        eCounters.AuthorizationFailed();
                    }
                }

                ServicePerformanceCountersBase sCounters = PerformanceCounters.GetServicePerformanceCounters(el.PerfCounterInstanceId);
                if (null != sCounters)
                {
                    sCounters.AuthorizationFailed();
                }
            }
        }
コード例 #3
0
        internal static void MethodCalled(string operationName)
        {
            EndpointDispatcher endpointDispatcher = GetEndpointDispatcher();

            if (endpointDispatcher != null)
            {
                if (Scope == PerformanceCounterScope.All)
                {
                    string perfCounterId = endpointDispatcher.PerfCounterId;
                    OperationPerformanceCountersBase operationPerformanceCounters = GetOperationPerformanceCounters(endpointDispatcher.PerfCounterInstanceId, operationName);
                    if (operationPerformanceCounters != null)
                    {
                        operationPerformanceCounters.MethodCalled();
                    }
                    EndpointPerformanceCountersBase endpointPerformanceCounters = GetEndpointPerformanceCounters(endpointDispatcher.PerfCounterInstanceId);
                    if (endpointPerformanceCounters != null)
                    {
                        endpointPerformanceCounters.MethodCalled();
                    }
                }
                ServicePerformanceCountersBase servicePerformanceCounters = GetServicePerformanceCounters(endpointDispatcher.PerfCounterInstanceId);
                if (servicePerformanceCounters != null)
                {
                    servicePerformanceCounters.MethodCalled();
                }
            }
        }
コード例 #4
0
        internal static void TxFlowed(EndpointDispatcher el, string operation)
        {
            if (null != el)
            {
                ServicePerformanceCountersBase sCounters = PerformanceCounters.GetServicePerformanceCounters(el.PerfCounterInstanceId);
                if (null != sCounters)
                {
                    sCounters.TxFlowed();
                }

                if (PerformanceCounters.Scope == PerformanceCounterScope.All)
                {
                    OperationPerformanceCountersBase oCounters = PerformanceCounters.GetOperationPerformanceCounters(el.PerfCounterInstanceId, operation);
                    if (null != oCounters)
                    {
                        oCounters.TxFlowed();
                    }

                    EndpointPerformanceCountersBase eCounters = PerformanceCounters.GetEndpointPerformanceCounters(el.PerfCounterInstanceId);
                    if (null != sCounters)
                    {
                        eCounters.TxFlowed();
                    }
                }
            }
        }
コード例 #5
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);
                         }
                     }
                 }
             }
         }
     }
 }
コード例 #6
0
        internal ServiceModelPerformanceCounters(
            ServiceHostBase serviceHost,
            ContractDescription contractDescription,
            EndpointDispatcher endpointDispatcher)
        {
            this.perfCounterId = endpointDispatcher.PerfCounterId;

            if (PerformanceCounters.Scope == PerformanceCounterScope.All)
            {
                this.operationPerfCounters = new Dictionary <string, OperationPerformanceCountersBase>(contractDescription.Operations.Count);
                this.actionToOperation     = new SortedList <string, string>(contractDescription.Operations.Count);

                foreach (OperationDescription opDescription in contractDescription.Operations)
                {
                    Fx.Assert(null != opDescription.Messages, "OperationDescription.Messages should not be null");
                    Fx.Assert(opDescription.Messages.Count > 0, "OperationDescription.Messages should not be empty");
                    Fx.Assert(null != opDescription.Messages[0], "OperationDescription.Messages[0] should not be null");
                    if (null != opDescription.Messages[0].Action && !this.actionToOperation.Keys.Contains(opDescription.Messages[0].Action))
                    {
                        this.actionToOperation.Add(opDescription.Messages[0].Action, opDescription.Name);
                    }
                    OperationPerformanceCountersBase c;
                    if (!this.operationPerfCounters.TryGetValue(opDescription.Name, out c))
                    {
                        OperationPerformanceCountersBase counters =
                            PerformanceCountersFactory.CreateOperationCounters(serviceHost.Description.Name, contractDescription.Name, opDescription.Name, endpointDispatcher.PerfCounterBaseId);
                        if (counters != null && counters.Initialized)
                        {
                            this.operationPerfCounters.Add(opDescription.Name, counters);
                        }
                        else
                        {
                            // cleanup the others and return.
                            this.initialized = false;
                            return;
                        }
                    }
                }

                // add endpoint scoped perf counters
                EndpointPerformanceCountersBase endpointCounters = PerformanceCountersFactory.CreateEndpointCounters(serviceHost.Description.Name, contractDescription.Name, endpointDispatcher.PerfCounterBaseId);
                if (endpointCounters != null && endpointCounters.Initialized)
                {
                    this.endpointPerfCounters = endpointCounters;
                }
            }

            if (PerformanceCounters.PerformanceCountersEnabled)
            {
                this.servicePerfCounters = serviceHost.Counters;
            }
            if (PerformanceCounters.MinimalPerformanceCountersEnabled)
            {
                this.defaultPerfCounters = serviceHost.DefaultCounters;
            }
            this.initialized = true;
        }
 internal ServiceModelPerformanceCounters(ServiceHostBase serviceHost, ContractDescription contractDescription, EndpointDispatcher endpointDispatcher)
 {
     this.perfCounterId = endpointDispatcher.PerfCounterId;
     if (PerformanceCounters.Scope == PerformanceCounterScope.All)
     {
         this.operationPerfCounters = new Dictionary <string, OperationPerformanceCountersBase>(contractDescription.Operations.Count);
         this.actionToOperation     = new SortedList <string, string>(contractDescription.Operations.Count);
         foreach (OperationDescription description in contractDescription.Operations)
         {
             OperationPerformanceCountersBase base2;
             if ((description.Messages[0].Action != null) && !this.actionToOperation.Keys.Contains(description.Messages[0].Action))
             {
                 this.actionToOperation.Add(description.Messages[0].Action, description.Name);
             }
             if (!this.operationPerfCounters.TryGetValue(description.Name, out base2))
             {
                 OperationPerformanceCountersBase base3 = PerformanceCountersFactory.CreateOperationCounters(serviceHost.Description.Name, contractDescription.Name, description.Name, endpointDispatcher.PerfCounterBaseId);
                 if ((base3 != null) && base3.Initialized)
                 {
                     this.operationPerfCounters.Add(description.Name, base3);
                 }
                 else
                 {
                     this.initialized = false;
                     return;
                 }
             }
         }
         EndpointPerformanceCountersBase base4 = PerformanceCountersFactory.CreateEndpointCounters(serviceHost.Description.Name, contractDescription.Name, endpointDispatcher.PerfCounterBaseId);
         if ((base4 != null) && base4.Initialized)
         {
             this.endpointPerfCounters = base4;
         }
     }
     if (PerformanceCounters.PerformanceCountersEnabled)
     {
         this.servicePerfCounters = serviceHost.Counters;
     }
     if (PerformanceCounters.MinimalPerformanceCountersEnabled)
     {
         this.defaultPerfCounters = serviceHost.DefaultCounters;
     }
     this.initialized = true;
 }
コード例 #8
0
        internal static void MethodReturnedError(string operationName, long time)
        {
            EndpointDispatcher el = GetEndpointDispatcher();

            if (null != el)
            {
                if (PerformanceCounters.Scope == PerformanceCounterScope.All)
                {
                    string uri = el.PerfCounterId;
                    OperationPerformanceCountersBase counters = PerformanceCounters.GetOperationPerformanceCounters(el.PerfCounterInstanceId, operationName);
                    if (null != counters)
                    {
                        counters.MethodReturnedError();
                        if (time > 0)
                        {
                            counters.SaveCallDuration(time);
                        }
                    }
                    EndpointPerformanceCountersBase eCounters = PerformanceCounters.GetEndpointPerformanceCounters(el.PerfCounterInstanceId);
                    if (null != eCounters)
                    {
                        eCounters.MethodReturnedError();
                        if (time > 0)
                        {
                            eCounters.SaveCallDuration(time);
                        }
                    }
                }
                ServicePerformanceCountersBase sCounters = PerformanceCounters.GetServicePerformanceCounters(el.PerfCounterInstanceId);
                if (null != sCounters)
                {
                    sCounters.MethodReturnedError();
                    if (time > 0)
                    {
                        sCounters.SaveCallDuration(time);
                    }
                }
            }
        }
コード例 #9
0
        internal static void MethodReturnedSuccess(string operationName, long time)
        {
            EndpointDispatcher endpointDispatcher = GetEndpointDispatcher();

            if (endpointDispatcher != null)
            {
                if (Scope == PerformanceCounterScope.All)
                {
                    string perfCounterId = endpointDispatcher.PerfCounterId;
                    OperationPerformanceCountersBase operationPerformanceCounters = GetOperationPerformanceCounters(endpointDispatcher.PerfCounterInstanceId, operationName);
                    if (operationPerformanceCounters != null)
                    {
                        operationPerformanceCounters.MethodReturnedSuccess();
                        if (time > 0L)
                        {
                            operationPerformanceCounters.SaveCallDuration(time);
                        }
                    }
                    EndpointPerformanceCountersBase endpointPerformanceCounters = GetEndpointPerformanceCounters(endpointDispatcher.PerfCounterInstanceId);
                    if (endpointPerformanceCounters != null)
                    {
                        endpointPerformanceCounters.MethodReturnedSuccess();
                        if (time > 0L)
                        {
                            endpointPerformanceCounters.SaveCallDuration(time);
                        }
                    }
                }
                ServicePerformanceCountersBase servicePerformanceCounters = GetServicePerformanceCounters(endpointDispatcher.PerfCounterInstanceId);
                if (servicePerformanceCounters != null)
                {
                    servicePerformanceCounters.MethodReturnedSuccess();
                    if (time > 0L)
                    {
                        servicePerformanceCounters.SaveCallDuration(time);
                    }
                }
            }
        }
コード例 #10
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);
                                }
                            }
                        }
                    }
                }
            }
        }
コード例 #11
0
 internal static void TxFlowed(EndpointDispatcher el, string operation)
 {
     if (el != null)
     {
         ServicePerformanceCountersBase servicePerformanceCounters = GetServicePerformanceCounters(el.PerfCounterInstanceId);
         if (servicePerformanceCounters != null)
         {
             servicePerformanceCounters.TxFlowed();
         }
         if (Scope == PerformanceCounterScope.All)
         {
             OperationPerformanceCountersBase operationPerformanceCounters = GetOperationPerformanceCounters(el.PerfCounterInstanceId, operation);
             if (operationPerformanceCounters != null)
             {
                 operationPerformanceCounters.TxFlowed();
             }
             EndpointPerformanceCountersBase endpointPerformanceCounters = GetEndpointPerformanceCounters(el.PerfCounterInstanceId);
             if (servicePerformanceCounters != null)
             {
                 endpointPerformanceCounters.TxFlowed();
             }
         }
     }
 }