You can enable Microservices Governance of Microservices Engine (MSE) for applications by integrating custom tracking of SDKs for Java with Java agents. This way, you can perform operations on code blocks based on your business requirements. This topic describes how to configure custom tracking for an application.
Limits
Your MSE Java agent version must be 3.2.9 or later.
Only custom interfaces that generate traffic can be displayed in Microservices Governance due to the limitations of programming patterns.
For more information about agent versions, see Release notes for the Java agent. You can also specify a version by following the instructions in Specify the agent version.
Procedure
If Microservices Governance is enabled for your application, you can perform the following steps to add a custom interface:
Add the following dependency to the pom.xml file of the application:
<dependency> <groupId>com.alibaba.csp</groupId> <artifactId>sentinel-core</artifactId> <version>1.8.7</version> </dependency>Configure tracking. Use the following code to encapsulate your business logic:
import com.alibaba.csp.sentinel.Entry; import com.alibaba.csp.sentinel.SphU; import com.alibaba.csp.sentinel.slots.block.BlockException; import com.alibaba.csp.sentinel.EntryType; // HelloWorld is the name of the resource to be called. The resource is displayed on the monitoring page and in the interface list in the MSE console. // The rule is configured for the resource. // EntryType.IN indicates that the resource is an ingress resource. try (Entry entry = SphU.entry("HelloWorld", EntryType.IN)) { // The business logic is protected. System.out.println("Hello MSE Sentinel!"); } catch (BlockException e) { // Throttling and degradation are triggered. A throttling process, such as fallback or logging, is performed. }NoteEntryType specifies whether traffic on the resource is inbound traffic or outbound traffic. EntryType.IN indicates inbound traffic and EntryType.OUT indicates outbound traffic. System rules take effect only for ingress resources.
The total traffic amount of an application displayed in the MSE console includes only the traffic indicated by EntryType.IN.
The name of the resource for custom tracking cannot exceed 1,024 characters in length.
The recommended symbols that can be used in the names of resources for custom tracking are hyphens (
-), underscores (_), periods (.) or colons (:).
Verify the result
Log on to the MSE console. In the left-side navigation pane, choose Microservices Governance > Application Governance. If the resource card of the application appears on the Application list page and data is reported, Microservices Governance is enabled for the application.

If traffic is generated on the custom interface, you can view the custom interface on the Custom Interface tab of the interface details page.
References
For more information about how to perform traffic protection on custom interfaces, see Create a throttling rule, Create an isolation rule, and Create a circuit breaking rule.