pom.xml in the application's root directory to add dependencyManagement for polaris-java:<dependencyManagement><dependencies><dependency><groupId>com.tencent.polaris</groupId><artifactId>polaris-dependencies</artifactId><version>${version}</version><type>pom</type><scope>import</scope></dependency></dependencies></dependencyManagement>
<dependencies><dependency><groupId>com.tencent.polaris</groupId><artifactId>polaris-all</artifactId></dependency></dependencies>
global:serverConnectors:- id: polarisprotocol: grpcaddresses:# The IP address needs to be replaced with the client access IP address of the North Star engine you created.- 127.0.0.1:8091# Description: Configuration related to monitoring and log data reportingstatReporter:# Description: Whether to Enable Reportingenable: trueplugin:prometheus:type: push# Description: Configure the pushgateway IP address, effective only when type == push# The IP address needs to be replaced with the client access IP address of the North Star engine you created.address: 127.0.0.1:9091# Description: Set the execution interval for pushing metric data to pushgateway# Range: [1s:...], Default value: 10spushInterval: 10s
import com.tencent.polaris.factory.api.DiscoveryAPIFactory;public static void main(String[] args) throws Exception {ConsumerAPI consumerAPI = DiscoveryAPIFactory.createConsumerAPI();}
public enum RetStatus {// Service invocation successfulRetSuccess,// Service invocation failedRetFail,// Service invocation timeoutRetTimeout,}ServiceCallResult result = new ServiceCallResult();// Set the callee service namespaceresult.setNamespace(String namespace);// Set the callee service informationresult.setService(String service);// Set callee instanceresult.setInstance(Instance instance);// Set the response code for this requestresult.setRetCode(String code);// Set the latency for this requestresult.setDelay(String delay);// Set the result status of this requestresult.setRetStatus(RetStatus status);// Set the request Tag for this request, format is key=value;key=value;result.setLabels(String labels);// Set the method to invoke for this requestresult.setMethod(String method);
ConsumerAPI.updateServiceCallResult method to report the request invocation results. The SDK internally converts the reported invocation result information into corresponding traffic invocation metric data and reports it to prometheus.consumerAPI.updateServiceCallResult(ServiceCallResult)
Was this page helpful?
You can also Contact sales or Submit a Ticket for help.
Help us improve! Rate your documentation experience in 5 mins.
Feedback