Add listener to write.
This commit is contained in:
+3
-3
@@ -21,9 +21,9 @@ import static com.alibaba.otter.canal.server.netty.CanalServerWithNettyProfiler.
|
||||
public class CanalInstanceExports {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(CanalInstanceExports.class);
|
||||
public static final String DESTINATION = "destination";
|
||||
public static final String[] DEST_LABELS = {DESTINATION};
|
||||
public static final List<String> DEST_LABEL_LIST = Collections.singletonList(DESTINATION);
|
||||
public static final String DEST = "destination";
|
||||
public static final String[] DEST_LABELS = {DEST};
|
||||
public static final List<String> DEST_LABEL_LIST = Collections.singletonList(DEST);
|
||||
private final String destination;
|
||||
private Collector storeCollector;
|
||||
private Collector delayCollector;
|
||||
|
||||
@@ -22,11 +22,8 @@ import static com.alibaba.otter.canal.server.netty.CanalServerWithNettyProfiler.
|
||||
public class PrometheusService implements CanalMetricsService {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(PrometheusService.class);
|
||||
|
||||
private final Map<String, CanalInstanceExports> exports = new ConcurrentHashMap<String, CanalInstanceExports>();
|
||||
|
||||
private volatile boolean running = false;
|
||||
|
||||
private HTTPServer server;
|
||||
|
||||
private PrometheusService() {
|
||||
@@ -69,8 +66,8 @@ public class PrometheusService implements CanalMetricsService {
|
||||
// Normally, service should be terminated at canal shutdown.
|
||||
// No need to unregister instance exports explicitly.
|
||||
// But for the sake of safety, unregister them.
|
||||
for (CanalInstanceExports ie : exports.values()) {
|
||||
ie.unregister();
|
||||
for (CanalInstanceExports cie : exports.values()) {
|
||||
cie.unregister();
|
||||
}
|
||||
profiler().setInstanceProfilerFactory(DISABLED);
|
||||
if (server != null) {
|
||||
|
||||
+2
-2
@@ -12,7 +12,7 @@ import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import static com.alibaba.otter.canal.prometheus.CanalInstanceExports.DESTINATION;
|
||||
import static com.alibaba.otter.canal.prometheus.CanalInstanceExports.DEST;
|
||||
import static com.alibaba.otter.canal.prometheus.CanalInstanceExports.DEST_LABEL_LIST;
|
||||
|
||||
/**
|
||||
@@ -45,7 +45,7 @@ public class MysqlParserCollector extends Collector {
|
||||
this.receivedBinlogBytesHelp = "Received binlog bytes of instance" + destination;
|
||||
this.isParallel = ((MysqlEventParser)parser).isParallel();
|
||||
this.modeHelp = "Parser mode of instance" + destination;
|
||||
this.modeLabels = Arrays.asList(DESTINATION, MODE_LABEL);
|
||||
this.modeLabels = Arrays.asList(DEST, MODE_LABEL);
|
||||
this.modeLabelValues = Arrays.asList(destination, isParallel.toString());
|
||||
}
|
||||
|
||||
|
||||
+3
-3
@@ -7,7 +7,7 @@ import io.prometheus.client.CollectorRegistry;
|
||||
import io.prometheus.client.Counter;
|
||||
import io.prometheus.client.Histogram;
|
||||
|
||||
import static com.alibaba.otter.canal.prometheus.CanalInstanceExports.DESTINATION;
|
||||
import static com.alibaba.otter.canal.prometheus.CanalInstanceExports.DEST;
|
||||
import static com.alibaba.otter.canal.prometheus.CanalInstanceExports.DEST_LABELS;
|
||||
|
||||
/**
|
||||
@@ -38,7 +38,7 @@ public class PrometheusClientInstanceProfiler implements ClientInstanceProfiler
|
||||
.help("Send bytes to client of instance " + destination)
|
||||
.create();
|
||||
this.packetsCounter = Counter.build()
|
||||
.labelNames(new String[]{DESTINATION, "packetType"})
|
||||
.labelNames(new String[]{DEST, "packetType"})
|
||||
.name(PACKET_TYPE)
|
||||
.help("Send packets to client of instance " + destination)
|
||||
.create();
|
||||
@@ -48,7 +48,7 @@ public class PrometheusClientInstanceProfiler implements ClientInstanceProfiler
|
||||
.help("Send empty batches to client of instance " + destination)
|
||||
.create();
|
||||
this.errorsCounter = Counter.build()
|
||||
.labelNames(new String[]{DESTINATION, "errorCode"})
|
||||
.labelNames(new String[]{DEST, "errorCode"})
|
||||
.name(ERRORS)
|
||||
.help("Client request errors of instance " + destination)
|
||||
.create();
|
||||
|
||||
Reference in New Issue
Block a user