Add size label for store metrics.

This commit is contained in:
Chuanyi Li
2018-08-13 21:03:30 +08:00
parent ec00792475
commit a3bf1d59e6
4 changed files with 13 additions and 8 deletions

View File

@@ -21,7 +21,6 @@ import java.util.concurrent.atomic.AtomicLong;
import static com.alibaba.otter.canal.prometheus.CanalInstanceExports.DEST;
import static com.alibaba.otter.canal.prometheus.CanalInstanceExports.DEST_LABELS_LIST;
import static java.util.concurrent.TimeUnit.NANOSECONDS;
/**
* @author Chuanyi Li

View File

@@ -40,7 +40,7 @@ public class StoreCollector extends Collector implements InstanceRegistry {
private static final String PRODUCE_MEM_HELP = "Produced mem bytes of canal instance";
private static final String CONSUME_MEM_HELP = "Consumed mem bytes of canal instance";
private final ConcurrentMap<String, StoreMetricsHolder> instances = new ConcurrentHashMap<String, StoreMetricsHolder>();
private final List<String> storeLabelsList = Arrays.asList(DEST, "batchMode");
private final List<String> storeLabelsList = Arrays.asList(DEST, "batchMode", "size");
private StoreCollector() {}
@@ -100,7 +100,8 @@ public class StoreCollector extends Collector implements InstanceRegistry {
holder.putSeq = memStore.getPutSequence();
holder.ackSeq = memStore.getAckSequence();
holder.destLabelValues = Collections.singletonList(destination);
holder.storeLabelValues = Arrays.asList(destination, memStore.getBatchMode().name());
holder.size = memStore.getBufferSize();
holder.storeLabelValues = Arrays.asList(destination, holder.batchMode.name(), Integer.toString(holder.size));
Preconditions.checkNotNull(holder.batchMode);
Preconditions.checkNotNull(holder.putSeq);
Preconditions.checkNotNull(holder.ackSeq);
@@ -128,6 +129,7 @@ public class StoreCollector extends Collector implements InstanceRegistry {
private BatchMode batchMode;
private AtomicLong putMemSize;
private AtomicLong ackMemSize;
private int size;
private List<String> destLabelValues;
private List<String> storeLabelValues;
}