Updating decorators due the new behavior
This commit is contained in:
parent
549943ec63
commit
b152036327
|
@ -2,7 +2,6 @@ package com.datadoghq.trace.integration;
|
||||||
|
|
||||||
import com.datadoghq.trace.DDSpanContext;
|
import com.datadoghq.trace.DDSpanContext;
|
||||||
import com.datadoghq.trace.DDTags;
|
import com.datadoghq.trace.DDTags;
|
||||||
|
|
||||||
import io.opentracing.tag.Tags;
|
import io.opentracing.tag.Tags;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -20,14 +19,12 @@ public class DBComponent extends DDSpanContextDecorator {
|
||||||
@Override
|
@Override
|
||||||
public boolean afterSetTag(DDSpanContext context, String tag, Object value) {
|
public boolean afterSetTag(DDSpanContext context, String tag, Object value) {
|
||||||
//Assign service name
|
//Assign service name
|
||||||
if(super.afterSetTag(context, tag, value)){
|
if (super.afterSetTag(context, tag, value)) {
|
||||||
//Assign span type to DB
|
//Assign span type to DB
|
||||||
context.setSpanType("db");
|
context.setSpanType("db");
|
||||||
|
|
||||||
//Assign resource name
|
//Assign resource name
|
||||||
if(tag.equals(Tags.DB_STATEMENT.getKey())){
|
|
||||||
context.setResourceName(String.valueOf(value));
|
context.setResourceName(String.valueOf(value));
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -15,13 +15,13 @@ public abstract class DDSpanContextDecorator {
|
||||||
|
|
||||||
private String setValue;
|
private String setValue;
|
||||||
|
|
||||||
public boolean afterSetTag(DDSpanContext context, String tag, Object value){
|
public boolean afterSetTag(DDSpanContext context, String tag, Object value) {
|
||||||
if(tag.equals(this.getMatchingTag()) && (this.getMatchingValue()==null || value.equals(this.getMatchingValue()))){
|
if ((this.getMatchingValue() == null || value.equals(this.getMatchingValue()))) {
|
||||||
String targetTag = getSetTag()==null?tag:getSetTag();
|
String targetTag = getSetTag() == null ? tag : getSetTag();
|
||||||
String targetValue = getSetValue()==null?String.valueOf(value):getSetTag();
|
String targetValue = getSetValue() == null ? String.valueOf(value) : getSetTag();
|
||||||
context.setTag(targetTag, targetValue);
|
context.setTag(targetTag, targetValue);
|
||||||
return true;
|
return true;
|
||||||
}else{
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,6 @@ package com.datadoghq.trace.integration;
|
||||||
|
|
||||||
import com.datadoghq.trace.DDSpanContext;
|
import com.datadoghq.trace.DDSpanContext;
|
||||||
import com.datadoghq.trace.DDTags;
|
import com.datadoghq.trace.DDTags;
|
||||||
|
|
||||||
import io.opentracing.tag.Tags;
|
import io.opentracing.tag.Tags;
|
||||||
|
|
||||||
|
|
||||||
|
@ -21,11 +20,12 @@ public class HTTPComponent extends DDSpanContextDecorator {
|
||||||
@Override
|
@Override
|
||||||
public boolean afterSetTag(DDSpanContext context, String tag, Object value) {
|
public boolean afterSetTag(DDSpanContext context, String tag, Object value) {
|
||||||
//Assign service name
|
//Assign service name
|
||||||
if(super.afterSetTag(context, tag, value)){
|
if (super.afterSetTag(context, tag, value)) {
|
||||||
|
|
||||||
//Assign span type to WEB
|
//Assign span type to WEB
|
||||||
context.setSpanType("web");
|
context.setSpanType("web");
|
||||||
return true;
|
return true;
|
||||||
}else{
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,12 +1,11 @@
|
||||||
package com.datadoghq.trace.integration;
|
package com.datadoghq.trace.integration;
|
||||||
|
|
||||||
import java.net.MalformedURLException;
|
|
||||||
|
|
||||||
import com.datadoghq.trace.DDSpanContext;
|
import com.datadoghq.trace.DDSpanContext;
|
||||||
import com.datadoghq.trace.DDTags;
|
import com.datadoghq.trace.DDTags;
|
||||||
|
|
||||||
import io.opentracing.tag.Tags;
|
import io.opentracing.tag.Tags;
|
||||||
|
|
||||||
|
import java.net.MalformedURLException;
|
||||||
|
|
||||||
public class URLAsResourceName extends DDSpanContextDecorator {
|
public class URLAsResourceName extends DDSpanContextDecorator {
|
||||||
|
|
||||||
public URLAsResourceName() {
|
public URLAsResourceName() {
|
||||||
|
@ -18,17 +17,13 @@ public class URLAsResourceName extends DDSpanContextDecorator {
|
||||||
@Override
|
@Override
|
||||||
public boolean afterSetTag(DDSpanContext context, String tag, Object value) {
|
public boolean afterSetTag(DDSpanContext context, String tag, Object value) {
|
||||||
//Assign resource name
|
//Assign resource name
|
||||||
if(tag.equals(Tags.HTTP_URL.getKey())){
|
|
||||||
try {
|
try {
|
||||||
String path = new java.net.URL(String.valueOf(value)).getPath();
|
String path = new java.net.URL(String.valueOf(value)).getPath();
|
||||||
context.setTag(this.getSetTag(),path);
|
context.setTag(this.getSetTag(), path);
|
||||||
} catch (MalformedURLException e) {
|
} catch (MalformedURLException e) {
|
||||||
context.setResourceName(String.valueOf(value));
|
context.setResourceName(String.valueOf(value));
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}else{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue