Restore bootstrap.yml. Don't throw exception in reporting process.

pull/546/head
pandaapo 3 years ago
parent f0c6c2ef95
commit 500faa1e1a

@ -9,6 +9,6 @@ spring:
content: content:
label1: value1 label1: value1
polaris: polaris:
address: grpc://127.0.0.1:8091 address: grpc://183.47.111.80:8091
namespace: default namespace: default
enabled: true enabled: true

@ -9,6 +9,6 @@ spring:
content: content:
label1: value2 label1: value2
polaris: polaris:
address: grpc://127.0.0.1:8091 address: grpc://183.47.111.80:8091
namespace: default namespace: default
enabled: true enabled: true

@ -8,17 +8,12 @@ spring:
metadata: metadata:
content: content:
k1: v1 k1: v1
rpc-enhancement:
reporter:
series: client_error, server_error
polaris: polaris:
address: grpc://127.0.0.1:8091 address: grpc://183.47.111.80:8091
namespace: default namespace: default
enabled: true enabled: true
loadbalancer: loadbalancer:
enabled: true enabled: true
stat:
enabled: true
management: management:
endpoints: endpoints:
web: web:

@ -31,6 +31,8 @@ import com.tencent.polaris.api.utils.CollectionUtils;
import feign.Request; import feign.Request;
import feign.RequestTemplate; import feign.RequestTemplate;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import static com.tencent.cloud.common.constant.ContextConstant.UTF_8; import static com.tencent.cloud.common.constant.ContextConstant.UTF_8;
@ -41,6 +43,8 @@ import static com.tencent.cloud.common.constant.ContextConstant.UTF_8;
*/ */
public final class ReporterUtils { public final class ReporterUtils {
private static final Logger LOGGER = LoggerFactory.getLogger(ReporterUtils.class);
private ReporterUtils() { private ReporterUtils() {
} }
@ -57,10 +61,9 @@ public final class ReporterUtils {
label = URLDecoder.decode(label, UTF_8); label = URLDecoder.decode(label, UTF_8);
} }
catch (UnsupportedEncodingException e) { catch (UnsupportedEncodingException e) {
throw new RuntimeException("unsupported charset exception " + UTF_8); LOGGER.error("unsupported charset exception " + UTF_8, e);
} }
label = convertLabel(label); resultRequest.setLabels(convertLabel(label));
resultRequest.setLabels(label);
} }
resultRequest.setService(serviceName); resultRequest.setService(serviceName);
URI uri = URI.create(request.url()); URI uri = URI.create(request.url());

@ -83,7 +83,7 @@ public class ReporterUtilsTest {
RequestTemplate requestTemplate = new RequestTemplate(); RequestTemplate requestTemplate = new RequestTemplate();
requestTemplate.feignTarget(target); requestTemplate.feignTarget(target);
try { try {
requestTemplate.header(RouterConstants.ROUTER_LABEL_HEADER, URLEncoder.encode("k1:v1|k2:v2", UTF_8)); requestTemplate.header(RouterConstants.ROUTER_LABEL_HEADER, URLEncoder.encode("{\"k1\":\"v1\",\"k2\":\"v2\"}", UTF_8));
} }
catch (UnsupportedEncodingException e) { catch (UnsupportedEncodingException e) {
throw new RuntimeException("unsupported charset exception " + UTF_8); throw new RuntimeException("unsupported charset exception " + UTF_8);

Loading…
Cancel
Save