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/25 01:33:08 UTC

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

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



##########
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();

Review comment:
       How about `servicecomb.context.source.serviceId`, `servicecomb.context.source.instanceId`,  `servicecomb.context.source.serviceName` ? 
   




-- 
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