change span.description to span.name

This commit is contained in:
Spencer Gibb
2015-06-26 13:21:04 -06:00
parent 6e7e090a1c
commit fa5996e38e
5 changed files with 31 additions and 31 deletions

View File

@@ -26,16 +26,16 @@ public class DefaultTrace implements Trace {
}
@Override
public TraceScope startSpan(String description) {
return this.startSpan(description, defaultSampler);
public TraceScope startSpan(String name) {
return this.startSpan(name, defaultSampler);
}
@Override
public TraceScope startSpan(String description, TraceInfo tinfo) {
public TraceScope startSpan(String name, TraceInfo tinfo) {
if (tinfo == null) return doStart(null);
MilliSpan span = MilliSpan.builder()
.begin(System.currentTimeMillis())
.description(description)
.name(name)
.traceId(tinfo.getTraceId())
.spanId(idGenerator.create())
.parents(Collections.singletonList(tinfo.getSpanId()))
@@ -45,9 +45,9 @@ public class DefaultTrace implements Trace {
}
@Override
public TraceScope startSpan(String description, Span parent) {
public TraceScope startSpan(String name, Span parent) {
if (parent == null) {
return startSpan(description);
return startSpan(name);
}
Span currentSpan = getCurrentSpan();
if ((currentSpan != null) && (currentSpan != parent)) {
@@ -56,41 +56,41 @@ public class DefaultTrace implements Trace {
"with parent " + parent.toString() + ", but there is already a " +
"currentSpan " + currentSpan);
}
return doStart(createChild(parent, description));
return doStart(createChild(parent, name));
}
@Override
public <T> TraceScope startSpan(String description, Sampler<T> s) {
return startSpan(description, s, null);
public <T> TraceScope startSpan(String name, Sampler<T> s) {
return startSpan(name, s, null);
}
@Override
public <T> TraceScope startSpan(String description, Sampler<T> s, T info) {
public <T> TraceScope startSpan(String name, Sampler<T> s, T info) {
Span span = null;
if (TraceContextHolder.isTracing() || s.next(info)) {
span = createNew(description);
span = createNew(name);
}
return doStart(span);
}
protected Span createNew(String description) {
protected Span createNew(String name) {
Span parent = getCurrentSpan();
if (parent == null) {
return MilliSpan.builder()
.begin(System.currentTimeMillis())
.description(description)
.name(name)
.traceId(idGenerator.create())
.spanId(idGenerator.create())
.build();
} else {
return createChild(parent, description);
return createChild(parent, name);
}
}
protected Span createChild(Span parent, String childDescription) {
protected Span createChild(Span parent, String childname) {
return MilliSpan.builder().
begin(System.currentTimeMillis()).
description(childDescription).
name(childname).
traceId(parent.getTraceId()).
parents(Collections.singletonList(parent.getSpanId())).
//TODO: when lombok plugin supports @Singular parent(parent.getSpanId()).

View File

@@ -17,7 +17,7 @@ public class MilliSpan implements Span {
private long begin;
@NonFinal
private long end = 0;
private String description;
private String name;
private String traceId;
@Singular
private List<String> parents;
@@ -31,7 +31,7 @@ public class MilliSpan implements Span {
public synchronized void stop() {
if (end == 0) {
if (begin == 0)
throw new IllegalStateException("Span for " + description
throw new IllegalStateException("Span for " + name
+ " has not been started");
end = System.currentTimeMillis();
}

View File

@@ -39,11 +39,11 @@ public interface Span {
boolean isRunning();
/**
* Return a textual description of this span.<p/>
* Return a textual name of this span.<p/>
* <p/>
* Will never be null.
*/
String getDescription();
String getName();
/**
* A pseudo-unique (random) number assigned to this span instance.<p/>

View File

@@ -5,7 +5,7 @@ package org.springframework.cloud.sleuth;
* methods to create and manipulate spans.
*
* A 'Span' represents a length of time. It has many other attributes such as a
* description, ID, and even potentially a set of key/value strings attached to
* name, ID, and even potentially a set of key/value strings attached to
* it.
*
* Each thread in your application has a single currently active currentSpan
@@ -46,11 +46,11 @@ public interface Trace {
* If there is no currently active trace span, the trace scope we create will
* be empty.
*
* @param description The description field for the new span to create.
* @param name The name field for the new span to create.
*/
TraceScope startSpan(String description);
TraceScope startSpan(String name);
TraceScope startSpan(String description, TraceInfo tinfo);
TraceScope startSpan(String name, TraceInfo tinfo);
/**
* Creates a new trace scope.
@@ -59,13 +59,13 @@ public interface Trace {
* span that you pass in here as a parameter. The trace scope we create here
* will contain a new span which is a child of 'parent'.
*
* @param description The description field for the new span to create.
* @param name The name field for the new span to create.
*/
TraceScope startSpan(String description, Span parent);
TraceScope startSpan(String name, Span parent);
<T> TraceScope startSpan(String description, Sampler<T> s);
<T> TraceScope startSpan(String name, Sampler<T> s);
<T> TraceScope startSpan(String description, Sampler<T> s, T info);
<T> TraceScope startSpan(String name, Sampler<T> s, T info);
/**
* Pick up an existing span from another thread.

View File

@@ -69,12 +69,12 @@ public class DefaultTraceTests {
assertThat("gen4 was non-empty", gen4.isEmpty(), is(true));
}
private Span assertSpan(List<Span> spans, String parentId, String desc) {
private Span assertSpan(List<Span> spans, String parentId, String name) {
List<Span> found = findSpans(spans, parentId);
assertThat("more than one span with parentId " + parentId, found.size(), is(1));
Span span = found.get(0);
assertThat("description is wrong for span with parentId " + parentId,
span.getDescription(), is(desc));
assertThat("name is wrong for span with parentId " + parentId,
span.getName(), is(name));
return span;
}