@Test public void testAttemptNumber() { tracer.attemptStarted(0); tracer.attemptFailed(new RuntimeException(), Duration.ofMillis(1)); tracer.attemptStarted(1); tracer.attemptSucceeded(); tracer.operationSucceeded(); verify(span) .addAnnotation(eq("Attempt failed, scheduling next attempt"), attributeCaptor.capture()); assertThat(attributeCaptor.getValue()) .containsEntry("attempt", AttributeValue.longAttributeValue(0)); verify(span).addAnnotation(eq("Attempt succeeded"), attributeCaptor.capture()); assertThat(attributeCaptor.getValue()) .containsEntry("attempt", AttributeValue.longAttributeValue(1)); verify(span).putAttributes(attributeCaptor.capture()); assertThat(attributeCaptor.getValue()) .containsEntry("attempt count", AttributeValue.longAttributeValue(2)); }
@Test public void testRequestCount() { // Initial attempt sent 2 messages, then failed tracer.attemptStarted(0); tracer.requestSent(); tracer.requestSent(); tracer.attemptFailed(new RuntimeException(), Duration.ofMillis(1)); // Next attempt sent 1 message, then successfully finished the attempt and the logical operation. tracer.attemptStarted(1); tracer.requestSent(); tracer.attemptSucceeded(); tracer.operationSucceeded(); verify(span) .addAnnotation(eq("Attempt failed, scheduling next attempt"), attributeCaptor.capture()); assertThat(attributeCaptor.getValue()) .containsEntry("attempt request count", AttributeValue.longAttributeValue(2)); verify(span).addAnnotation(eq("Attempt succeeded"), attributeCaptor.capture()); assertThat(attributeCaptor.getValue()) .containsEntry("attempt request count", AttributeValue.longAttributeValue(1)); verify(span).putAttributes(attributeCaptor.capture()); assertThat(attributeCaptor.getValue()) .containsEntry("total request count", AttributeValue.longAttributeValue(3)); }
@Test public void testResponseCount() { // Initial attempt got 2 messages, then failed tracer.attemptStarted(0); tracer.responseReceived(); tracer.responseReceived(); tracer.attemptFailed(new RuntimeException(), Duration.ofMillis(1)); // Next attempt got 1 message, then successfully finished the attempt and the logical operation. tracer.attemptStarted(1); tracer.responseReceived(); tracer.attemptSucceeded(); tracer.operationSucceeded(); verify(span) .addAnnotation(eq("Attempt failed, scheduling next attempt"), attributeCaptor.capture()); assertThat(attributeCaptor.getValue()) .containsEntry("attempt response count", AttributeValue.longAttributeValue(2)); verify(span).addAnnotation(eq("Attempt succeeded"), attributeCaptor.capture()); assertThat(attributeCaptor.getValue()) .containsEntry("attempt response count", AttributeValue.longAttributeValue(1)); verify(span).putAttributes(attributeCaptor.capture()); assertThat(attributeCaptor.getValue()) .containsEntry("total response count", AttributeValue.longAttributeValue(3)); }
@Test public void testBatchExample() { tracer.batchRequestSent(100, 1000); tracer.attemptStarted(0); tracer.connectionSelected(1); tracer.attemptSucceeded(); tracer.operationSucceeded(); verify(span).putAttribute("batch count", AttributeValue.longAttributeValue(100)); verify(span).putAttribute("batch size", AttributeValue.longAttributeValue(1000)); }
tracer.connectionSelected(2); tracer.attemptSucceeded(); tracer.operationSucceeded();