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;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -10,7 +9,7 @@ import io.opentracing.tag.Tags;
|
||||||
* service name and retrieves some DB meta such as the statement
|
* service name and retrieves some DB meta such as the statement
|
||||||
*/
|
*/
|
||||||
public class DBComponent extends DDSpanContextDecorator {
|
public class DBComponent extends DDSpanContextDecorator {
|
||||||
|
|
||||||
public DBComponent() {
|
public DBComponent() {
|
||||||
super();
|
super();
|
||||||
this.setMatchingTag(Tags.COMPONENT.getKey());
|
this.setMatchingTag(Tags.COMPONENT.getKey());
|
||||||
|
@ -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;
|
||||||
|
|
||||||
|
|
||||||
|
@ -11,7 +10,7 @@ import io.opentracing.tag.Tags;
|
||||||
* service name and retrieves some HTTP meta such as the request path
|
* service name and retrieves some HTTP meta such as the request path
|
||||||
*/
|
*/
|
||||||
public class HTTPComponent extends DDSpanContextDecorator {
|
public class HTTPComponent extends DDSpanContextDecorator {
|
||||||
|
|
||||||
public HTTPComponent() {
|
public HTTPComponent() {
|
||||||
super();
|
super();
|
||||||
this.setMatchingTag(Tags.COMPONENT.getKey());
|
this.setMatchingTag(Tags.COMPONENT.getKey());
|
||||||
|
@ -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,14 +1,13 @@
|
||||||
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() {
|
||||||
super();
|
super();
|
||||||
this.setMatchingTag(Tags.HTTP_URL.getKey());
|
this.setMatchingTag(Tags.HTTP_URL.getKey());
|
||||||
|
@ -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;
|
|
||||||
}else{
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue