internal static EventTelemetry ToTelemetry([NotNull] this BbTimedEvent @event) { try { var tEvent = new EventTelemetry { Name = @event.GetType().Name, Timestamp = DateTimeOffset.Now, }; tEvent.Metrics[nameof(BbTimedEvent.ProcessingTime)] = @event.ProcessingTime.TotalSeconds; tEvent.SetCorrelation(@event); @event.CopyPropertiesInto(tEvent.Properties); return(tEvent); } catch (Exception ex) { #if DEBUG if (Debugger.IsAttached) { throw; } #endif BigBrother.PublishError(ex); return(null); } }
public void Test_Publish_EndsTimedEvents() { using (ShimsContext.Create()) { var endCalled = false; ShimBbTimedEvent.AllInstances.End = _ => endCalled = true; var bbMock = new Mock <BigBrother> { CallBase = true }; var tEvent = new BbTimedEvent(); bbMock.Object.Publish(tEvent); endCalled.Should().BeTrue(); } }