예제 #1
0
        private System.Exception ProvideException(PayloadSize payloadSize)
        {
            const int totalExceptionFramesBaseline = 3;
            int       multiplier = 1;

            switch (payloadSize)
            {
            case PayloadSize.Small:
                multiplier = 1;
                break;

            case PayloadSize.Medium:
                multiplier = 1 * Constants.SmallToMediumExceptionCallStackDepthMultiplier;
                break;

            case PayloadSize.Large:
                multiplier = 1 * Constants.SmallToMediumExceptionCallStackDepthMultiplier * Constants.MediumToLargeExceptionCallStackDepthMultiplier;
                break;

            default:
                Assumption.FailValidation("Unexpected value!", nameof(payloadSize));
                break;
            }

            return(ExceptionSimulator.GetExceptionWith(multiplier * totalExceptionFramesBaseline));
        }
예제 #2
0
        private string ProvideMessage(PayloadSize payloadSize)
        {
            string        smallMessage = @"Small message 1234 56789! ";
            StringBuilder result       = new StringBuilder(smallMessage);

            int multiplier = 1;

            switch (payloadSize)
            {
            case PayloadSize.Small:
                multiplier = 1;
                break;

            case PayloadSize.Medium:
                multiplier = 1 * Constants.SmallToMediumMessageMultiplier;
                break;

            case PayloadSize.Large:
                multiplier = 1 * Constants.SmallToMediumMessageMultiplier * Constants.MediumToLargeMessageMultiplier;
                break;

            default:
                Assumption.FailValidation("Unexpected value!", nameof(payloadSize));
                break;
            }

            int counter = 0;

            while (++counter < multiplier)
            {
                result.AppendLine(smallMessage);
            }

            return(result.ToString());
        }
        /// <summary>
        /// Decides whether to collect user ip value or not.
        /// </summary>
        /// <param name="initialIPAddress">The initial ip address.</param>
        /// <param name="ipAddressCollectionPolicy">The ip address collection policy.</param>
        /// <returns>The IP value as System.String.</returns>
        private static string?DecideCollectableUserIPValue(
            string?initialIPAddress,
            IpAddressCollectionPolicy ipAddressCollectionPolicy
            )
        {
            if (string.IsNullOrWhiteSpace(initialIPAddress))
            {
                return(null);
            }

            switch (ipAddressCollectionPolicy)
            {
            case IpAddressCollectionPolicy.Collect:
                return(initialIPAddress);

            case IpAddressCollectionPolicy.CollectAnonymized:
                return(IpAddressUtility.Anonymize(initialIPAddress !));

            case IpAddressCollectionPolicy.DoNotCollect:
                return(null);

            default:
                Assumption.FailValidation(
                    "Unexpected enumeration value!"
                    , nameof(ipAddressCollectionPolicy)
                    );
                break;
            }

            return(null);
        }
예제 #4
0
        private void BlockUntilRollbarQueuesAreEmpty()
        {
            DateTime startedAt = DateTime.Now;

            while (RollbarQueueController.Instance.GetTotalPayloadCount() > 0)
            {
                if (DateTime.Now.Subtract(startedAt) > TimeSpan.FromMinutes(5))
                {
                    Assumption.FailValidation("Something wrong with blocking!", nameof(DateTime.Now));
                }
                Thread.Sleep(TimeSpan.FromMilliseconds(250));
            }
        }
예제 #5
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;
            }
        }
예제 #6
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);
        }