Updating decorators due the new behavior

This commit is contained in:
Guillaume Polaert 2017-05-29 17:12:01 +02:00
parent 549943ec63
commit b152036327
4 changed files with 22 additions and 30 deletions

View File

@ -2,7 +2,6 @@ package com.datadoghq.trace.integration;
import com.datadoghq.trace.DDSpanContext;
import com.datadoghq.trace.DDTags;
import io.opentracing.tag.Tags;
/**
@ -20,14 +19,12 @@ public class DBComponent extends DDSpanContextDecorator {
@Override
public boolean afterSetTag(DDSpanContext context, String tag, Object value) {
//Assign service name
if(super.afterSetTag(context, tag, value)){
if (super.afterSetTag(context, tag, value)) {
//Assign span type to DB
context.setSpanType("db");
//Assign resource name
if(tag.equals(Tags.DB_STATEMENT.getKey())){
context.setResourceName(String.valueOf(value));
}
context.setResourceName(String.valueOf(value));
return true;
}
return false;

View File

@ -15,13 +15,13 @@ public abstract class DDSpanContextDecorator {
private String setValue;
public boolean afterSetTag(DDSpanContext context, String tag, Object value){
if(tag.equals(this.getMatchingTag()) && (this.getMatchingValue()==null || value.equals(this.getMatchingValue()))){
String targetTag = getSetTag()==null?tag:getSetTag();
String targetValue = getSetValue()==null?String.valueOf(value):getSetTag();
public boolean afterSetTag(DDSpanContext context, String tag, Object value) {
if ((this.getMatchingValue() == null || value.equals(this.getMatchingValue()))) {
String targetTag = getSetTag() == null ? tag : getSetTag();
String targetValue = getSetValue() == null ? String.valueOf(value) : getSetTag();
context.setTag(targetTag, targetValue);
return true;
}else{
} else {
return false;
}
}

View File

@ -2,7 +2,6 @@ package com.datadoghq.trace.integration;
import com.datadoghq.trace.DDSpanContext;
import com.datadoghq.trace.DDTags;
import io.opentracing.tag.Tags;
@ -21,11 +20,12 @@ public class HTTPComponent extends DDSpanContextDecorator {
@Override
public boolean afterSetTag(DDSpanContext context, String tag, Object value) {
//Assign service name
if(super.afterSetTag(context, tag, value)){
if (super.afterSetTag(context, tag, value)) {
//Assign span type to WEB
context.setSpanType("web");
return true;
}else{
} else {
return false;
}
}

View File

@ -1,12 +1,11 @@
package com.datadoghq.trace.integration;
import java.net.MalformedURLException;
import com.datadoghq.trace.DDSpanContext;
import com.datadoghq.trace.DDTags;
import io.opentracing.tag.Tags;
import java.net.MalformedURLException;
public class URLAsResourceName extends DDSpanContextDecorator {
public URLAsResourceName() {
@ -18,17 +17,13 @@ public class URLAsResourceName extends DDSpanContextDecorator {
@Override
public boolean afterSetTag(DDSpanContext context, String tag, Object value) {
//Assign resource name
if(tag.equals(Tags.HTTP_URL.getKey())){
try {
String path = new java.net.URL(String.valueOf(value)).getPath();
context.setTag(this.getSetTag(),path);
} catch (MalformedURLException e) {
context.setResourceName(String.valueOf(value));
}
return true;
}else{
return false;
try {
String path = new java.net.URL(String.valueOf(value)).getPath();
context.setTag(this.getSetTag(), path);
} catch (MalformedURLException e) {
context.setResourceName(String.valueOf(value));
}
return true;
}
}