예제 #1
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();
                    }
                }
            }
        }
예제 #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 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();
                }
            }
        }
예제 #4
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();
                }
            }
        }
        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 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;
 }
 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;
 }
예제 #9
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);
                    }
                }
            }
        }
예제 #10
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);
                    }
                }
            }
        }
예제 #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();
             }
         }
     }
 }