Added the ability to setup service, resource, and spantype on the
builder by tags
ADD
src/main/java/com/datadoghq/trace/DDTags.java
+package com.datadoghq.trace;
+
+public class DDTags {
+ public static final String SPAN_TYPE = "span-type";
+ public static final String SERVICE_NAME = "service-name";
+ public static final String RESOURCE_NAME = "resource-name";
+}

MODIFY
src/main/java/com/datadoghq/trace/DDTracer.java
src/main/java/com/datadoghq/trace/DDTracer.java
package com.datadoghq.trace;
+import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
+
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
@@ -162,8 +164,16 @@ public class DDTracer implements io.opentracing.Tracer {
}
public DDTracer.DDSpanBuilder withTag(String tag, String string) {
+ if(tag.equals(DDTags.SERVICE_NAME)){
+ return withServiceName(string);
+ }else if(tag.equals(DDTags.RESOURCE_NAME)){
+ return withResourceName(string);
+ }else if(tag.equals(DDTags.SPAN_TYPE)){
+ return withSpanType(string);
+ }else{
return withTag(tag, (Object) string);
}
+ }
public DDTracer.DDSpanBuilder withTag(String tag, boolean bool) {
return withTag(tag, (Object) bool);

MODIFY
src/main/java/com/datadoghq/trace/integration/MapperDecorator.java
src/main/java/com/datadoghq/trace/integration/MapperDecorator.java
@@ -3,16 +3,13 @@ package com.datadoghq.trace.integration;
import java.util.Map;
import com.datadoghq.trace.DDSpanContext;
+import com.datadoghq.trace.DDTags;
/**
* Remap some tags to other tags
*/
public class MapperDecorator implements DDSpanContextDecorator {
- public static final String SPAN_TYPE = "spanType";
- public static final String SERVICE_NAME = "serviceName";
- public static final String RESOURCE_NAME = "resourceName";
-
private final Map<String,String> mappings;
public MapperDecorator(Map<String, String> mappings) {
@@ -24,11 +21,11 @@ public class MapperDecorator implements DDSpanContextDecorator {
public void afterSetTag(DDSpanContext context, String tag, Object value) {
String toAssign = mappings.get(tag);
if(toAssign != null){
- if(toAssign.equals(SPAN_TYPE)){
+ if(toAssign.equals(DDTags.SPAN_TYPE)){
context.setSpanType(String.valueOf(value));
- }else if(toAssign.equals(SERVICE_NAME)){
+ }else if(toAssign.equals(DDTags.SERVICE_NAME)){
context.setServiceName(String.valueOf(value));
- }else if(toAssign.equals(RESOURCE_NAME)){
+ }else if(toAssign.equals(DDTags.RESOURCE_NAME)){
context.setResourceName(String.valueOf(value));
}else{
//General remap

Added the ability to setup service, resource, and spantype on the
builder by tags