Skip to content

Commit

Permalink
format metrics name
Browse files Browse the repository at this point in the history
  • Loading branch information
poorbarcode committed Nov 10, 2022
1 parent 6f1fcf0 commit 55dc2c0
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -129,12 +129,12 @@ public void testTransactionMetaLogMetrics() throws Exception{
Assert.assertTrue(response.getStatus() / 200 == 1);
List<String> metricsLines = parseResponseEntityToList(response);

metricsLines = metricsLines.stream().filter(s -> s.contains("bufferedwriter")).collect(
metricsLines = metricsLines.stream().filter(s -> !s.startsWith("#") && s.contains("bufferedwriter")).collect(
Collectors.toList());

// verify tc.
String metrics_key_txn_tc_record_count_sum =
"pulsar_txn_tc_bufferedwriter_batch_record_sum{cluster=\"%s\",broker=\"%s\"} ";
"pulsar_txn_tc_bufferedwriter_batch_records_sum{cluster=\"%s\",broker=\"%s\"} ";
Assert.assertTrue(searchMetricsValue(metricsLines,
String.format(metrics_key_txn_tc_record_count_sum, metricsLabelCluster, metricsLabelBroker))
> 0);
Expand All @@ -150,7 +150,7 @@ public void testTransactionMetaLogMetrics() throws Exception{
> 0);
// verify pending ack.
String metrics_key_txn_pending_ack_record_count_sum =
"pulsar_txn_pending_ack_store_bufferedwriter_batch_record_sum{cluster=\"%s\",broker=\"%s\"} ";
"pulsar_txn_pending_ack_store_bufferedwriter_batch_records_sum{cluster=\"%s\",broker=\"%s\"} ";
Assert.assertTrue(searchMetricsValue(metricsLines,
String.format(metrics_key_txn_pending_ack_record_count_sum, metricsLabelCluster, metricsLabelBroker))
> 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import io.netty.util.concurrent.FastThreadLocal;
import java.io.Closeable;
import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public TxnLogBufferedWriterMetricsStats(String metricsPrefix, String[] labelName
this.labelValues = labelValues.clone();

String recordsPerBatchMetricName =
String.format("%s_bufferedwriter_batch_record", metricsPrefix);
String.format("%s_bufferedwriter_batch_records", metricsPrefix);
recordsPerBatchMetric = new Histogram.Builder()
.name(recordsPerBatchMetricName)
.labelNames(this.labelNames)
Expand All @@ -122,7 +122,7 @@ public TxnLogBufferedWriterMetricsStats(String metricsPrefix, String[] labelName
batchSizeBytesHistogram = batchSizeBytesMetric.labels(this.labelValues);

String oldestRecordInBatchDelayTimeSecondsMetricName =
String.format("%s_bufferedwriter_batch_oldest_record_delay_time_second", metricsPrefix);
String.format("%s_bufferedwriter_batch_oldest_record_delay_seconds", metricsPrefix);
oldestRecordInBatchDelayTimeSecondsMetric = new Histogram.Builder()
.name(oldestRecordInBatchDelayTimeSecondsMetricName)
.labelNames(this.labelNames)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -997,17 +997,17 @@ private void verifyTheCounterMetrics(int triggeredByRecordCount, int triggeredBy
private void verifyTheHistogramMetrics(int batchFlushCount, int totalRecordsCount, int totalSize){
// Total flush count.
assertEquals(
getHistogramCount(String.format("%s_bufferedwriter_batch_record", metricsPrefix)),
getHistogramCount(String.format("%s_bufferedwriter_batch_records", metricsPrefix)),
batchFlushCount);
assertEquals(
getHistogramCount(String.format("%s_bufferedwriter_batch_size_bytes", metricsPrefix)),
batchFlushCount);
assertEquals(
getHistogramCount(String.format("%s_bufferedwriter_batch_oldest_record_delay_time_second", metricsPrefix)),
getHistogramCount(String.format("%s_bufferedwriter_batch_oldest_record_delay_seconds", metricsPrefix)),
batchFlushCount);
// Total records count.
assertEquals(
getHistogramSum(String.format("%s_bufferedwriter_batch_record", metricsPrefix)),
getHistogramSum(String.format("%s_bufferedwriter_batch_records", metricsPrefix)),
totalRecordsCount);
// Total data size.
assertEquals(
Expand Down

0 comments on commit 55dc2c0

Please sign in to comment.