public void CheckRecordExceptionEmpty() { using Activity activity = new Activity("exception-test"); using TelemetrySpan telemetrySpan = new TelemetrySpan(activity); telemetrySpan.RecordException(string.Empty, string.Empty, string.Empty); Assert.Empty(activity.Events); telemetrySpan.RecordException(null); Assert.Empty(activity.Events); }
public void CheckRecordExceptionData() { string message = "message"; using Activity activity = new Activity("exception-test"); using TelemetrySpan telemetrySpan = new TelemetrySpan(activity); telemetrySpan.RecordException(new ArgumentNullException(message, new Exception("new-exception"))); Assert.Single(activity.Events); var @event = telemetrySpan.Activity.Events.FirstOrDefault(q => q.Name == SemanticConventions.AttributeExceptionEventName); Assert.Equal(message, @event.Tags.FirstOrDefault(t => t.Key == SemanticConventions.AttributeExceptionMessage).Value); Assert.Equal(typeof(ArgumentNullException).Name, @event.Tags.FirstOrDefault(t => t.Key == SemanticConventions.AttributeExceptionType).Value); }
public void CheckRecordExceptionData2() { string type = "ArgumentNullException"; string message = "message"; string stack = "stack"; using Activity activity = new Activity("exception-test"); using TelemetrySpan telemetrySpan = new TelemetrySpan(activity); telemetrySpan.RecordException(type, message, stack); Assert.Single(activity.Events); var @event = telemetrySpan.Activity.Events.FirstOrDefault(q => q.Name == SemanticConventions.AttributeExceptionEventName); Assert.Equal(message, @event.Tags.FirstOrDefault(t => t.Key == SemanticConventions.AttributeExceptionMessage).Value); Assert.Equal(type, @event.Tags.FirstOrDefault(t => t.Key == SemanticConventions.AttributeExceptionType).Value); Assert.Equal(stack, @event.Tags.FirstOrDefault(t => t.Key == SemanticConventions.AttributeExceptionStacktrace).Value); }