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

            if (counters != null)
            {
                return(counters.GetOperationPerformanceCounters(operation));
            }
            return(null);
        }
示例#2
0
 internal static void MsmqRejectedMessage(string uri)
 {
     if (PerformanceCounters.Scope == PerformanceCounterScope.All)
     {
         ServiceModelPerformanceCountersEntry counters = PerformanceCounters.GetServiceModelPerformanceCountersBaseUri(uri);
         if (null != counters)
         {
             counters.ServicePerformanceCounters.MsmqRejectedMessage();
         }
     }
 }
示例#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);
        }
示例#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);
             }
         }
     }
 }
示例#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();
                        }
                    }
                }
            }
        }
示例#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);
     }
 }
示例#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;
                }
            }
        }
示例#10
0
 static internal void AuthenticationFailed(Message message, Uri listenUri)
 {
     PerformanceCounters.CallOnAllCounters("AuthenticationFailed", message, listenUri, true);
 }
示例#11
0
 internal static void MethodReturnedError(string operationName)
 {
     PerformanceCounters.MethodReturnedError(operationName, -1);
 }