コード例 #1
0
        public void EvaluatePerformance()
        {
            ResetAllCounts();

            RollbarQueueController.Instance.InternalEvent += Instance_InternalEvent;
            ClassificationDeclaration classificationDeclaration = new ClassificationDeclaration();

            foreach (var classifier in EnumUtil.GetAllValues <PayloadSize>())
            {
                EvaluateUsing(classifier, classificationDeclaration);
            }
            BlockUntilRollbarQueuesAreEmpty();
            RollbarQueueController.Instance.InternalEvent -= Instance_InternalEvent;

            // Any SDK error would invalidate the test:
            Assert.AreEqual(0, this._apiErrorsCount);
            Assert.AreEqual(0, this._commErrorsCount);
            Assert.AreEqual(0, this._internalErrorsCount);

            // Let's make sure expected amount of payloads was
            // delivered to the Rollbar API:
            Assert.AreEqual(
                Constants.TotalMeasurementSamples
                * EnumUtil.GetAllValues <PayloadSize>().Length
                *EnumUtil.GetAllValues <PayloadType>().Length
                *(EnumUtil.GetAllValues <MethodVariant>().Length - 1)
                * EnumUtil.GetAllValues <Method>().Length
                , this._commSuccessCount
                );
        }
コード例 #2
0
 private void EvaluateUsing(MethodVariant theClassifier, ClassificationDeclaration classificationDeclaration)
 {
     classificationDeclaration.MethodVariant = theClassifier;
     foreach (var classifier in EnumUtil.GetAllValues <Method>())
     {
         EvaluateUsing(classifier, classificationDeclaration);
     }
 }
コード例 #3
0
 private void EvaluateUsing(PayloadSize theClassifier, ClassificationDeclaration classificationDeclaration)
 {
     classificationDeclaration.PayloadSize = theClassifier;
     foreach (var classifier in EnumUtil.GetAllValues <PayloadType>())
     {
         EvaluateUsing(classifier, classificationDeclaration);
     }
 }
コード例 #4
0
 private void EvaluateUsing(PayloadType theClassifier, ClassificationDeclaration classificationDeclaration)
 {
     classificationDeclaration.PayloadType = theClassifier;
     foreach (var classifier in EnumUtility.GetAllValues <MethodVariant>())
     {
         EvaluateUsing(classifier, classificationDeclaration);
     }
 }
コード例 #5
0
        public static PerformanceTimerAttribute GetPerformanceTimer(ClassificationDeclaration classificationDeclaration)
        {
            var timer = PerformanceTimerAttribute.StartNew(
                RollbarPerformanceMonitor.Instance,
                PerformanceUtil.GetClassification(classificationDeclaration)
                );

            return(timer);
        }
コード例 #6
0
        private void EvaluateUsing(Method theClassifier, ClassificationDeclaration classificationDeclaration)
        {
            classificationDeclaration.Method = theClassifier;

            switch (classificationDeclaration.Method)
            {
            case Method.Log:
                EvaluateLogMethod(classificationDeclaration);
                break;

            default:
                Assumption.FailValidation("Unexpected value!", nameof(classificationDeclaration.Method));
                break;
            }
        }
コード例 #7
0
        private object ProvideObjectToLog(ClassificationDeclaration classificationDeclaration)
        {
            switch (classificationDeclaration.PayloadType)
            {
            case PayloadType.Message:
                return(ProvideMessage(classificationDeclaration.PayloadSize));

            case PayloadType.Exception:
                return(ProvideException(classificationDeclaration.PayloadSize));

            default:
                Assumption.FailValidation("Unexpected value!", nameof(classificationDeclaration.PayloadType));
                break;
            }
            return(null);
        }
コード例 #8
0
        public static Classification GetClassification(ClassificationDeclaration classificationDeclaration)
        {
            var classification = Classification.MatchClassification(classificationDeclaration.GetAllClassifiers());

            return(classification);
        }
コード例 #9
0
        private void EvaluateLogMethod(ClassificationDeclaration classificationDeclaration)
        {
            RollbarConfig loggerConfig = ProvideRollbarConfig();

            object payload = null;

            switch (classificationDeclaration.PayloadType)
            {
            case PayloadType.Message:
            {
                payload = ProvideObjectToLog(classificationDeclaration);
            }
            break;

            case PayloadType.Exception:
            {
                payload = ProvideObjectToLog(classificationDeclaration);
            }
            break;

            default:
                break;
            }
            Assert.IsNotNull(payload);

            // Let's give things change to stabilize:
            //Thread.Sleep(TimeSpan.FromSeconds(2));

            using (var rollbar = RollbarFactory.CreateNew().Configure(loggerConfig))
            {
                for (int i = 0; i < Constants.TotalMeasurementSamples; i++)
                {
                    switch (classificationDeclaration.MethodVariant)
                    {
                    case MethodVariant.Async:
                    {
                        IAsyncLogger logger = rollbar;
                        using (PerformanceUtil.GetPerformanceTimer(classificationDeclaration))
                        {
                            logger.Log(ErrorLevel.Warning, payload);
                        }
                        break;
                    }

                    case MethodVariant.AsyncWaited:
                    {
                        IAsyncLogger logger = rollbar;
                        using (PerformanceUtil.GetPerformanceTimer(classificationDeclaration))
                        {
                            logger.Log(ErrorLevel.Warning, payload).Wait();
                        }
                        break;
                    }

                    case MethodVariant.Blocking:
                    {
                        // NOTE: for blocking call we want to eliminate effect of
                        // the max reporting rate restriction, so that the wait time
                        // that is a result of the rate limit is not counted against
                        // the blocking call:
                        BlockUntilRollbarQueuesAreEmpty();
                        Thread.Sleep(TimeSpan.FromSeconds(60 / rollbar.Config.MaxReportsPerMinute));

                        ILogger logger = rollbar.AsBlockingLogger(Constants.RollbarBlockingTimeout);
                        using (PerformanceUtil.GetPerformanceTimer(classificationDeclaration))
                        {
                            logger.Log(ErrorLevel.Critical, payload);
                        }
                        break;
                    }

                    default:
                        // nothing to do...
                        break;
                    }
                }

                //BlockUntilRollbarQueuesAreEmpty();
                //Thread.Sleep(TimeSpan.FromMilliseconds(250));
                //if (classificationDeclaration.MethodVariant == MethodVariant.Async)
                //{
                //    // NOTE: for async call we want to make sure the logger's instance is not
                //    // disposed until all the buffered payloads delivered to the Rollbar API.
                //    // This delay ios needed until issue #197 is resolved...
                //    BlockUntilRollbarQueuesAreEmpty();
                //}
            }
        }