feat:support stat reporting path aggregation. (#1609)

Co-authored-by: Haotian Zhang <skyebefreeman@qq.com>
pull/1614/head
Fishtail 3 months ago committed by GitHub
parent 3a728df6c8
commit 60187f46d7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -7,3 +7,4 @@
- [feat:support dynamic multi-discovery.](https://github.com/Tencent/spring-cloud-tencent/pull/1596)
- [feat:support ipv6.](https://github.com/Tencent/spring-cloud-tencent/pull/1601)
- [feat:support config all recover enabled.](https://github.com/Tencent/spring-cloud-tencent/pull/1605)
- [feat:support stat reporting path aggregation.](https://github.com/Tencent/spring-cloud-tencent/pull/1609)

@ -35,6 +35,7 @@ import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
@ -214,4 +215,14 @@ public class QuickstartCallerController {
public String healthCheck() {
return "ok";
}
/**
* health check.
* @return health check info
*/
@GetMapping("/test/{num}")
public String test1(@PathVariable int num) {
String path = "http://QuickstartCalleeService/quickstart/callee/test/" + num + "/echo";
return restTemplate.getForObject(path, String.class);
}
}

@ -28,6 +28,8 @@ spring:
port: 28082
stat:
enabled: true
path-regex-list:
- /quickstart/callee/test/(.+)/echo
# pushgateway:
# enabled: true
# address: 127.0.0.1:9091

@ -17,6 +17,9 @@
package com.tencent.cloud.rpc.enhancement.stat.config;
import java.util.ArrayList;
import java.util.List;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties;
@ -75,6 +78,11 @@ public class PolarisStatProperties {
@Value("${spring.cloud.polaris.stat.pushgateway.open-gzip:#{false}}")
private Boolean openGzip = false;
/**
* The path regex list for stat for aggregation.
*/
private List<String> pathRegexList = new ArrayList<>();
public boolean isEnabled() {
return enabled;
}
@ -139,6 +147,14 @@ public class PolarisStatProperties {
this.openGzip = openGzip;
}
public List<String> getPathRegexList() {
return pathRegexList;
}
public void setPathRegexList(List<String> pathRegexList) {
this.pathRegexList = pathRegexList;
}
@Override
public String toString() {
return "PolarisStatProperties{" +
@ -150,6 +166,7 @@ public class PolarisStatProperties {
", statService='" + statService + '\'' +
", pushGatewayPushInterval=" + pushGatewayPushInterval +
", openGzip=" + openGzip +
", pathRegexList=" + pathRegexList +
'}';
}
}

@ -45,6 +45,7 @@ public class StatConfigModifier implements PolarisConfigModifier {
StatReporterConfigImpl statReporterConfig = configuration.getGlobal().getStatReporter();
statReporterConfig.setEnable(polarisStatProperties.isEnabled());
PrometheusHandlerConfig prometheusHandlerConfig = statReporterConfig.getPluginConfig(DEFAULT_REPORTER_PROMETHEUS, PrometheusHandlerConfig.class);
prometheusHandlerConfig.setPathRegexList(polarisStatProperties.getPathRegexList());
// Set prometheus plugin.
if (polarisStatProperties.isEnabled()) {
if (polarisStatProperties.isPushGatewayEnabled()) {

Loading…
Cancel
Save