示例#1
0
        private MethodSpecificCounterWriters InitializeMethodCounterInstanceData(string instanceName)
        {
            var tempCounterWriters = new MethodSpecificCounterWriters();


            try
            {
                tempCounterWriters.ServiceMethodCounterSetInstance =
                    ServiceMethodCounterSet.CreateCounterSetInstance(instanceName);
            }
            catch (Exception ex)
            {
                //Instance creation failed, Be done.
                ServiceTrace.Source.WriteWarning(TraceType,
                                                 "Data for performance counter instance {0} of category {1} will not be provided because an exception occurred during its initialization. Exception info: {2}",
                                                 instanceName, ServiceRemotingPerformanceCounters.ServiceMethodCategoryName, ex);
                return(null);
            }

            tempCounterWriters.ServiceMethodFrequencyCounterWriter = this.CreateMethodCounterWriter(
                instanceName,
                typeof(FabricNumberOfItems64PerformanceCounterWriter),
                tempCounterWriters.ServiceMethodCounterSetInstance,
                inst =>
                new FabricNumberOfItems64PerformanceCounterWriter(inst,
                                                                  ServiceRemotingPerformanceCounters.ServiceMethodInvocationsPerSecCounterName));
            tempCounterWriters.ServiceMethodExceptionFrequencyCounterWriter = this.CreateMethodCounterWriter(
                instanceName,
                typeof(FabricNumberOfItems64PerformanceCounterWriter),
                tempCounterWriters.ServiceMethodCounterSetInstance,
                inst =>
                new FabricNumberOfItems64PerformanceCounterWriter(inst,
                                                                  ServiceRemotingPerformanceCounters.ServiceMethodExceptionsPerSecCounterName));
            tempCounterWriters.ServiceMethodExecTimeCounterWriter = this.CreateMethodCounterWriter(
                instanceName,
                typeof(FabricAverageCount64PerformanceCounterWriter),
                tempCounterWriters.ServiceMethodCounterSetInstance,
                inst =>
                new FabricAverageCount64PerformanceCounterWriter(inst,
                                                                 ServiceRemotingPerformanceCounters.ServiceMethodExecTimeMillisecCounterName,
                                                                 ServiceRemotingPerformanceCounters.ServiceMethodExecTimeMillisecBaseCounterName));
            return(tempCounterWriters);
        }
示例#2
0
        private void OnActorMethodFinish(ActorMethodDiagnosticData methodData)
        {
            long interfaceMethodKey = methodData.InterfaceMethodKey;
            MethodSpecificCounterWriters counterWriters = this.actorMethodCounterInstanceData[interfaceMethodKey].CounterWriters;

            if (!AvaiableFabricCounterSet.TryGetValue(ActorPerformanceCounters.ActorMethodCategoryName, out ActorMethodCounterSet))
            {
                return;
            }

            if (counterWriters == null)
            {
                bool logCounterWriterCreation = false;
                lock (this.actorMethodCounterInstanceData[interfaceMethodKey])
                {
                    if (this.actorMethodCounterInstanceData[interfaceMethodKey].CounterWriters == null)
                    {
                        // We have not yet created the objects that write the counter values. So build
                        // up the list of counter writers now.
                        string instanceName = this.actorMethodCounterInstanceData[interfaceMethodKey].InstanceName;

                        var tempCounterWriters = new MethodSpecificCounterWriters();

                        try
                        {
                            tempCounterWriters.ActorMethodCounterSetInstance =
                                ActorMethodCounterSet.CreateCounterSetInstance(instanceName);
                        }
                        catch (Exception ex)
                        {
                            //Instance creation failed, Be done.
                            AppTrace.TraceSource.WriteWarning(
                                TraceType,
                                "Data for performance counter instance {0} of category {1} will not be provided because an exception occurred during its initialization. Exception info: {2}",
                                instanceName, ActorPerformanceCounters.ActorMethodCategoryName, ex);
                            return;
                        }

                        tempCounterWriters.ActorMethodFrequencyCounterWriter = this.CreateMethodCounterWriter(
                            instanceName,
                            typeof(ActorMethodFrequencyCounterWriter),
                            tempCounterWriters.ActorMethodCounterSetInstance,
                            inst => new ActorMethodFrequencyCounterWriter(inst));
                        tempCounterWriters.ActorMethodExceptionFrequencyCounterWriter = this.CreateMethodCounterWriter(
                            instanceName,
                            typeof(ActorMethodExceptionFrequencyCounterWriter),
                            tempCounterWriters.ActorMethodCounterSetInstance,
                            inst => new ActorMethodExceptionFrequencyCounterWriter(inst));
                        tempCounterWriters.ActorMethodExecTimeCounterWriter = this.CreateMethodCounterWriter(
                            instanceName,
                            typeof(ActorMethodExecTimeCounterWriter),
                            tempCounterWriters.ActorMethodCounterSetInstance,
                            inst => new ActorMethodExecTimeCounterWriter(inst));
                        logCounterWriterCreation = true;

                        this.actorMethodCounterInstanceData[interfaceMethodKey].CounterWriters = tempCounterWriters;
                    }
                }
                counterWriters = this.actorMethodCounterInstanceData[interfaceMethodKey].CounterWriters;

                if (logCounterWriterCreation)
                {
                    object[] newlyCreatedCounterWriters =
                    {
                        counterWriters.ActorMethodFrequencyCounterWriter,
                        counterWriters.ActorMethodExceptionFrequencyCounterWriter,
                        counterWriters.ActorMethodExecTimeCounterWriter
                    };
                    foreach (var newlyCreatedCounterWriter in newlyCreatedCounterWriters)
                    {
                        if (null != newlyCreatedCounterWriter)
                        {
                            this.LogCounterInstanceCreationResult(
                                newlyCreatedCounterWriter.GetType(),
                                this.actorMethodCounterInstanceData[interfaceMethodKey].InstanceName,
                                null);
                        }
                    }
                }
            }

            // Call the counter writers to update the counter values
            if (null != counterWriters.ActorMethodFrequencyCounterWriter)
            {
                counterWriters.ActorMethodFrequencyCounterWriter.UpdateCounterValue();
            }
            if (null != counterWriters.ActorMethodExceptionFrequencyCounterWriter)
            {
                counterWriters.ActorMethodExceptionFrequencyCounterWriter.UpdateCounterValue(methodData);
            }
            if (null != counterWriters.ActorMethodExecTimeCounterWriter)
            {
                counterWriters.ActorMethodExecTimeCounterWriter.UpdateCounterValue(methodData);
            }
        }
