未验证 提交 54269101 编写于 作者: Z ZS-Oliver 提交者: GitHub

Fix thrift trace broken and wrong arg collected. (#5989)

上级 bf639d3e
......@@ -17,7 +17,8 @@ Release Notes.
* Fix the unexpected RunningContext recreation in the Tomcat plugin.
* Fix the potential NPE when trace_sql_parameters is enabled.
* Update `byte-buddy` to 1.10.19.
* Fix thrift plugin trace link broken when intermediate service does not mount agent
* Fix thrift plugin collects wrong args when the method without parameter.
#### OAP-Backend
* Make meter receiver support MAL.
......
......@@ -100,6 +100,7 @@ public class TServiceClientInterceptor implements InstanceConstructorInterceptor
while (true) {
TFieldIdEnum field = base.fieldForId(++idx);
if (field == null) {
idx--;
break;
}
buffer.append(field.getFieldName()).append(", ");
......
......@@ -21,6 +21,7 @@ package org.apache.skywalking.apm.plugin.thrift.wrapper;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
import org.apache.skywalking.apm.agent.core.context.CarrierItem;
import org.apache.skywalking.apm.agent.core.context.ContextCarrier;
import org.apache.skywalking.apm.agent.core.context.ContextManager;
......@@ -45,6 +46,7 @@ public class ServerInProtocolWrapper extends AbstractProtocolWrapper {
private static final ILog LOGGER = LogManager.getLogger(ServerInProtocolWrapper.class);
private static final StringTag TAG_ARGS = new StringTag("args");
private AbstractContext context;
private static final String HAVE_CREATED_SPAN = "HAVE_CREATED_SPAN";
public ServerInProtocolWrapper(final TProtocol protocol) {
super(protocol);
......@@ -52,6 +54,7 @@ public class ServerInProtocolWrapper extends AbstractProtocolWrapper {
public void initial(AbstractContext context) {
this.context = context;
ContextManager.getRuntimeContext().put(HAVE_CREATED_SPAN, false);
}
@Override
......@@ -72,6 +75,7 @@ public class ServerInProtocolWrapper extends AbstractProtocolWrapper {
span.tag(TAG_ARGS, context.getArguments());
span.setComponent(ComponentsDefine.THRIFT_SERVER);
SpanLayer.asRPCFramework(span);
ContextManager.getRuntimeContext().put(HAVE_CREATED_SPAN, true);
} catch (Throwable throwable) {
LOGGER.error("Failed to resolve header or create EntrySpan.", throwable);
} finally {
......@@ -81,6 +85,24 @@ public class ServerInProtocolWrapper extends AbstractProtocolWrapper {
}
return readFieldBegin();
}
if (field.type == TType.STOP) {
Boolean haveCreatedSpan =
(Boolean) ContextManager.getRuntimeContext().get(HAVE_CREATED_SPAN);
if (haveCreatedSpan != null && !haveCreatedSpan) {
try {
AbstractSpan span = ContextManager.createEntrySpan(
context.getOperatorName(), createContextCarrier(null));
span.start(context.startTime);
span.tag(TAG_ARGS, context.getArguments());
span.setComponent(ComponentsDefine.THRIFT_SERVER);
SpanLayer.asRPCFramework(span);
} catch (Throwable throwable) {
LOGGER.error("Failed to create EntrySpan.", throwable);
} finally {
context = null;
}
}
}
return field;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册