Esempio n. 1
0
        public void ValidateProblemIdForExceptionWithStackTrace()
        {
            Exception ex = CreateException(1);

            var id = LogsHelper.GetProblemId(ex);

            Assert.StartsWith(typeof(AggregateException).FullName + " at " + typeof(TelemetryExceptionDataTests).FullName + "." + nameof(FunctionWithException), id);
        }
Esempio n. 2
0
        public TelemetryExceptionData(int version, LogRecord logRecord) : base(version)
        {
            Properties   = new ChangeTrackingDictionary <string, string>();
            Measurements = new ChangeTrackingDictionary <string, double>();

            var message = LogsHelper.GetMessageAndSetProperties(logRecord, Properties);

            SeverityLevel = LogsHelper.GetSeverityLevel(logRecord.LogLevel);
            ProblemId     = LogsHelper.GetProblemId(logRecord.Exception).Truncate(SchemaConstants.ExceptionData_ProblemId_MaxLength);

            // collect the set of exceptions detail info from the passed in exception
            List <TelemetryExceptionDetails> exceptions = new List <TelemetryExceptionDetails>();

            ConvertExceptionTree(logRecord.Exception, message, null, exceptions);

            // trim if we have too many, also add a custom exception to let the user know we're trimmed
            if (exceptions.Count > MaxExceptionCountToSave)
            {
                // create our "message" exception.
                InnerExceptionCountExceededException countExceededException =
                    new InnerExceptionCountExceededException(
                        string.Format(
                            CultureInfo.InvariantCulture,
                            "The number of inner exceptions was {0} which is larger than {1}, the maximum number allowed during transmission. All but the first {1} have been dropped.",
                            exceptions.Count,
                            MaxExceptionCountToSave));

                // remove all but the first N exceptions
                exceptions.RemoveRange(MaxExceptionCountToSave,
                                       exceptions.Count - MaxExceptionCountToSave);

                // we'll add our new exception and parent it to the root exception (first one in the list)
                exceptions.Add(new TelemetryExceptionDetails(countExceededException, countExceededException.Message, exceptions[0]));
            }

            Exceptions = exceptions;
        }
Esempio n. 3
0
        public void ValidateProblemIdForExceptionWithoutStackTrace()
        {
            var id = LogsHelper.GetProblemId(new Exception("Test"));

            Assert.Equal(typeof(Exception).FullName + " at UnknownMethod", id);
        }