protected override void OnEventWritten(EventWrittenEventArgs eventData) { if (!_disposed) { // Make sure we can format the event EventSourceEventFormatting.Format(eventData); _events.Enqueue(eventData); } }
/// <inheritdoc /> protected sealed override void OnEventWritten(EventWrittenEventArgs eventData) { // Workaround https://github.com/dotnet/corefx/issues/42600 if (eventData.EventId == -1) { return; } _log(eventData, EventSourceEventFormatting.Format(eventData)); }
/// <inheritdoc /> protected sealed override void OnEventWritten(EventWrittenEventArgs eventData) { // Workaround https://github.com/dotnet/corefx/issues/42600 if (eventData.EventId == -1) { return; } // There is a very tight race during the AzureEventSourceListener creation where EnableEvents was called // and the thread producing events not observing the `_log` field assignment _log?.Invoke(eventData, EventSourceEventFormatting.Format(eventData)); }
protected override void OnEventWritten(EventWrittenEventArgs eventData) { // Work around https://github.com/dotnet/corefx/issues/42600 if (eventData.EventId == -1) { return; } if (!_disposed) { // Make sure we can format the event EventSourceEventFormatting.Format(eventData); _events.Enqueue(eventData); } }
protected override void OnEventWritten(EventWrittenEventArgs eventData) { // Work around https://github.com/dotnet/corefx/issues/42600 if (eventData.EventId == -1) { return; } if (!_disposed) { if (_events.Count >= _maxEventCount) { throw new Exception($"Number of events has exceeded {_maxEventCount}. Create {typeof(TestEventListener)} with a larger 'maxEventCount'."); } // Make sure we can format the event EventSourceEventFormatting.Format(eventData); _events.Enqueue(eventData); } }
private void TestAggregateException(Action <string, Exception> writeAction, int expectedId, string expectedName) { using var listener = new TestListener(); // When running tests parallel, it's possible for one test to collect the messages from another test. // We use a guid here to be able to find the specific message created by this test. var name = $"{nameof(AzureMonitorExporterEventSourceTests)}.{Guid.NewGuid()}"; writeAction(name, new AggregateException(new Exception("hello world_1"), new Exception("hello world_2)"))); var eventData = FindEvent(listener.Events, name); Assert.Equal(AzureMonitorExporterEventSource.EventSourceName, eventData.EventSource.Name); Assert.Equal(expectedId, eventData.EventId); Assert.Equal(expectedName, eventData.EventName); var message = EventSourceEventFormatting.Format(eventData); Assert.Equal($"{name} - System.Exception: hello world_1", message); }
protected override void OnEventWritten(EventWrittenEventArgs eventData) { string message = EventSourceEventFormatting.Format(eventData); TelemetryDebugWriter.WriteMessage($"{eventData.EventSource.Name} - EventId: [{eventData.EventId}], EventName: [{eventData.EventName}], Message: [{message}]"); }
private static string FormatMessage(EventSourceEvent eventSourceEvent, Exception exception) { return(EventSourceEventFormatting.Format(eventSourceEvent.EventData)); }
protected sealed override void OnEventWritten(EventWrittenEventArgs eventData) { _log(eventData, EventSourceEventFormatting.Format(eventData)); }