You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicecomb.apache.org by GitBox <gi...@apache.org> on 2021/08/26 01:24:26 UTC

[GitHub] [servicecomb-java-chassis] develpoerX commented on a change in pull request #2526: #SCB-2320 Add instanceId and serviceId in invocation header.

develpoerX commented on a change in pull request #2526:
URL: https://github.com/apache/servicecomb-java-chassis/pull/2526#discussion_r696218765



##########
File path: core/src/main/java/org/apache/servicecomb/core/invocation/InvocationFactory.java
##########
@@ -42,11 +45,27 @@ public static Invocation forConsumer(ReferenceConfig referenceConfig, OperationM
   }
 
   public static Invocation setSrcMicroservice(Invocation invocation) {
-    String microserviceName = RegistrationManager.INSTANCE.getMicroservice().getServiceName();
-    invocation.addContext(Const.SRC_MICROSERVICE, microserviceName);
+    Microservice microservice = RegistrationManager.INSTANCE.getMicroservice();
+    invocation.addContext(Const.SRC_MICROSERVICE, microservice.getServiceName());
+    if (isServiceId()) {
+      invocation.addContext(Const.SRC_SERVICE_ID, microservice.getServiceId());
+    }
+    if (isInstanceId()) {
+      invocation.addContext(Const.SRC_INSTANCE_ID, microservice.getInstance().getInstanceId());
+    }
     return invocation;
   }
 
+  public static boolean isServiceId() {
+    return DynamicPropertyFactory.getInstance().
+        getBooleanProperty("servicecomb.context.enabled.serviceId", true).get();
+  }
+
+  public static boolean isInstanceId() {

Review comment:
       done




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@servicecomb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org