DubboSpanGenerator.java 1.8 KB
Newer Older
P
pengys5 已提交
1
package org.skywalking.apm.sniffer.mock.trace.builders.span;
2

3
import org.skywalking.apm.agent.core.context.ContextManager;
P
pengys5 已提交
4 5
import org.skywalking.apm.trace.Span;
import org.skywalking.apm.trace.tag.Tags;
6 7 8 9 10 11 12 13

/**
 * The <code>DubboSpanGenerator</code> generates all possible spans, by tracing Dubbo rpc.
 * Including client/server side span.
 *
 * @author wusheng
 */
public class DubboSpanGenerator {
14
    public static class Client extends SpanGeneration {
P
pengys5 已提交
15 16 17
        @Override
        protected void before() {
            Span span = ContextManager.createSpan("/default_rpc/org.skywalking.apm.test.persistence.PersistenceService.query");
18
            Tags.COMPONENT.set(span, "Dubbo");
P
pengys5 已提交
19
            Tags.URL.set(span, "rest://192.168.1.8:20880/default_rpc/org.skywalking.apm.test.persistence.PersistenceService.query(String)");
20
            Tags.SPAN_KIND.set(span, Tags.SPAN_KIND_SERVER);
wu-sheng's avatar
wu-sheng 已提交
21 22
            span.setPeer_host("192.168.1.8");
            span.setPort(20880);
23 24 25
            Tags.SPAN_LAYER.asHttp(span);
        }

P
pengys5 已提交
26 27
        @Override
        protected void after() {
28
            ContextManager.stopSpan();
29 30 31
        }
    }

32
    public static class Server extends SpanGeneration {
P
pengys5 已提交
33 34 35
        @Override
        protected void before() {
            Span span = ContextManager.createSpan("/default_rpc/org.skywalking.apm.test.persistence.PersistenceService.query");
36
            Tags.COMPONENT.set(span, "Dubbo");
P
pengys5 已提交
37
            Tags.URL.set(span, "rest://192.168.1.8:20880/default_rpc/org.skywalking.apm.test.persistence.PersistenceService.query(String)");
38
            Tags.SPAN_KIND.set(span, Tags.SPAN_KIND_CLIENT);
wu-sheng's avatar
wu-sheng 已提交
39
            span.setPeer_host("10.21.9.35");
40 41 42
            Tags.SPAN_LAYER.asHttp(span);
        }

P
pengys5 已提交
43 44
        @Override
        protected void after() {
45
            ContextManager.stopSpan();
46 47 48
        }
    }
}