Rename DDTracer, DDSpanBuilder + Remove Arraylist externally
This commit is contained in:
parent
b6632eef7b
commit
cf5f2541ca
|
@ -1,29 +1,32 @@
|
|||
package com.datadoghq.trace.impl;
|
||||
|
||||
import java.time.Clock;
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonGetter;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
|
||||
import io.opentracing.Span;
|
||||
import io.opentracing.SpanContext;
|
||||
|
||||
|
||||
public class DDSpan implements io.opentracing.Span {
|
||||
|
||||
protected final Tracer tracer;
|
||||
protected final DDTracer tracer;
|
||||
protected String operationName;
|
||||
protected Map<String, Object> tags;
|
||||
protected long startTimeNano;
|
||||
protected long durationNano;
|
||||
protected final DDSpanContext context;
|
||||
protected final ArrayList<Span> trace;
|
||||
protected final List<Span> trace;
|
||||
|
||||
DDSpan(
|
||||
Tracer tracer,
|
||||
DDTracer tracer,
|
||||
String operationName,
|
||||
ArrayList<Span> trace,
|
||||
List<Span> trace,
|
||||
Map<String, Object> tags,
|
||||
Long timestampMilliseconds,
|
||||
DDSpanContext context) {
|
||||
|
@ -69,7 +72,7 @@ public class DDSpan implements io.opentracing.Span {
|
|||
return context.getTraceId() == context.getSpanId();
|
||||
}
|
||||
|
||||
public io.opentracing.Span setTag(String tag, String value) {
|
||||
public Span setTag(String tag, String value) {
|
||||
return this.setTag(tag, value);
|
||||
}
|
||||
|
||||
|
@ -184,7 +187,7 @@ public class DDSpan implements io.opentracing.Span {
|
|||
}
|
||||
|
||||
@JsonIgnore
|
||||
public ArrayList<Span> getTrace() {
|
||||
public List<Span> getTrace() {
|
||||
return trace;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,7 +29,7 @@ public class DDSpanSerializer implements SpanSerializer {
|
|||
|
||||
|
||||
List<Span> array = new ArrayList<Span>();
|
||||
Tracer tracer = new Tracer();
|
||||
DDTracer tracer = new DDTracer();
|
||||
|
||||
Span parent = tracer
|
||||
.buildSpan("hello-world")
|
||||
|
|
|
@ -9,12 +9,12 @@ import io.opentracing.SpanContext;
|
|||
import io.opentracing.propagation.Format;
|
||||
|
||||
|
||||
public class Tracer implements io.opentracing.Tracer {
|
||||
public class DDTracer implements io.opentracing.Tracer {
|
||||
|
||||
private TracerLogger logger = new TracerLogger();
|
||||
|
||||
public SpanBuilder buildSpan(String operationName) {
|
||||
return new SpanBuilder(operationName);
|
||||
public DDSpanBuilder buildSpan(String operationName) {
|
||||
return new DDSpanBuilder(operationName);
|
||||
}
|
||||
|
||||
public <C> void inject(SpanContext spanContext, Format<C> format, C c) {
|
||||
|
@ -26,10 +26,10 @@ public class Tracer implements io.opentracing.Tracer {
|
|||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public class SpanBuilder implements io.opentracing.Tracer.SpanBuilder {
|
||||
public class DDSpanBuilder implements SpanBuilder {
|
||||
|
||||
private final String operationName;
|
||||
private Map<String, Object> tags = new HashMap<>();
|
||||
private Map<String, Object> tags = new HashMap<String, Object>();
|
||||
private Long timestamp;
|
||||
private DDSpan parent;
|
||||
private String serviceName;
|
||||
|
@ -37,63 +37,63 @@ public class Tracer implements io.opentracing.Tracer {
|
|||
private boolean errorFlag;
|
||||
private String spanType;
|
||||
|
||||
public SpanBuilder(String operationName) {
|
||||
public DDSpanBuilder(String operationName) {
|
||||
this.operationName = operationName;
|
||||
}
|
||||
|
||||
public Tracer.SpanBuilder asChildOf(SpanContext spanContext) {
|
||||
public DDTracer.DDSpanBuilder asChildOf(SpanContext spanContext) {
|
||||
throw new UnsupportedOperationException("Should be a complete span");
|
||||
//this.parent = spanContext;
|
||||
//return this;
|
||||
}
|
||||
|
||||
public Tracer.SpanBuilder asChildOf(Span span) {
|
||||
public DDTracer.DDSpanBuilder asChildOf(Span span) {
|
||||
this.parent = (DDSpan) span;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Tracer.SpanBuilder addReference(String referenceType, SpanContext spanContext) {
|
||||
public DDTracer.DDSpanBuilder addReference(String referenceType, SpanContext spanContext) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public Tracer.SpanBuilder withTag(String tag, Number number) {
|
||||
public DDTracer.DDSpanBuilder withTag(String tag, Number number) {
|
||||
return withTag(tag, (Object) number);
|
||||
}
|
||||
|
||||
public Tracer.SpanBuilder withTag(String tag, String string) {
|
||||
public DDTracer.DDSpanBuilder withTag(String tag, String string) {
|
||||
return withTag(tag, (Object) string);
|
||||
}
|
||||
|
||||
public Tracer.SpanBuilder withTag(String tag, boolean bool) {
|
||||
public DDTracer.DDSpanBuilder withTag(String tag, boolean bool) {
|
||||
return withTag(tag, (Object) bool);
|
||||
}
|
||||
|
||||
private Tracer.SpanBuilder withTag(String tag, Object value) {
|
||||
private DDTracer.DDSpanBuilder withTag(String tag, Object value) {
|
||||
this.tags.put(tag, value);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Tracer.SpanBuilder withStartTimestamp(long timestampMillis) {
|
||||
public DDTracer.DDSpanBuilder withStartTimestamp(long timestampMillis) {
|
||||
this.timestamp = timestampMillis;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Tracer.SpanBuilder withServiceName(String serviceName) {
|
||||
public DDTracer.DDSpanBuilder withServiceName(String serviceName) {
|
||||
this.serviceName = serviceName;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Tracer.SpanBuilder withResourceName(String resourceName) {
|
||||
public DDTracer.DDSpanBuilder withResourceName(String resourceName) {
|
||||
this.resourceName = resourceName;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Tracer.SpanBuilder withErrorFlag() {
|
||||
public DDTracer.DDSpanBuilder withErrorFlag() {
|
||||
this.errorFlag = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Tracer.SpanBuilder withSpanType(String spanType) {
|
||||
public DDTracer.DDSpanBuilder withSpanType(String spanType) {
|
||||
this.spanType = spanType;
|
||||
return this;
|
||||
}
|
||||
|
@ -105,13 +105,13 @@ public class Tracer implements io.opentracing.Tracer {
|
|||
DDSpanContext context = buildTheSpanContext();
|
||||
logger.startNewSpan(this.operationName, context.getSpanId());
|
||||
|
||||
ArrayList<Span> trace = null;
|
||||
List<Span> trace = null;
|
||||
if (this.parent != null) {
|
||||
trace = parent.getTrace();
|
||||
}
|
||||
|
||||
return new DDSpan(
|
||||
Tracer.this,
|
||||
DDTracer.this,
|
||||
this.operationName,
|
||||
trace,
|
||||
this.tags,
|
|
@ -10,7 +10,7 @@ import java.util.List;
|
|||
|
||||
import com.datadoghq.trace.SpanSerializer;
|
||||
import com.datadoghq.trace.impl.DDSpanSerializer;
|
||||
import com.datadoghq.trace.impl.Tracer;
|
||||
import com.datadoghq.trace.impl.DDTracer;
|
||||
|
||||
import io.opentracing.Span;
|
||||
|
||||
|
@ -88,7 +88,7 @@ public class DDApi {
|
|||
public static void main(String[] args) throws Exception{
|
||||
|
||||
List<Span> array = new ArrayList<Span>();
|
||||
Tracer tracer = new Tracer();
|
||||
DDTracer tracer = new DDTracer();
|
||||
|
||||
Span parent = tracer
|
||||
.buildSpan("hello-world")
|
||||
|
|
|
@ -2,7 +2,7 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
|
||||
import com.datadoghq.trace.Writer;
|
||||
import com.datadoghq.trace.impl.Tracer;
|
||||
import com.datadoghq.trace.impl.DDTracer;
|
||||
import com.datadoghq.trace.writer.impl.DDAgentWriter;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
|
||||
|
@ -13,7 +13,7 @@ public class Example {
|
|||
public static void main(String[] args) throws Exception{
|
||||
List<Span> trace = new ArrayList<Span>();
|
||||
|
||||
Tracer tracer = new Tracer();
|
||||
DDTracer tracer = new DDTracer();
|
||||
Writer writer = new DDAgentWriter();
|
||||
|
||||
Span parent = tracer
|
||||
|
|
|
@ -16,11 +16,11 @@ import static org.mockito.Mockito.when;
|
|||
|
||||
public class DDSpanBuilderTest {
|
||||
|
||||
private Tracer tracer;
|
||||
private DDTracer tracer;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
tracer = new Tracer();
|
||||
tracer = new DDTracer();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -5,13 +5,13 @@ import org.junit.Test;
|
|||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
public class TracerTest {
|
||||
public class DDTracerTest {
|
||||
|
||||
|
||||
@Test
|
||||
public void testGenerateNewId() {
|
||||
|
||||
Tracer tracer = new Tracer();
|
||||
DDTracer tracer = new DDTracer();
|
||||
long id1 = tracer.generateNewId();
|
||||
long id2 = tracer.generateNewId();
|
||||
|
Loading…
Reference in New Issue