diff --git a/CHANGES.md b/CHANGES.md index 23f4db54d..da8a191f2 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -16,6 +16,7 @@ Release Notes. * Refactor kotlin coroutine plugin with CoroutineContext. * Fix OracleURLParser ignoring actual port when :SID is absent. * Change gRPC instrumentation point to fix plugin not working for server side. +* Fix servicecomb plugin trace break. #### Documentation * Update docs of Tracing APIs, reorganize the API docs into six parts. diff --git a/apm-sniffer/apm-sdk-plugin/servicecomb-plugin/servicecomb-java-chassis-2.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/servicecomb/v2/ProducerOperationHandlerInterceptor.java b/apm-sniffer/apm-sdk-plugin/servicecomb-plugin/servicecomb-java-chassis-2.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/servicecomb/v2/ProducerOperationHandlerInterceptor.java index bbd620f40..4fe3d6f2c 100644 --- a/apm-sniffer/apm-sdk-plugin/servicecomb-plugin/servicecomb-java-chassis-2.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/servicecomb/v2/ProducerOperationHandlerInterceptor.java +++ b/apm-sniffer/apm-sdk-plugin/servicecomb-plugin/servicecomb-java-chassis-2.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/servicecomb/v2/ProducerOperationHandlerInterceptor.java @@ -42,7 +42,14 @@ public class ProducerOperationHandlerInterceptor implements InstanceMethodsAroun CarrierItem next = contextCarrier.items(); while (next.hasNext()) { next = next.next(); - next.setHeadValue(invocation.getContext().get(next.getHeadKey())); + String headKey = next.getHeadKey(); + if (invocation.getContext().containsKey(headKey)) { + // cse invoke scenario + next.setHeadValue(invocation.getContext().get(headKey)); + } else { + // not cse invoke scenario + next.setHeadValue(invocation.getRequestEx().getHeader(headKey)); + } } String operationName = invocation.getMicroserviceQualifiedName(); AbstractSpan span = ContextManager.createEntrySpan(operationName, contextCarrier);