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

Add host:port/peers to ContextCarrier.

上级 d6696ad2
......@@ -125,9 +125,16 @@ public final class TracerContext {
*/
public void inject(ContextCarrier carrier) {
carrier.setTraceSegmentId(this.segment.getTraceSegmentId());
carrier.setSpanId(this.activeSpan().getSpanId());
Span span = this.activeSpan();
carrier.setSpanId(span.getSpanId());
carrier.setApplicationCode(Config.Agent.APPLICATION_CODE);
carrier.setPeerHost(Tags.PEER_HOST.get(activeSpan()));
String host = Tags.PEER_HOST.get(span);
if(host != null) {
Integer port = Tags.PEER_PORT.get(span);
carrier.setPeerHost(host + ":" + port);
}else{
carrier.setPeerHost(Tags.PEERS.get(span));
}
carrier.setDistributedTraceIds(this.segment.getRelatedGlobalTraces());
carrier.setSampled(this.segment.isSampled());
}
......
......@@ -61,7 +61,8 @@ public class TracerContextTestCase {
TracerContext context = new TracerContext();
Span serviceSpan = context.createSpan("/serviceA");
Span dbSpan = context.createSpan("db/preparedStatement/execute");
Tags.PEER_HOST.set(dbSpan, "127.0.0.1:8080");
Tags.PEER_HOST.set(dbSpan, "127.0.0.1");
Tags.PEER_PORT.set(dbSpan, 8080);
ContextCarrier carrier = new ContextCarrier();
context.inject(carrier);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册