mirror of https://github.com/tikv/client-java.git
use defaultexportor (#332)
Signed-off-by: birdstorm <samuelwyf@hotmail.com>
This commit is contained in:
parent
b60afd0b97
commit
1e74211269
|
|
@ -14,15 +14,10 @@
|
|||
*/
|
||||
package org.tikv.common;
|
||||
|
||||
import io.prometheus.client.CollectorRegistry;
|
||||
import io.prometheus.client.exporter.HTTPServer;
|
||||
import java.net.InetSocketAddress;
|
||||
import io.prometheus.client.hotspot.DefaultExports;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.tikv.common.policy.RetryPolicy;
|
||||
import org.tikv.common.region.RegionManager;
|
||||
import org.tikv.common.region.RegionStoreClient;
|
||||
import org.tikv.raw.RawKVClient;
|
||||
|
||||
public class MetricsServer {
|
||||
private static final Logger logger = LoggerFactory.getLogger(MetricsServer.class);
|
||||
|
|
@ -32,7 +27,6 @@ public class MetricsServer {
|
|||
|
||||
private int port;
|
||||
private HTTPServer server;
|
||||
private CollectorRegistry collectorRegistry;
|
||||
|
||||
public static MetricsServer getInstance(TiConfiguration conf) {
|
||||
if (!conf.isMetricsEnable()) {
|
||||
|
|
@ -58,16 +52,9 @@ public class MetricsServer {
|
|||
|
||||
private MetricsServer(int port) {
|
||||
try {
|
||||
this.collectorRegistry = new CollectorRegistry();
|
||||
this.collectorRegistry.register(RawKVClient.RAW_REQUEST_LATENCY);
|
||||
this.collectorRegistry.register(RawKVClient.RAW_REQUEST_FAILURE);
|
||||
this.collectorRegistry.register(RawKVClient.RAW_REQUEST_SUCCESS);
|
||||
this.collectorRegistry.register(RegionStoreClient.GRPC_RAW_REQUEST_LATENCY);
|
||||
this.collectorRegistry.register(RetryPolicy.GRPC_SINGLE_REQUEST_LATENCY);
|
||||
this.collectorRegistry.register(RegionManager.GET_REGION_BY_KEY_REQUEST_LATENCY);
|
||||
this.collectorRegistry.register(PDClient.PD_GET_REGION_BY_KEY_REQUEST_LATENCY);
|
||||
this.port = port;
|
||||
this.server = new HTTPServer(new InetSocketAddress(port), this.collectorRegistry, true);
|
||||
DefaultExports.initialize();
|
||||
this.server = new HTTPServer(port, true);
|
||||
logger.info("http server is up " + this.server.getPort());
|
||||
} catch (Exception e) {
|
||||
logger.error("http server not up");
|
||||
|
|
|
|||
Loading…
Reference in New Issue