提交 00127403 编写于 作者: wu-sheng's avatar wu-sheng

Tags are supported.

上级 4958def7
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);
}
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);
}
}
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);
}
}
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);
}
}
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");
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册