Esempio n. 1
0
        static OperationPerformanceCountersBase GetOperationPerformanceCounters(int perfCounterInstanceId, string operation)
        {
            ServiceModelPerformanceCounters counters = PerformanceCounters.GetServiceModelPerformanceCounters(perfCounterInstanceId);

            if (counters != null)
            {
                return(counters.GetOperationPerformanceCounters(operation));
            }
            return(null);
        }
Esempio n. 2
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. 3
0
        static internal PerformanceCounter GetPerformanceCounter(string categoryName, string perfCounterName, string instanceName, PerformanceCounterInstanceLifetime instanceLifetime)
        {
            PerformanceCounter counter = null;

            if (PerformanceCounters.PerformanceCountersEnabled || PerformanceCounters.MinimalPerformanceCountersEnabled)
            {
                counter = PerformanceCounters.GetPerformanceCounterInternal(categoryName, perfCounterName, instanceName, instanceLifetime);
            }

            return(counter);
        }
Esempio n. 4
0
 internal static void TxInDoubt(EndpointDispatcher el, long count)
 {
     if (PerformanceCounters.PerformanceCountersEnabled)
     {
         if (null != el)
         {
             ServicePerformanceCountersBase sCounters = PerformanceCounters.GetServicePerformanceCounters(el.PerfCounterInstanceId);
             if (null != sCounters)
             {
                 sCounters.TxInDoubt(count);
             }
         }
     }
 }
Esempio n. 5
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. 6
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);
                    }
                }
            }
        }
 protected override void Dispose(bool disposing)
 {
     try
     {
         if ((disposing && PerformanceCounters.PerformanceCountersEnabled) && (this.Counters != null))
         {
             for (int i = this.PerfCounterStart; i < this.PerfCounterEnd; i++)
             {
                 PerformanceCounter counter = this.Counters[i];
                 if (counter != null)
                 {
                     PerformanceCounters.ReleasePerformanceCounter(ref counter);
                 }
                 this.Counters[i] = null;
             }
             this.Counters = null;
         }
     }
     finally
     {
         base.Dispose(disposing);
     }
 }
Esempio n. 8
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);
                                }
                            }
                        }
                    }
                }
            }
        }
        internal OperationPerformanceCounters(string service, string contract, string operationName, string uri)
            : base(service, contract, operationName, uri)
        {
            this.Counters = new PerformanceCounter[(int)PerfCounters.TotalCounters];
            for (int i = 0; i < (int)PerfCounters.TotalCounters; i++)
            {
                PerformanceCounter counter = PerformanceCounters.GetOperationPerformanceCounter(perfCounterNames[i], this.instanceName);
                if (counter != null)
                {
                    try
                    {
                        counter.RawValue = 0;
                        this.Counters[i] = counter;
                    }
#pragma warning suppress 56500 // covered by FxCOP
                    catch (Exception e)
                    {
                        if (Fx.IsFatal(e))
                        {
                            throw;
                        }

                        if (DiagnosticUtility.ShouldTraceError)
                        {
                            TraceUtility.TraceEvent(TraceEventType.Error, TraceCode.PerformanceCounterFailedToLoad,
                                                    SR.GetString(SR.TraceCodePerformanceCounterFailedToLoad), null, e);
                        }
                        break;
                    }
                }
                else
                {
                    break;
                }
            }
        }
Esempio n. 10
0
 static internal void AuthenticationFailed(Message message, Uri listenUri)
 {
     PerformanceCounters.CallOnAllCounters("AuthenticationFailed", message, listenUri, true);
 }
Esempio n. 11
0
 internal static void MethodReturnedError(string operationName)
 {
     PerformanceCounters.MethodReturnedError(operationName, -1);
 }