Merge pull request #49 from DataDog/gpolaert/deprecated

Fixing deprecated methods
This commit is contained in:
Tyler Benson 2017-07-17 12:27:13 -07:00 committed by GitHub
commit 9868144455
6 changed files with 44 additions and 21 deletions

View File

@ -24,7 +24,6 @@ dependencies {
compile group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.8.8' compile group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.8.8'
compile group: 'com.fasterxml.jackson.dataformat', name: 'jackson-dataformat-yaml', version: '2.8.8' compile group: 'com.fasterxml.jackson.dataformat', name: 'jackson-dataformat-yaml', version: '2.8.8'
compile group: 'org.slf4j', name: 'slf4j-api', version: '1.7.25' compile group: 'org.slf4j', name: 'slf4j-api', version: '1.7.25'
compile group: 'ch.qos.logback', name: 'logback-classic', version: '1.2.3'
compile group: 'com.google.auto.service', name: 'auto-service', version: '1.0-rc3' compile group: 'com.google.auto.service', name: 'auto-service', version: '1.0-rc3'
testCompile group: 'junit', name: 'junit', version: '4.12' testCompile group: 'junit', name: 'junit', version: '4.12'
testCompile group: 'org.assertj', name: 'assertj-core', version: '3.6.2' testCompile group: 'org.assertj', name: 'assertj-core', version: '3.6.2'

View File

@ -10,14 +10,22 @@ public class ExampleWithLoggingWriter {
DDTracer tracer = new DDTracer(new LoggingWriter(), new AllSampler()); DDTracer tracer = new DDTracer(new LoggingWriter(), new AllSampler());
Span parent = Span parent =
tracer.buildSpan("hello-world").withServiceName("service-name").withSpanType("web").start(); tracer
.buildSpan("hello-world")
.withServiceName("service-name")
.withSpanType("web")
.startManual();
parent.setBaggageItem("a-baggage", "value"); parent.setBaggageItem("a-baggage", "value");
Thread.sleep(100); Thread.sleep(100);
Span child = Span child =
tracer.buildSpan("hello-world").asChildOf(parent).withResourceName("resource-name").start(); tracer
.buildSpan("hello-world")
.asChildOf(parent)
.withResourceName("resource-name")
.startManual();
Thread.sleep(100); Thread.sleep(100);

View File

@ -28,7 +28,7 @@ public class DDSpanBuilderTest {
public void shouldBuildSimpleSpan() { public void shouldBuildSimpleSpan() {
final String expectedName = "fakeName"; final String expectedName = "fakeName";
DDSpan span = tracer.buildSpan(expectedName).withServiceName("foo").start(); DDSpan span = tracer.buildSpan(expectedName).withServiceName("foo").startManual();
assertThat(span.getOperationName()).isEqualTo(expectedName); assertThat(span.getOperationName()).isEqualTo(expectedName);
} }
@ -52,14 +52,14 @@ public class DDSpanBuilderTest {
.withTag("1", (Boolean) tags.get("1")) .withTag("1", (Boolean) tags.get("1"))
.withTag("2", (String) tags.get("2")) .withTag("2", (String) tags.get("2"))
.withTag("3", (Number) tags.get("3")) .withTag("3", (Number) tags.get("3"))
.start(); .startManual();
assertThat(span.getOperationName()).isEqualTo(expectedName); assertThat(span.getOperationName()).isEqualTo(expectedName);
assertThat(span.getTags()).containsAllEntriesOf(tags); assertThat(span.getTags()).containsAllEntriesOf(tags);
// with no tag provided // with no tag provided
span = tracer.buildSpan(expectedName).withServiceName("foo").start(); span = tracer.buildSpan(expectedName).withServiceName("foo").startManual();
assertThat(span.getTags()).isNotNull(); assertThat(span.getTags()).isNotNull();
assertThat(span.getTags().size()).isEqualTo(2); assertThat(span.getTags().size()).isEqualTo(2);
@ -77,7 +77,7 @@ public class DDSpanBuilderTest {
.withServiceName(expectedService) .withServiceName(expectedService)
.withErrorFlag() .withErrorFlag()
.withSpanType(expectedType) .withSpanType(expectedType)
.start(); .startManual();
DDSpanContext actualContext = span.context(); DDSpanContext actualContext = span.context();
@ -96,7 +96,7 @@ public class DDSpanBuilderTest {
final String expectedName = "fakeName"; final String expectedName = "fakeName";
DDSpan span = tracer.buildSpan(expectedName).withServiceName("foo").start(); DDSpan span = tracer.buildSpan(expectedName).withServiceName("foo").startManual();
assertThat(span.getBaggageItem(DDSpanContext.LANGUAGE_FIELDNAME)).isEqualTo("java"); assertThat(span.getBaggageItem(DDSpanContext.LANGUAGE_FIELDNAME)).isEqualTo("java");
} }
@ -120,7 +120,7 @@ public class DDSpanBuilderTest {
// auto-timestamp in nanoseconds // auto-timestamp in nanoseconds
long tick = System.currentTimeMillis(); long tick = System.currentTimeMillis();
span = tracer.buildSpan(expectedName).withServiceName("foo").start(); span = tracer.buildSpan(expectedName).withServiceName("foo").startManual();
// Give a range of +/- 2 millis // Give a range of +/- 2 millis
assertThat(span.getStartTime()) assertThat(span.getStartTime())
@ -141,7 +141,11 @@ public class DDSpanBuilderTest {
final String expectedName = "fakeName"; final String expectedName = "fakeName";
DDSpan span = DDSpan span =
tracer.buildSpan(expectedName).withServiceName("foo").asChildOf(mockedContext).start(); tracer
.buildSpan(expectedName)
.withServiceName("foo")
.asChildOf(mockedContext)
.startManual();
DDSpanContext actualContext = span.context(); DDSpanContext actualContext = span.context();
@ -167,7 +171,7 @@ public class DDSpanBuilderTest {
.withServiceName("foo") .withServiceName("foo")
.withResourceName(expectedParentResourceName) .withResourceName(expectedParentResourceName)
.withSpanType(expectedParentType) .withSpanType(expectedParentType)
.start(); .startManual();
parent.setBaggageItem(expectedBaggageItemKey, expectedBaggageItemValue); parent.setBaggageItem(expectedBaggageItemKey, expectedBaggageItemValue);
@ -177,7 +181,7 @@ public class DDSpanBuilderTest {
.buildSpan(expectedName) .buildSpan(expectedName)
.withServiceName(expectedParentServiceName) .withServiceName(expectedParentServiceName)
.asChildOf(parent) .asChildOf(parent)
.start(); .startManual();
assertThat(span.getOperationName()).isEqualTo(expectedName); assertThat(span.getOperationName()).isEqualTo(expectedName);
assertThat(span.getBaggageItem(expectedBaggageItemKey)).isEqualTo(expectedBaggageItemValue); assertThat(span.getBaggageItem(expectedBaggageItemKey)).isEqualTo(expectedBaggageItemValue);
@ -193,7 +197,7 @@ public class DDSpanBuilderTest {
.withResourceName(expectedChildResourceName) .withResourceName(expectedChildResourceName)
.withSpanType(expectedChildType) .withSpanType(expectedChildType)
.asChildOf(parent) .asChildOf(parent)
.start(); .startManual();
assertThat(span.getOperationName()).isEqualTo(expectedName); assertThat(span.getOperationName()).isEqualTo(expectedName);
assertThat(span.getBaggageItem(expectedBaggageItemKey)).isEqualTo(expectedBaggageItemValue); assertThat(span.getBaggageItem(expectedBaggageItemKey)).isEqualTo(expectedBaggageItemValue);
@ -211,7 +215,7 @@ public class DDSpanBuilderTest {
// root (aka spans[0]) is the parent // root (aka spans[0]) is the parent
// others are just for fun // others are just for fun
DDSpan root = tracer.buildSpan("fake_O").withServiceName("foo").start(); DDSpan root = tracer.buildSpan("fake_O").withServiceName("foo").startManual();
spans.add(root); spans.add(root);
Thread.sleep(200); Thread.sleep(200);
@ -219,7 +223,11 @@ public class DDSpanBuilderTest {
for (int i = 1; i <= 10; i++) { for (int i = 1; i <= 10; i++) {
spans.add( spans.add(
tracer.buildSpan("fake_" + i).withServiceName("foo").asChildOf(spans.get(i - 1)).start()); tracer
.buildSpan("fake_" + i)
.withServiceName("foo")
.asChildOf(spans.get(i - 1))
.startManual());
} }
spans.get(1).finish(tickEnd); spans.get(1).finish(tickEnd);

View File

@ -50,7 +50,7 @@ public class DDSpanTest {
final String expectedName = "operationName"; final String expectedName = "operationName";
DDSpan span = new DDTracer().buildSpan(expectedName).start(); DDSpan span = new DDTracer().buildSpan(expectedName).startManual();
// ResourceName = expectedName // ResourceName = expectedName
assertThat(span.getResourceName()).isEqualTo(expectedName); assertThat(span.getResourceName()).isEqualTo(expectedName);
assertThat(span.getServiceName()).isEqualTo(DDTracer.UNASSIGNED_DEFAULT_SERVICE_NAME); assertThat(span.getServiceName()).isEqualTo(DDTracer.UNASSIGNED_DEFAULT_SERVICE_NAME);
@ -62,7 +62,7 @@ public class DDSpanTest {
.buildSpan(expectedName) .buildSpan(expectedName)
.withResourceName(expectedResourceName) .withResourceName(expectedResourceName)
.withServiceName("foo") .withServiceName("foo")
.start(); .startManual();
assertThat(span.getResourceName()).isEqualTo(expectedResourceName); assertThat(span.getResourceName()).isEqualTo(expectedResourceName);
assertThat(span.getServiceName()).isEqualTo("foo"); assertThat(span.getServiceName()).isEqualTo("foo");

View File

@ -22,14 +22,22 @@ public class ExampleWithDDAgentWriter {
DDTracer tracer = new DDTracer(writer, sampler); DDTracer tracer = new DDTracer(writer, sampler);
Span parent = Span parent =
tracer.buildSpan("hello-world").withServiceName("service-name").withSpanType("web").start(); tracer
.buildSpan("hello-world")
.withServiceName("service-name")
.withSpanType("web")
.startManual();
Thread.sleep(100); Thread.sleep(100);
parent.setBaggageItem("a-baggage", "value"); parent.setBaggageItem("a-baggage", "value");
Span child = Span child =
tracer.buildSpan("hello-world").asChildOf(parent).withResourceName("resource-name").start(); tracer
.buildSpan("hello-world")
.asChildOf(parent)
.withResourceName("resource-name")
.startManual();
Thread.sleep(100); Thread.sleep(100);

View File

@ -27,12 +27,12 @@ public class DDAgentWriterTest {
//Setup //Setup
DDTracer tracer = new DDTracer(); DDTracer tracer = new DDTracer();
parent = tracer.buildSpan("hello-world").withServiceName("service-name").start(); parent = tracer.buildSpan("hello-world").withServiceName("service-name").startManual();
parent.setBaggageItem("a-baggage", "value"); parent.setBaggageItem("a-baggage", "value");
Thread.sleep(100); Thread.sleep(100);
DDSpan child = tracer.buildSpan("hello-world").asChildOf(parent).start(); DDSpan child = tracer.buildSpan("hello-world").asChildOf(parent).startManual();
Thread.sleep(100); Thread.sleep(100);
child.finish(); child.finish();