Custom Metrics Monitor
Explanation#
Before custom development, please customize and build the gateway environment first, please refer to: custom deployment
This article describes how to customize the extension of
org.apache.shenyu.plugin.metrics.spi.MetricsService.
Extension#
- Create a new project and introduce the following dependencies:
<dependencies> <dependency> <groupId>org.apache.shenyu</groupId> <artifactId>shenyu-plugin-base</artifactId> <version>${project.version}</version> </dependency></dependencies>- Create a new class
${you class},implementsorg.apache.shenyu.plugin.metrics.spi.MetricsService
public class ${you class} implements MetricsService { /** * Start metrics tracker. * * @param metricsConfig metrics config * @param metricsRegister the metrics register */ public void start(MetricsConfig metricsConfig, MetricsRegister metricsRegister){ //your code } /** * Stop metrics tracker. */ public void stop() { //your code }}- In the project
resourcesdirectory,Create a newMETA-INF/shenyudirectory, and the new file name is :org.apache.shenyu.plugin.metrics.spi.MetricsService. add${you spi name}=${you class path}:
${you spi name} = ${you class path}Package the project and copy it to the
liborext-libdirectory of the gateway (bootstrap-bin).In the
Adminservice ---> BasicConfig ---> Plugin , Find theMonitorplugin, edit config, pay attention to themetricsNamename:${you spi name}.
