Change the hierarchy of noopspan. And add WithPeerInfo interface.
This commit is contained in:
parent
ad547e00b9
commit
41e459df19
|
|
@ -20,7 +20,6 @@ package org.skywalking.apm.collector.agent.grpc.handler;
|
|||
|
||||
import io.grpc.ManagedChannel;
|
||||
import io.grpc.ManagedChannelBuilder;
|
||||
import org.junit.Test;
|
||||
import org.skywalking.apm.network.proto.Application;
|
||||
import org.skywalking.apm.network.proto.ApplicationMapping;
|
||||
import org.skywalking.apm.network.proto.ApplicationRegisterServiceGrpc;
|
||||
|
|
@ -36,7 +35,7 @@ public class ApplicationRegisterServiceHandlerTestCase {
|
|||
|
||||
private ApplicationRegisterServiceGrpc.ApplicationRegisterServiceBlockingStub stub;
|
||||
|
||||
@Test
|
||||
//@Test
|
||||
public void testRegister() {
|
||||
ManagedChannel channel = ManagedChannelBuilder.forAddress("localhost", 11800).usePlaintext(true).build();
|
||||
stub = ApplicationRegisterServiceGrpc.newBlockingStub(channel);
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@ import org.skywalking.apm.agent.core.context.trace.NoopExitSpan;
|
|||
import org.skywalking.apm.agent.core.context.trace.NoopSpan;
|
||||
import org.skywalking.apm.agent.core.context.trace.TraceSegment;
|
||||
import org.skywalking.apm.agent.core.context.trace.TraceSegmentRef;
|
||||
import org.skywalking.apm.agent.core.context.trace.WithPeerInfo;
|
||||
import org.skywalking.apm.agent.core.dictionary.DictionaryManager;
|
||||
import org.skywalking.apm.agent.core.dictionary.DictionaryUtil;
|
||||
import org.skywalking.apm.agent.core.dictionary.PossibleFound;
|
||||
|
|
@ -97,17 +98,9 @@ public class TracingContext implements AbstractTracerContext {
|
|||
throw new IllegalStateException("Inject can be done only in Exit Span");
|
||||
}
|
||||
|
||||
String peer;
|
||||
int peerId;
|
||||
if (span instanceof NoopExitSpan) {
|
||||
NoopExitSpan exitSpan = (NoopExitSpan)span;
|
||||
peerId = exitSpan.getPeerId();
|
||||
peer = exitSpan.getPeer();
|
||||
} else {
|
||||
ExitSpan exitSpan = (ExitSpan)span;
|
||||
peerId = exitSpan.getPeerId();
|
||||
peer = exitSpan.getPeer();
|
||||
}
|
||||
WithPeerInfo spanWithPeer = (WithPeerInfo)span;
|
||||
String peer = spanWithPeer.getPeer();
|
||||
int peerId = spanWithPeer.getPeerId();
|
||||
|
||||
carrier.setTraceSegmentId(this.segment.getTraceSegmentId());
|
||||
carrier.setSpanId(span.getSpanId());
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ import org.skywalking.apm.network.trace.component.Component;
|
|||
*
|
||||
* @author wusheng
|
||||
*/
|
||||
public class ExitSpan extends StackBasedTracingSpan {
|
||||
public class ExitSpan extends StackBasedTracingSpan implements WithPeerInfo {
|
||||
private String peer;
|
||||
private int peerId;
|
||||
|
||||
|
|
@ -147,10 +147,12 @@ public class ExitSpan extends StackBasedTracingSpan {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPeerId() {
|
||||
return peerId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPeer() {
|
||||
return peer;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,10 +18,7 @@
|
|||
|
||||
package org.skywalking.apm.agent.core.context.trace;
|
||||
|
||||
import java.util.Map;
|
||||
import org.skywalking.apm.network.trace.component.Component;
|
||||
|
||||
public class NoopExitSpan implements AbstractNoopSpan {
|
||||
public class NoopExitSpan extends NoopSpan implements WithPeerInfo {
|
||||
|
||||
private String peer;
|
||||
private int peerId;
|
||||
|
|
@ -34,71 +31,18 @@ public class NoopExitSpan implements AbstractNoopSpan {
|
|||
this.peer = peer;
|
||||
}
|
||||
|
||||
@Override public AbstractSpan setComponent(Component component) {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override public AbstractSpan setComponent(String componentName) {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override public AbstractSpan setLayer(SpanLayer layer) {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override public AbstractSpan tag(String key, String value) {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override public AbstractSpan log(Throwable t) {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override public AbstractSpan errorOccurred() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override public boolean isEntry() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override public boolean isExit() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override public AbstractSpan log(long timestamp, Map<String, ?> event) {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override public AbstractSpan setOperationName(String operationName) {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override public AbstractSpan start() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override public int getSpanId() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override public int getOperationId() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override public String getOperationName() {
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override public AbstractSpan setOperationId(int operationId) {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPeerId() {
|
||||
return peerId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPeer() {
|
||||
return peer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isExit() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ import org.skywalking.apm.network.trace.component.Component;
|
|||
*
|
||||
* @author wusheng
|
||||
*/
|
||||
public class NoopSpan implements AbstractNoopSpan {
|
||||
public class NoopSpan implements AbstractSpan {
|
||||
public NoopSpan() {
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -19,9 +19,10 @@
|
|||
package org.skywalking.apm.agent.core.context.trace;
|
||||
|
||||
/**
|
||||
* The <code>AbstractNoopSpan</code> represents a span implementation without any actual operation.
|
||||
*
|
||||
* @author zhangxin
|
||||
* @author wusheng
|
||||
*/
|
||||
public interface AbstractNoopSpan extends AbstractSpan {
|
||||
public interface WithPeerInfo {
|
||||
int getPeerId();
|
||||
|
||||
String getPeer();
|
||||
}
|
||||
Loading…
Reference in New Issue