Skip to content

Commit

Permalink
fix: rename ThreeStats to AggStats (#184)
Browse files Browse the repository at this point in the history
  • Loading branch information
GGXXLL authored Aug 26, 2021
1 parent ba32e20 commit 4cccba0
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 48 deletions.
25 changes: 12 additions & 13 deletions observability/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@ package observability
import (
"sync"

"github.com/DoNewsCode/core/otkafka"

"github.com/DoNewsCode/core/otgorm"
"github.com/DoNewsCode/core/otkafka"
"github.com/DoNewsCode/core/otredis"
"github.com/go-kit/kit/metrics"
"github.com/go-kit/kit/metrics/prometheus"
Expand Down Expand Up @@ -144,7 +143,7 @@ func ProvideKafkaReaderMetrics() *otkafka.ReaderStats {
Name: "kafka_reader_queue_capacity",
Help: "",
}, labels),
DialTime: otkafka.ThreeStats{
DialTime: otkafka.AggStats{
Min: prometheus.NewGaugeFrom(stdprometheus.GaugeOpts{
Name: "kafka_reader_dial_seconds_min",
Help: "",
Expand All @@ -158,7 +157,7 @@ func ProvideKafkaReaderMetrics() *otkafka.ReaderStats {
Help: "",
}, labels),
},
ReadTime: otkafka.ThreeStats{
ReadTime: otkafka.AggStats{
Min: prometheus.NewGaugeFrom(stdprometheus.GaugeOpts{
Name: "kafka_reader_read_seconds_min",
Help: "",
Expand All @@ -172,7 +171,7 @@ func ProvideKafkaReaderMetrics() *otkafka.ReaderStats {
Help: "",
}, labels),
},
WaitTime: otkafka.ThreeStats{
WaitTime: otkafka.AggStats{
Min: prometheus.NewGaugeFrom(stdprometheus.GaugeOpts{
Name: "kafka_reader_wait_seconds_min",
Help: "",
Expand All @@ -186,7 +185,7 @@ func ProvideKafkaReaderMetrics() *otkafka.ReaderStats {
Help: "",
}, labels),
},
FetchSize: otkafka.ThreeStats{
FetchSize: otkafka.AggStats{
Min: prometheus.NewGaugeFrom(stdprometheus.GaugeOpts{
Name: "kafka_reader_fetch_size_min",
Help: "",
Expand All @@ -200,7 +199,7 @@ func ProvideKafkaReaderMetrics() *otkafka.ReaderStats {
Help: "",
}, labels),
},
FetchBytes: otkafka.ThreeStats{
FetchBytes: otkafka.AggStats{
Min: prometheus.NewGaugeFrom(stdprometheus.GaugeOpts{
Name: "kafka_reader_fetch_bytes_min",
Help: "",
Expand Down Expand Up @@ -266,7 +265,7 @@ func ProvideKafkaWriterMetrics() *otkafka.WriterStats {
Name: "kafka_writer_async",
Help: "",
}, labels),
BatchTime: otkafka.ThreeStats{
BatchTime: otkafka.AggStats{
Min: prometheus.NewGaugeFrom(stdprometheus.GaugeOpts{
Name: "kafka_writer_batch_seconds_min",
Help: "",
Expand All @@ -280,7 +279,7 @@ func ProvideKafkaWriterMetrics() *otkafka.WriterStats {
Help: "",
}, labels),
},
WriteTime: otkafka.ThreeStats{
WriteTime: otkafka.AggStats{
Min: prometheus.NewGaugeFrom(stdprometheus.GaugeOpts{
Name: "kafka_writer_write_seconds_min",
Help: "",
Expand All @@ -294,7 +293,7 @@ func ProvideKafkaWriterMetrics() *otkafka.WriterStats {
Help: "",
}, labels),
},
WaitTime: otkafka.ThreeStats{
WaitTime: otkafka.AggStats{
Min: prometheus.NewGaugeFrom(stdprometheus.GaugeOpts{
Name: "kafka_writer_wait_seconds_min",
Help: "",
Expand All @@ -308,7 +307,7 @@ func ProvideKafkaWriterMetrics() *otkafka.WriterStats {
Help: "",
}, labels),
},
Retries: otkafka.ThreeStats{
Retries: otkafka.AggStats{
Min: prometheus.NewGaugeFrom(stdprometheus.GaugeOpts{
Name: "kafka_writer_retries_count_min",
Help: "",
Expand All @@ -322,7 +321,7 @@ func ProvideKafkaWriterMetrics() *otkafka.WriterStats {
Help: "",
}, labels),
},
BatchSize: otkafka.ThreeStats{
BatchSize: otkafka.AggStats{
Min: prometheus.NewGaugeFrom(stdprometheus.GaugeOpts{
Name: "kafka_writer_batch_size_min",
Help: "",
Expand All @@ -336,7 +335,7 @@ func ProvideKafkaWriterMetrics() *otkafka.WriterStats {
Help: "",
}, labels),
},
BatchBytes: otkafka.ThreeStats{
BatchBytes: otkafka.AggStats{
Min: prometheus.NewGaugeFrom(stdprometheus.GaugeOpts{
Name: "kafka_writer_batch_bytes_min",
Help: "",
Expand Down
44 changes: 22 additions & 22 deletions otkafka/module_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,27 +63,27 @@ func TestModule_ProvideRunGroup(t *testing.T) {
MaxWait: m,
QueueLength: m,
QueueCapacity: m,
DialTime: ThreeStats{
DialTime: AggStats{
Min: m,
Max: m,
Avg: m,
},
ReadTime: ThreeStats{
ReadTime: AggStats{
Min: m,
Max: m,
Avg: m,
},
WaitTime: ThreeStats{
WaitTime: AggStats{
Min: m,
Max: m,
Avg: m,
},
FetchSize: ThreeStats{
FetchSize: AggStats{
Min: m,
Max: m,
Avg: m,
},
FetchBytes: ThreeStats{
FetchBytes: AggStats{
Min: m,
Max: m,
Avg: m,
Expand All @@ -103,32 +103,32 @@ func TestModule_ProvideRunGroup(t *testing.T) {
WriteTimeout: m,
RequiredAcks: m,
Async: m,
BatchTime: ThreeStats{
BatchTime: AggStats{
Min: m,
Max: m,
Avg: m,
},
WriteTime: ThreeStats{
WriteTime: AggStats{
Min: m,
Max: m,
Avg: m,
},
WaitTime: ThreeStats{
WaitTime: AggStats{
Min: m,
Max: m,
Avg: m,
},
Retries: ThreeStats{
Retries: AggStats{
Min: m,
Max: m,
Avg: m,
},
BatchSize: ThreeStats{
BatchSize: AggStats{
Min: m,
Max: m,
Avg: m,
},
BatchBytes: ThreeStats{
BatchBytes: AggStats{
Min: m,
Max: m,
Avg: m,
Expand Down Expand Up @@ -186,27 +186,27 @@ func TestCollector(t *testing.T) {
MaxWait: m,
QueueLength: m,
QueueCapacity: m,
DialTime: ThreeStats{
DialTime: AggStats{
Min: m,
Max: m,
Avg: m,
},
ReadTime: ThreeStats{
ReadTime: AggStats{
Min: m,
Max: m,
Avg: m,
},
WaitTime: ThreeStats{
WaitTime: AggStats{
Min: m,
Max: m,
Avg: m,
},
FetchSize: ThreeStats{
FetchSize: AggStats{
Min: m,
Max: m,
Avg: m,
},
FetchBytes: ThreeStats{
FetchBytes: AggStats{
Min: m,
Max: m,
Avg: m,
Expand All @@ -226,32 +226,32 @@ func TestCollector(t *testing.T) {
WriteTimeout: m,
RequiredAcks: m,
Async: m,
BatchTime: ThreeStats{
BatchTime: AggStats{
Min: m,
Max: m,
Avg: m,
},
WriteTime: ThreeStats{
WriteTime: AggStats{
Min: m,
Max: m,
Avg: m,
},
WaitTime: ThreeStats{
WaitTime: AggStats{
Min: m,
Max: m,
Avg: m,
},
Retries: ThreeStats{
Retries: AggStats{
Min: m,
Max: m,
Avg: m,
},
BatchSize: ThreeStats{
BatchSize: AggStats{
Min: m,
Max: m,
Avg: m,
},
BatchBytes: ThreeStats{
BatchBytes: AggStats{
Min: m,
Max: m,
Avg: m,
Expand Down
14 changes: 7 additions & 7 deletions otkafka/reader_metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ type readerCollector struct {
interval time.Duration
}

// ThreeStats is a gauge group struct.
type ThreeStats struct {
// AggStats is a gauge group struct.
type AggStats struct {
Min metrics.Gauge
Max metrics.Gauge
Avg metrics.Gauge
Expand All @@ -38,11 +38,11 @@ type ReaderStats struct {
QueueLength metrics.Gauge
QueueCapacity metrics.Gauge

DialTime ThreeStats
ReadTime ThreeStats
WaitTime ThreeStats
FetchSize ThreeStats
FetchBytes ThreeStats
DialTime AggStats
ReadTime AggStats
WaitTime AggStats
FetchSize AggStats
FetchBytes AggStats
}

// newCollector creates a new kafka reader wrapper containing the name of the reader.
Expand Down
12 changes: 6 additions & 6 deletions otkafka/writer_metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ type WriterStats struct {
RequiredAcks metrics.Gauge
Async metrics.Gauge

BatchTime ThreeStats
WriteTime ThreeStats
WaitTime ThreeStats
Retries ThreeStats
BatchSize ThreeStats
BatchBytes ThreeStats
BatchTime AggStats
WriteTime AggStats
WaitTime AggStats
Retries AggStats
BatchSize AggStats
BatchBytes AggStats
}

// newCollector creates a new kafka writer wrapper containing the name of the reader.
Expand Down

0 comments on commit 4cccba0

Please sign in to comment.