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

Tighten Span#isRPC check #100

Merged
merged 1 commit into from
Nov 30, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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