From 3306ef56c89bb96c60fdc5e239668a8e3fc639dd Mon Sep 17 00:00:00 2001 From: Haotian Zhang <928016560@qq.com> Date: Tue, 11 Oct 2022 18:02:51 +0800 Subject: [PATCH] fix:cancel reporting useless metadata. (#639) * fix:cancel reporting useless metadata. * update CHANGELOG.md. --- CHANGELOG.md | 7 +++++-- .../cloud/common/metadata/StaticMetadataManager.java | 10 ++++++---- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 79c219cd1..a7a4ef8ff 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,10 +7,13 @@ - [Optimize: optimize configuration conditional & optimize config data tips](https://github.com/Tencent/spring-cloud-tencent/pull/603) - [Automatically transmit some headers specified by a environment varaible that directly defines header keys.](https://github.com/Tencent/spring-cloud-tencent/pull/606) - [Optimize: Maybe remove Chinese characters](https://github.com/Tencent/spring-cloud-tencent/pull/607) +- [Optimize: InstanceId of PolarisRegistration and PolarisServiceRegistry](https://github.com/Tencent/spring-cloud-tencent/pull/610) - [ fix pr #606 cause ci fail](https://github.com/Tencent/spring-cloud-tencent/pull/613) -- [Bugfix: fix feign report call result error when using feign direct call](https://github.com/Tencent/spring-cloud-tencent/pull/621) -- [fix pr 606: modify a part of changes requested by review.](https://github.com/Tencent/spring-cloud-tencent/pull/620) - [fix pr 613: modify a judgment logic](https://github.com/Tencent/spring-cloud-tencent/pull/618) +- [fix pr 606: modify a part of changes requested by review.](https://github.com/Tencent/spring-cloud-tencent/pull/620) +- [Bugfix: fix feign report call result error when using feign direct call](https://github.com/Tencent/spring-cloud-tencent/pull/621) +- [remove useless code for router](https://github.com/Tencent/spring-cloud-tencent/pull/626) - [Feature: support new label expression](https://github.com/Tencent/spring-cloud-tencent/pull/627) - [feat:report the labels when using RestTemplate.](https://github.com/Tencent/spring-cloud-tencent/pull/629) - [Bugfix: fix throw npe when router context is null](https://github.com/Tencent/spring-cloud-tencent/pull/635) +- [fix:cancel reporting useless metadata.](https://github.com/Tencent/spring-cloud-tencent/pull/639) diff --git a/spring-cloud-tencent-commons/src/main/java/com/tencent/cloud/common/metadata/StaticMetadataManager.java b/spring-cloud-tencent-commons/src/main/java/com/tencent/cloud/common/metadata/StaticMetadataManager.java index e71804ad3..9581d8ca5 100644 --- a/spring-cloud-tencent-commons/src/main/java/com/tencent/cloud/common/metadata/StaticMetadataManager.java +++ b/spring-cloud-tencent-commons/src/main/java/com/tencent/cloud/common/metadata/StaticMetadataManager.java @@ -13,7 +13,6 @@ * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR * CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. - * */ package com.tencent.cloud.common.metadata; @@ -35,7 +34,7 @@ import org.springframework.util.CollectionUtils; /** * manage metadata from env/config file/custom spi. * - * @author lepdou 2022-05-20 + * @author lepdou, Haotian Zhang */ public class StaticMetadataManager { /** @@ -67,6 +66,7 @@ public class StaticMetadataManager { private Map envMetadata; private Map envTransitiveMetadata; private Map envDisposableMetadata; + private Map envNotReportMetadata; private Map configMetadata; private Map configTransitiveMetadata; private Map configDisposableMetadata; @@ -100,6 +100,7 @@ public class StaticMetadataManager { Map allEnvs = System.getenv(); envMetadata = new HashMap<>(); + envNotReportMetadata = new HashMap<>(); // parse all metadata for (Map.Entry entry : allEnvs.entrySet()) { String key = entry.getKey(); @@ -110,11 +111,12 @@ public class StaticMetadataManager { String sourceKey = ""; if (key.equals(ENV_TRAFFIC_CONTENT_RAW_TRANSHEADERS)) { sourceKey = key; + envNotReportMetadata.put(sourceKey, value); } else { sourceKey = StringUtils.substring(key, ENV_METADATA_PREFIX_LENGTH); + envMetadata.put(sourceKey, value); } - envMetadata.put(sourceKey, value); LOGGER.info("[SCT] resolve metadata from env. key = {}, value = {}", sourceKey, value); } @@ -284,7 +286,7 @@ public class StaticMetadataManager { } public String getTransHeaderFromEnv() { - return envMetadata.get(ENV_TRAFFIC_CONTENT_RAW_TRANSHEADERS); + return envNotReportMetadata.get(ENV_TRAFFIC_CONTENT_RAW_TRANSHEADERS); } public Map getEnvTransitiveMetadata() {