public async Task SQSWrapper_SendMessageRequest_WrapRequestWithObject_GeneratesException() { const string TestQueueName = "testQueueName"; const string ExpectedOperationName = "MessageBroker/SQS/Queue/Produce/Named/" + TestQueueName; const string QueueUrl = "https://sqs.us-west-2.amazonaws.com/123456789/" + TestQueueName; const string ExpectedExceptionMessage = "whoopsie"; var sendMessageRequest = new SendMessageRequest(QueueUrl, ExpectedExceptionMessage); try { var result = await SQSWrapper.WrapRequest(SendSQSMessageWithException, sendMessageRequest); } catch (Exception) { var span = _tracer.FinishedSpans()[0]; Assert.That(span.Tags["span.kind"], Is.EqualTo("client")); Assert.That(span.Tags["component"], Is.EqualTo("SQS")); Assert.That(span.Tags["aws.operation"], Is.EqualTo("Produce")); Assert.That(span.Tags["error"], Is.EqualTo(true)); Assert.That(span.LogEntries.Count, Is.EqualTo(1)); Assert.That((string)span.LogEntries[0].Fields["event"], Is.EqualTo("error")); Assert.That(span.LogEntries[0].Fields["error.object"], Is.TypeOf(typeof(AmazonSQSException))); Assert.That((string)span.LogEntries[0].Fields["message"], Is.EqualTo(ExpectedExceptionMessage)); Assert.That((string)span.LogEntries[0].Fields["error.kind"], Is.EqualTo("Exception")); Assert.IsTrue(((string)span.LogEntries[0].Fields["stack"]).Contains("NewRelic.Tests.AwsLambda.AwsLambdaWrapperTests.LambdaWrapperTests.SendSQSMessageWithException(SendMessageRequest sendMessageRequest, CancellationToken cancellationToken)")); Assert.That(span.OperationName, Is.EqualTo(ExpectedOperationName)); return; } Assert.Fail("Did not catch exception as expected."); }
public async Task SQSWrapper_SendMessageRequest_WrapRequestWithQueueAndMessage_BadResponse() { const string TestQueueName = "testQueueName"; const string ExpectedOperationName = "MessageBroker/SQS/Queue/Produce/Named/" + TestQueueName; const string QueueUrl = "https://sqs.us-west-2.amazonaws.com/123456789/" + TestQueueName; var result = await SQSWrapper.WrapRequest(SendSQSMessageWithBadResult, QueueUrl, "myMessage"); var span = _tracer.FinishedSpans()[0]; Assert.That(span.Tags["span.kind"], Is.EqualTo("client")); Assert.That(span.Tags["component"], Is.EqualTo("SQS")); Assert.That(span.Tags["aws.operation"], Is.EqualTo("Produce")); Assert.That(span.Tags["http.status_code"], Is.EqualTo((int)HttpStatusCode.BadRequest)); Assert.That(span.OperationName, Is.EqualTo(ExpectedOperationName)); }
public async Task SQSWrapper_SendMessageBatchRequest_WrapRequestWithObject_OkResponse() { const string TestQueueName = "testQueueName"; const string ExpectedOperationName = "MessageBroker/SQS/Queue/Produce/Named/" + TestQueueName; const string QueueUrl = "https://sqs.us-west-2.amazonaws.com/123456789/" + TestQueueName; var batchEntries = new List <SendMessageBatchRequestEntry>(); batchEntries.Add(new SendMessageBatchRequestEntry("req1", "batch1message")); var sendMessageBatchRequest = new SendMessageBatchRequest(QueueUrl, batchEntries); var result = await SQSWrapper.WrapRequest(SendSQSBatchMessage, sendMessageBatchRequest); var span = _tracer.FinishedSpans()[0]; Assert.That(span.Tags["span.kind"], Is.EqualTo("client")); Assert.That(span.Tags["component"], Is.EqualTo("SQS")); Assert.That(span.Tags["aws.operation"], Is.EqualTo("Produce")); Assert.That(span.Tags["http.status_code"], Is.EqualTo((int)HttpStatusCode.OK)); Assert.That(span.OperationName, Is.EqualTo(ExpectedOperationName)); }