Source:
<code>public BinlogConnectorReplicator( SchemaStore schemaStore, AbstractProducer producer, AbstractBootstrapper bootstrapper, MaxwellMysqlConfig mysqlConfig, Long replicaServerID, String maxwellSchemaDatabaseName, Metrics metrics, Position start, boolean stopOnEOF, String clientID ) { super(clientID, bootstrapper, maxwellSchemaDatabaseName, producer, metrics, start); this.schemaStore = schemaStore; this.client = new BinaryLogClient(mysqlConfig.host, mysqlConfig.port, mysqlConfig.user, mysqlConfig.password); BinlogPosition startBinlog = start.getBinlogPosition(); if (startBinlog.getGtidSetStr() != null) { String gtidStr = startBinlog.getGtidSetStr(); LOGGER.info("Setting initial gtid to: " + gtidStr); this.client.setGtidSet(gtidStr); } else { LOGGER.info("Setting initial binlog pos to: " + startBinlog.getFile() + ":" + startBinlog.getOffset()); this.client.setBinlogFilename(startBinlog.getFile()); this.client.setBinlogPosition(startBinlog.getOffset()); } EventDeserializer eventDeserializer = new EventDeserializer(); eventDeserializer.setCompatibilityMode(EventDeserializer.CompatibilityMode.DATE_AND_TIME_AS_LONG_MICRO, EventDeserializer.CompatibilityMode.CHAR_AND_BINARY_AS_BYTE_ARRAY); this.client.setEventDeserializer(eventDeserializer); Timer replicationQueueTimer = metrics.getRegistry().timer(metrics.metricName("replication", "queue", "time")); this.binlogEventListener = new BinlogConnectorEventListener(client, queue, replicationQueueTimer); this.client.setBlocking(!stopOnEOF); this.client.registerEventListener(binlogEventListener); this.client.setServerId(replicaServerID.intValue()); this.stopOnEOF = stopOnEOF; metrics.getRegistry().register( metrics.metricName("replication", "queue", "count"), new Gauge<Long>() { @Override public Long getValue() { <START> return (long) queue.size(); <END> } } ); }</code><technical_language>queue is blocked queue capacity of 20, feeling this metrics give value. ~Can instrument blocking time?~ Ah I blocking time is instrumented in replicationQueueTimer. This metrics reveal if db is quiet not</technical_language>

Target:
public BinlogConnectorReplicator( SchemaStore schemaStore, AbstractProducer producer, AbstractBootstrapper bootstrapper, MaxwellMysqlConfig mysqlConfig, Long replicaServerID, String maxwellSchemaDatabaseName, Metrics metrics, Position start, boolean stopOnEOF, String clientID ) { super(clientID, bootstrapper, maxwellSchemaDatabaseName, producer, metrics, start); this.schemaStore = schemaStore; this.client = new BinaryLogClient(mysqlConfig.host, mysqlConfig.port, mysqlConfig.user, mysqlConfig.password); BinlogPosition startBinlog = start.getBinlogPosition(); if (startBinlog.getGtidSetStr() != null) { String gtidStr = startBinlog.getGtidSetStr(); LOGGER.info("Setting initial gtid to: " + gtidStr); this.client.setGtidSet(gtidStr); } else { LOGGER.info("Setting initial binlog pos to: " + startBinlog.getFile() + ":" + startBinlog.getOffset()); this.client.setBinlogFilename(startBinlog.getFile()); this.client.setBinlogPosition(startBinlog.getOffset()); } EventDeserializer eventDeserializer = new EventDeserializer(); eventDeserializer.setCompatibilityMode(EventDeserializer.CompatibilityMode.DATE_AND_TIME_AS_LONG_MICRO, EventDeserializer.CompatibilityMode.CHAR_AND_BINARY_AS_BYTE_ARRAY); this.client.setEventDeserializer(eventDeserializer); Timer replicationQueueTimer = metrics.getRegistry().timer(metrics.metricName("replication", "queue", "time")); this.binlogEventListener = new BinlogConnectorEventListener(client, queue, replicationQueueTimer); this.client.setBlocking(!stopOnEOF); this.client.registerEventListener(binlogEventListener); this.client.setServerId(replicaServerID.intValue()); this.stopOnEOF = stopOnEOF; }