diff --git a/observability/metrics.go b/observability/metrics.go index 7653edff..256d13d2 100644 --- a/observability/metrics.go +++ b/observability/metrics.go @@ -3,8 +3,9 @@ package observability import ( "sync" - "github.com/DoNewsCode/core/otgorm" "github.com/DoNewsCode/core/otkafka" + + "github.com/DoNewsCode/core/otgorm" "github.com/DoNewsCode/core/otredis" "github.com/go-kit/kit/metrics" "github.com/go-kit/kit/metrics/prometheus" @@ -143,7 +144,7 @@ func ProvideKafkaReaderMetrics() *otkafka.ReaderStats { Name: "kafka_reader_queue_capacity", Help: "", }, labels), - DialTime: otkafka.AggStats{ + DialTime: otkafka.ThreeStats{ Min: prometheus.NewGaugeFrom(stdprometheus.GaugeOpts{ Name: "kafka_reader_dial_seconds_min", Help: "", @@ -157,7 +158,7 @@ func ProvideKafkaReaderMetrics() *otkafka.ReaderStats { Help: "", }, labels), }, - ReadTime: otkafka.AggStats{ + ReadTime: otkafka.ThreeStats{ Min: prometheus.NewGaugeFrom(stdprometheus.GaugeOpts{ Name: "kafka_reader_read_seconds_min", Help: "", @@ -171,7 +172,7 @@ func ProvideKafkaReaderMetrics() *otkafka.ReaderStats { Help: "", }, labels), }, - WaitTime: otkafka.AggStats{ + WaitTime: otkafka.ThreeStats{ Min: prometheus.NewGaugeFrom(stdprometheus.GaugeOpts{ Name: "kafka_reader_wait_seconds_min", Help: "", @@ -185,7 +186,7 @@ func ProvideKafkaReaderMetrics() *otkafka.ReaderStats { Help: "", }, labels), }, - FetchSize: otkafka.AggStats{ + FetchSize: otkafka.ThreeStats{ Min: prometheus.NewGaugeFrom(stdprometheus.GaugeOpts{ Name: "kafka_reader_fetch_size_min", Help: "", @@ -199,7 +200,7 @@ func ProvideKafkaReaderMetrics() *otkafka.ReaderStats { Help: "", }, labels), }, - FetchBytes: otkafka.AggStats{ + FetchBytes: otkafka.ThreeStats{ Min: prometheus.NewGaugeFrom(stdprometheus.GaugeOpts{ Name: "kafka_reader_fetch_bytes_min", Help: "", @@ -265,7 +266,7 @@ func ProvideKafkaWriterMetrics() *otkafka.WriterStats { Name: "kafka_writer_async", Help: "", }, labels), - BatchTime: otkafka.AggStats{ + BatchTime: otkafka.ThreeStats{ Min: prometheus.NewGaugeFrom(stdprometheus.GaugeOpts{ Name: "kafka_writer_batch_seconds_min", Help: "", @@ -279,7 +280,7 @@ func ProvideKafkaWriterMetrics() *otkafka.WriterStats { Help: "", }, labels), }, - WriteTime: otkafka.AggStats{ + WriteTime: otkafka.ThreeStats{ Min: prometheus.NewGaugeFrom(stdprometheus.GaugeOpts{ Name: "kafka_writer_write_seconds_min", Help: "", @@ -293,7 +294,7 @@ func ProvideKafkaWriterMetrics() *otkafka.WriterStats { Help: "", }, labels), }, - WaitTime: otkafka.AggStats{ + WaitTime: otkafka.ThreeStats{ Min: prometheus.NewGaugeFrom(stdprometheus.GaugeOpts{ Name: "kafka_writer_wait_seconds_min", Help: "", @@ -307,7 +308,7 @@ func ProvideKafkaWriterMetrics() *otkafka.WriterStats { Help: "", }, labels), }, - Retries: otkafka.AggStats{ + Retries: otkafka.ThreeStats{ Min: prometheus.NewGaugeFrom(stdprometheus.GaugeOpts{ Name: "kafka_writer_retries_count_min", Help: "", @@ -321,7 +322,7 @@ func ProvideKafkaWriterMetrics() *otkafka.WriterStats { Help: "", }, labels), }, - BatchSize: otkafka.AggStats{ + BatchSize: otkafka.ThreeStats{ Min: prometheus.NewGaugeFrom(stdprometheus.GaugeOpts{ Name: "kafka_writer_batch_size_min", Help: "", @@ -335,7 +336,7 @@ func ProvideKafkaWriterMetrics() *otkafka.WriterStats { Help: "", }, labels), }, - BatchBytes: otkafka.AggStats{ + BatchBytes: otkafka.ThreeStats{ Min: prometheus.NewGaugeFrom(stdprometheus.GaugeOpts{ Name: "kafka_writer_batch_bytes_min", Help: "", diff --git a/otkafka/module_test.go b/otkafka/module_test.go index 59d93e7c..d1736ed5 100644 --- a/otkafka/module_test.go +++ b/otkafka/module_test.go @@ -63,27 +63,27 @@ func TestModule_ProvideRunGroup(t *testing.T) { MaxWait: m, QueueLength: m, QueueCapacity: m, - DialTime: AggStats{ + DialTime: ThreeStats{ Min: m, Max: m, Avg: m, }, - ReadTime: AggStats{ + ReadTime: ThreeStats{ Min: m, Max: m, Avg: m, }, - WaitTime: AggStats{ + WaitTime: ThreeStats{ Min: m, Max: m, Avg: m, }, - FetchSize: AggStats{ + FetchSize: ThreeStats{ Min: m, Max: m, Avg: m, }, - FetchBytes: AggStats{ + FetchBytes: ThreeStats{ Min: m, Max: m, Avg: m, @@ -103,32 +103,32 @@ func TestModule_ProvideRunGroup(t *testing.T) { WriteTimeout: m, RequiredAcks: m, Async: m, - BatchTime: AggStats{ + BatchTime: ThreeStats{ Min: m, Max: m, Avg: m, }, - WriteTime: AggStats{ + WriteTime: ThreeStats{ Min: m, Max: m, Avg: m, }, - WaitTime: AggStats{ + WaitTime: ThreeStats{ Min: m, Max: m, Avg: m, }, - Retries: AggStats{ + Retries: ThreeStats{ Min: m, Max: m, Avg: m, }, - BatchSize: AggStats{ + BatchSize: ThreeStats{ Min: m, Max: m, Avg: m, }, - BatchBytes: AggStats{ + BatchBytes: ThreeStats{ Min: m, Max: m, Avg: m, @@ -186,27 +186,27 @@ func TestCollector(t *testing.T) { MaxWait: m, QueueLength: m, QueueCapacity: m, - DialTime: AggStats{ + DialTime: ThreeStats{ Min: m, Max: m, Avg: m, }, - ReadTime: AggStats{ + ReadTime: ThreeStats{ Min: m, Max: m, Avg: m, }, - WaitTime: AggStats{ + WaitTime: ThreeStats{ Min: m, Max: m, Avg: m, }, - FetchSize: AggStats{ + FetchSize: ThreeStats{ Min: m, Max: m, Avg: m, }, - FetchBytes: AggStats{ + FetchBytes: ThreeStats{ Min: m, Max: m, Avg: m, @@ -226,32 +226,32 @@ func TestCollector(t *testing.T) { WriteTimeout: m, RequiredAcks: m, Async: m, - BatchTime: AggStats{ + BatchTime: ThreeStats{ Min: m, Max: m, Avg: m, }, - WriteTime: AggStats{ + WriteTime: ThreeStats{ Min: m, Max: m, Avg: m, }, - WaitTime: AggStats{ + WaitTime: ThreeStats{ Min: m, Max: m, Avg: m, }, - Retries: AggStats{ + Retries: ThreeStats{ Min: m, Max: m, Avg: m, }, - BatchSize: AggStats{ + BatchSize: ThreeStats{ Min: m, Max: m, Avg: m, }, - BatchBytes: AggStats{ + BatchBytes: ThreeStats{ Min: m, Max: m, Avg: m, diff --git a/otkafka/reader_metrics.go b/otkafka/reader_metrics.go index 43e50612..741452fd 100644 --- a/otkafka/reader_metrics.go +++ b/otkafka/reader_metrics.go @@ -13,8 +13,8 @@ type readerCollector struct { interval time.Duration } -// AggStats is a gauge group struct. -type AggStats struct { +// ThreeStats is a gauge group struct. +type ThreeStats struct { Min metrics.Gauge Max metrics.Gauge Avg metrics.Gauge @@ -38,11 +38,11 @@ type ReaderStats struct { QueueLength metrics.Gauge QueueCapacity metrics.Gauge - DialTime AggStats - ReadTime AggStats - WaitTime AggStats - FetchSize AggStats - FetchBytes AggStats + DialTime ThreeStats + ReadTime ThreeStats + WaitTime ThreeStats + FetchSize ThreeStats + FetchBytes ThreeStats } // newCollector creates a new kafka reader wrapper containing the name of the reader. diff --git a/otkafka/writer_metrics.go b/otkafka/writer_metrics.go index c737f0cf..a3548e7a 100644 --- a/otkafka/writer_metrics.go +++ b/otkafka/writer_metrics.go @@ -28,12 +28,12 @@ type WriterStats struct { RequiredAcks metrics.Gauge Async metrics.Gauge - BatchTime AggStats - WriteTime AggStats - WaitTime AggStats - Retries AggStats - BatchSize AggStats - BatchBytes AggStats + BatchTime ThreeStats + WriteTime ThreeStats + WaitTime ThreeStats + Retries ThreeStats + BatchSize ThreeStats + BatchBytes ThreeStats } // newCollector creates a new kafka writer wrapper containing the name of the reader.