fix:cancel reporting useless metadata. (#639)

* fix:cancel reporting useless metadata.

* update CHANGELOG.md.
pull/642/head
Haotian Zhang 2 years ago committed by GitHub
parent c472aa87ee
commit 3306ef56c8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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

@ -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<String, String> envMetadata;
private Map<String, String> envTransitiveMetadata;
private Map<String, String> envDisposableMetadata;
private Map<String, String> envNotReportMetadata;
private Map<String, String> configMetadata;
private Map<String, String> configTransitiveMetadata;
private Map<String, String> configDisposableMetadata;
@ -100,6 +100,7 @@ public class StaticMetadataManager {
Map<String, String> allEnvs = System.getenv();
envMetadata = new HashMap<>();
envNotReportMetadata = new HashMap<>();
// parse all metadata
for (Map.Entry<String, String> 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<String, String> getEnvTransitiveMetadata() {

Loading…
Cancel
Save