internal static ExceptionTelemetry ToTelemetry([NotNull] this BbExceptionEvent @event)
        {
            try
            {
                var tEvent = new ExceptionTelemetry
                {
                    Message   = @event.Exception.Message,
                    Exception = @event.Exception,
                    Timestamp = DateTimeOffset.Now
                };

                tEvent.SetCorrelation(@event);
                @event.CopyPropertiesInto(tEvent.Properties);

                return(tEvent);
            }
            catch (Exception ex)
            {
#if DEBUG
                if (Debugger.IsAttached)
                {
                    throw;
                }
#endif
                BigBrother.PublishError(ex);
                return(null);
            }
        }
Пример #2
0
        public void Ensure_CreateWithtOneReturnsSame()
        {
            var bbMock = new Mock <BigBrother> {
                CallBase = true
            };

            BbExceptionEvent errorEvent = null;

            using (BigBrother.InternalStream.OfType <BbExceptionEvent>()
                   .Subscribe(e => errorEvent = e))
            {
                var handle1 = bbMock.Object.CreateCorrelation();
                var handle2 = bbMock.Object.CreateCorrelation();
                handle2.Should().Be(handle1);

                errorEvent.Should().NotBeNull();
                errorEvent.Exception.Should().BeOfType <InvalidOperationException>();
            }
        }