Skip to content
This repository has been archived by the owner on Jul 1, 2022. It is now read-only.

Commit

Permalink
Make Span#isRPC more readable
Browse files Browse the repository at this point in the history
- Span#isRPC is set specifically for server or client spans.
  • Loading branch information
vprithvi committed Nov 30, 2016
1 parent dcfde78 commit 5160de4
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 7 deletions.
3 changes: 2 additions & 1 deletion jaeger-core/src/main/java/com/uber/jaeger/Span.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
23 changes: 17 additions & 6 deletions jaeger-core/src/test/java/com/uber/jaeger/SpanTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit 5160de4

Please sign in to comment.