From 5160de4fe0a78fb9db86d97580d127283c15c2d2 Mon Sep 17 00:00:00 2001
From: Prithvi Raj
Date: Wed, 30 Nov 2016 16:31:32 -0500
Subject: [PATCH] Make Span#isRPC more readable
- Span#isRPC is set specifically for server or client spans.
---
.../src/main/java/com/uber/jaeger/Span.java | 3 ++-
.../test/java/com/uber/jaeger/SpanTest.java | 23 ++++++++++++++-----
2 files changed, 19 insertions(+), 7 deletions(-)
diff --git a/jaeger-core/src/main/java/com/uber/jaeger/Span.java b/jaeger-core/src/main/java/com/uber/jaeger/Span.java
index f48b353d2..4e036dad2 100644
--- a/jaeger-core/src/main/java/com/uber/jaeger/Span.java
+++ b/jaeger-core/src/main/java/com/uber/jaeger/Span.java
@@ -223,7 +223,8 @@ private boolean handleSpecialTag(String key, Object value) {
if (key.equals(Tags.SPAN_KIND.getKey()) && value instanceof String) {
isClient = Tags.SPAN_KIND_CLIENT.equals(value);
- isRPC = true;
+ boolean isServer = Tags.SPAN_KIND_SERVER.equals(value);
+ isRPC = isClient || isServer;
return true;
}
diff --git a/jaeger-core/src/test/java/com/uber/jaeger/SpanTest.java b/jaeger-core/src/test/java/com/uber/jaeger/SpanTest.java
index 73064fbd2..605ec9481 100644
--- a/jaeger-core/src/test/java/com/uber/jaeger/SpanTest.java
+++ b/jaeger-core/src/test/java/com/uber/jaeger/SpanTest.java
@@ -21,6 +21,12 @@
*/
package com.uber.jaeger;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
import com.uber.jaeger.metrics.InMemoryStatsReporter;
import com.uber.jaeger.reporters.InMemoryReporter;
import com.uber.jaeger.samplers.ConstSampler;
@@ -31,11 +37,6 @@
import java.util.Random;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
public class SpanTest {
private Clock clock;
private InMemoryReporter reporter;
@@ -247,13 +248,23 @@ public void testSpanDetectsLocalComponent() {
}
@Test
- public void testSpanDetectsIsServer() {
+ public void testSpanDetectsIsClient() {
Span span = (Span) tracer.buildSpan("test-service-operation").start();
Tags.SPAN_KIND.set(span, Tags.SPAN_KIND_CLIENT);
+ assertTrue(span.isRPC());
assertTrue(span.isRPCClient());
}
+ @Test
+ public void testSpanDetectsIsServer() {
+ Span span = (Span) tracer.buildSpan("test-service-operation").start();
+ Tags.SPAN_KIND.set(span, Tags.SPAN_KIND_SERVER);
+
+ assertTrue(span.isRPC());
+ assertFalse(span.isRPCClient());
+ }
+
@Test
public void testSpanDetectsSamplingPriorityGreaterThanZero() {
Span span = (Span) tracer.buildSpan("test-service-operation").start();