Skip to content

Commit

Permalink
metrics(ticdc): Fix kafka compress ratio issue (#11313)
Browse files Browse the repository at this point in the history
close #11314
  • Loading branch information
sdojjy committed Jun 19, 2024
1 parent 4860903 commit dba5af5
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion metrics/grafana/ticdc.json
Original file line number Diff line number Diff line change
Expand Up @@ -7800,7 +7800,7 @@
},
"yaxes": [
{
"format": "none",
"format": "percent",
"label": null,
"logBase": 1,
"max": null,
Expand Down
2 changes: 1 addition & 1 deletion pkg/sink/codec/common/compress.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func Compress(changefeedID model.ChangeFeedID, cc string, data []byte) ([]byte,
}

newSize := len(compressed)
ratio := float64(oldSize) / float64(newSize)
ratio := float64(oldSize) / float64(newSize) * 100

compressionRatio.WithLabelValues(changefeedID.Namespace, changefeedID.ID).Observe(ratio)

Expand Down
4 changes: 2 additions & 2 deletions pkg/sink/kafka/metrics_collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,9 @@ func (m *saramaMetricsCollector) collectProducerMetrics() {
if histogram, ok := compressionRatioMetric.(metrics.Histogram); ok {
compressionRatioGauge.
WithLabelValues(namespace, changefeedID, "avg").
Set(histogram.Snapshot().Mean() / 100)
Set(histogram.Snapshot().Mean())
compressionRatioGauge.WithLabelValues(namespace, changefeedID, p99).
Set(histogram.Snapshot().Percentile(0.99) / 100)
Set(histogram.Snapshot().Percentile(0.99))
}

recordsPerRequestMetric := m.registry.Get(recordsPerRequestMetricName)
Expand Down

0 comments on commit dba5af5

Please sign in to comment.