Tags are supported.
This commit is contained in:
parent
4958def7c4
commit
001274037a
|
|
@ -0,0 +1,30 @@
|
|||
package com.a.eye.skywalking.trace.tag;
|
||||
|
||||
import com.a.eye.skywalking.trace.Span;
|
||||
|
||||
/**
|
||||
* This is the abstract tag.
|
||||
* All span's tags inherit from {@link AbstractTag},
|
||||
* which provide an easy way to
|
||||
* {@link Span#setTag(String, String)} ,
|
||||
* {@link Span#setTag(String, Number)} ,
|
||||
* {@link Span#setTag(String, boolean)}
|
||||
*
|
||||
* Created by wusheng on 2017/2/17.
|
||||
*/
|
||||
public abstract class AbstractTag<T> {
|
||||
/**
|
||||
* The key of this Tag.
|
||||
*/
|
||||
protected final String key;
|
||||
|
||||
public AbstractTag(String tagKey) {
|
||||
this.key = tagKey;
|
||||
}
|
||||
|
||||
public String getKey() {
|
||||
return key;
|
||||
}
|
||||
|
||||
protected abstract void set(Span span, T tagValue);
|
||||
}
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
package com.a.eye.skywalking.trace.tag;
|
||||
|
||||
import com.a.eye.skywalking.trace.Span;
|
||||
|
||||
/**
|
||||
* Do the same thing as {@link StringTag}, just with a {@link Boolean} value.
|
||||
*
|
||||
* Created by wusheng on 2017/2/17.
|
||||
*/
|
||||
public class BooleanTag extends AbstractTag<Boolean>{
|
||||
public BooleanTag(String key) {
|
||||
super(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void set(Span span, Boolean tagValue) {
|
||||
span.setTag(key, tagValue);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
package com.a.eye.skywalking.trace.tag;
|
||||
|
||||
import com.a.eye.skywalking.trace.Span;
|
||||
|
||||
/**
|
||||
* Do the same thing as {@link StringTag}, just with a {@link Short} value.
|
||||
*
|
||||
* Created by wusheng on 2017/2/17.
|
||||
*/
|
||||
public class ShortTag extends AbstractTag<Short> {
|
||||
public ShortTag(String key) {
|
||||
super(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void set(Span span, Short tagValue) {
|
||||
span.setTag(super.key, tagValue);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
package com.a.eye.skywalking.trace.tag;
|
||||
|
||||
import com.a.eye.skywalking.trace.Span;
|
||||
|
||||
/**
|
||||
* A subclass of {@link AbstractTag},
|
||||
* represent a tag with a {@link String} value.
|
||||
*
|
||||
* Created by wusheng on 2017/2/17.
|
||||
*/
|
||||
public class StringTag extends AbstractTag<String> {
|
||||
public StringTag(String tagKey) {
|
||||
super(tagKey);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void set(Span span, String tagValue) {
|
||||
span.setTag(key, tagValue);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
package com.a.eye.skywalking.trace.tag;
|
||||
|
||||
/**
|
||||
* The span tags are supported by sky-walking engine.
|
||||
* As default, all tags will be stored, but these ones have particular meanings.
|
||||
*
|
||||
* Created by wusheng on 2017/2/17.
|
||||
*/
|
||||
public final class Tags {
|
||||
private Tags() {
|
||||
}
|
||||
|
||||
/**
|
||||
* SPAN_KIND hints at the relationship between spans.
|
||||
* e.g. cl = client; se = server.
|
||||
*/
|
||||
public static StringTag SPAN_KIND = new StringTag("span.kind");
|
||||
|
||||
/**
|
||||
* COMPONENT is a low-cardinality identifier of the module, library, or package that is instrumented.
|
||||
* Like dubbo/dubbox/motan
|
||||
*/
|
||||
public static final StringTag COMPONENT = new StringTag("component");
|
||||
|
||||
/**
|
||||
* ERROR indicates whether a Span ended in an error state.
|
||||
*/
|
||||
public static final BooleanTag ERROR = new BooleanTag("error");
|
||||
}
|
||||
Loading…
Reference in New Issue