示例#3
0
        private MethodSpecificCounterWriters CreateCounterWriters(
            CounterInstanceData counterInstanceData,
            FabricPerformanceCounterSet ActorMethodCounterSet)
        {
            var logCounterWriterCreation = false;

            // We have not yet created the objects that write the counter values. So build
            // up the list of counter writers now.
            var instanceName       = counterInstanceData.InstanceName;
            var tempCounterWriters = new MethodSpecificCounterWriters();

            try
            {
                tempCounterWriters.ActorMethodCounterSetInstance =
                    ActorMethodCounterSet.CreateCounterSetInstance(instanceName);
            }
            catch (Exception ex)
            {
                //Instance creation failed, Be done.
                ActorTrace.Source.WriteWarning(
                    TraceType,
                    "Data for performance counter instance {0} of category {1} will not be provided because an exception occurred during its initialization. Exception info: {2}",
                    instanceName, ActorPerformanceCounters.ActorMethodCategoryName, ex);
                return(null);
            }

            tempCounterWriters.ActorMethodFrequencyCounterWriter = this.CreateMethodCounterWriter(
                instanceName,
                typeof(ActorMethodFrequencyCounterWriter),
                tempCounterWriters.ActorMethodCounterSetInstance,
                inst => new ActorMethodFrequencyCounterWriter(inst));
            tempCounterWriters.ActorMethodExceptionFrequencyCounterWriter = this.CreateMethodCounterWriter(
                instanceName,
                typeof(ActorMethodExceptionFrequencyCounterWriter),
                tempCounterWriters.ActorMethodCounterSetInstance,
                inst => new ActorMethodExceptionFrequencyCounterWriter(inst));
            tempCounterWriters.ActorMethodExecTimeCounterWriter = this.CreateMethodCounterWriter(
                instanceName,
                typeof(ActorMethodExecTimeCounterWriter),
                tempCounterWriters.ActorMethodCounterSetInstance,
                inst => new ActorMethodExecTimeCounterWriter(inst));
            logCounterWriterCreation = true;


            if (logCounterWriterCreation)
            {
                object[] newlyCreatedCounterWriters =
                {
                    tempCounterWriters.ActorMethodFrequencyCounterWriter,
                    tempCounterWriters.ActorMethodExceptionFrequencyCounterWriter,
                    tempCounterWriters.ActorMethodExecTimeCounterWriter
                };
                foreach (var newlyCreatedCounterWriter in newlyCreatedCounterWriters)
                {
                    if (null != newlyCreatedCounterWriter)
                    {
                        this.LogCounterInstanceCreationResult(
                            newlyCreatedCounterWriter.GetType(),
                            counterInstanceData.InstanceName,
                            null);
                    }
                }
            }

            return(tempCounterWriters);
        }