kezhenxu94 commented on a change in pull request #3367: agent support custom properties. URL: https://github.com/apache/skywalking/pull/3367#discussion_r324718621
########## File path: oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/query/MetadataQueryEsDAO.java ########## @@ -249,26 +250,32 @@ public Service searchService(String serviceCode) throws IOException { String propertiesString = (String)sourceAsMap.get(ServiceInstanceInventory.PROPERTIES); if (!Strings.isNullOrEmpty(propertiesString)) { JsonObject properties = GSON.fromJson(propertiesString, JsonObject.class); - if (properties.has(LANGUAGE)) { - serviceInstance.setLanguage(LanguageTrans.INSTANCE.value(properties.get(LANGUAGE).getAsString())); - } else { - serviceInstance.setLanguage(Language.UNKNOWN); - } + for (Map.Entry<String, JsonElement> property : properties.entrySet()) { + String key = property.getKey(); + String value = property.getValue().getAsString(); + if (key.equals(LANGUAGE)) { + serviceInstance.setLanguage(LanguageTrans.INSTANCE.value(value)); + } else { + serviceInstance.setLanguage(Language.UNKNOWN); Review comment: Should not set the language to `Language.UNKNOWN` in the `else` branch **every time** when the `key` is not `LANGUAGE`, because you're in the `for` loop, e.g. `properties`: ``` LANGUAGE -> "Java" whatever1 -> "whatever1" whatever2 -> "whatever2" whatever3 -> "whatever3" ``` after the `for` loop, the `serviceInstance.getLanguage` is `Language.UNKNOWN`, while expectation is `Java` ---------------------------------------------------------------- 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. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services