ShortTag.java 932 字节
Newer Older
P
pengys5 已提交
1
package org.skywalking.apm.trace.tag;
wu-sheng's avatar
wu-sheng 已提交
2

P
pengys5 已提交
3
import org.skywalking.apm.trace.Span;
wu-sheng's avatar
wu-sheng 已提交
4 5 6

/**
 * Do the same thing as {@link StringTag}, just with a {@link Short} value.
P
pengys5 已提交
7
 * <p>
wu-sheng's avatar
wu-sheng 已提交
8 9 10 11 12 13 14 15 16
 * 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) {
P
pengys5 已提交
17
        span.setTag(super.key, (int) tagValue.shortValue());
wu-sheng's avatar
wu-sheng 已提交
18
    }
19

20 21 22 23 24 25 26
    /**
     * Get a tag value, type of {@link Short}.
     * After akka-message/serialize, all tags values are type of {@link String}, convert to {@link Short}, if necessary.
     *
     * @param span
     * @return tag value
     */
P
pengys5 已提交
27 28
    @Override
    public Short get(Span span) {
29
        Integer tagValue = span.getIntTag(super.key);
wu-sheng's avatar
wu-sheng 已提交
30 31
        if (tagValue == null) {
            return null;
32
        } else {
33 34
            return Short.valueOf(tagValue.toString());
        }
35
    }
wu-sheng's avatar
wu-sheng 已提交
36
}