diff --git a/examples/activehealthcheck/go.mod b/examples/activehealthcheck/go.mod index eafc2190..f91af8ec 100644 --- a/examples/activehealthcheck/go.mod +++ b/examples/activehealthcheck/go.mod @@ -17,7 +17,7 @@ require ( github.com/modern-go/reflect2 v1.0.2 // indirect github.com/natefinch/lumberjack v2.0.0+incompatible // indirect github.com/pkg/errors v0.9.1 // indirect - github.com/polarismesh/specification v1.3.2-alpha.2 // indirect + github.com/polarismesh/specification v1.4.1 // indirect github.com/prometheus/client_golang v1.12.2 // indirect github.com/prometheus/client_model v0.2.0 // indirect github.com/prometheus/common v0.32.1 // indirect diff --git a/examples/activehealthcheck/go.sum b/examples/activehealthcheck/go.sum index 093a5191..48997cc2 100644 --- a/examples/activehealthcheck/go.sum +++ b/examples/activehealthcheck/go.sum @@ -377,6 +377,7 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/polarismesh/specification v1.3.2-alpha.2 h1:cMghyvCnRVM5ca2kYCGHOgIIxVnokiMvw0720q8a8RA= github.com/polarismesh/specification v1.3.2-alpha.2/go.mod h1:rDvMMtl5qebPmqiBLNa5Ps0XtwkP31ZLirbH4kXA0YU= +github.com/polarismesh/specification v1.4.1/go.mod h1:rDvMMtl5qebPmqiBLNa5Ps0XtwkP31ZLirbH4kXA0YU= github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo= github.com/prometheus/client_golang v1.7.1/go.mod h1:PY5Wy2awLA44sXw4AOSfFBetzPP4j5+D6mVACh+pe2M= diff --git a/examples/configuration/encrypt/go.mod b/examples/configuration/encrypt/go.mod index 6c3d513f..1f119279 100644 --- a/examples/configuration/encrypt/go.mod +++ b/examples/configuration/encrypt/go.mod @@ -17,7 +17,7 @@ require ( github.com/modern-go/reflect2 v1.0.2 // indirect github.com/natefinch/lumberjack v2.0.0+incompatible // indirect github.com/pkg/errors v0.9.1 // indirect - github.com/polarismesh/specification v1.4.0 // indirect + github.com/polarismesh/specification v1.4.1 // indirect github.com/prometheus/client_golang v1.12.2 // indirect github.com/prometheus/client_model v0.2.0 // indirect github.com/prometheus/common v0.32.1 // indirect diff --git a/examples/configuration/encrypt/go.sum b/examples/configuration/encrypt/go.sum index 41c830a6..2a18abaf 100644 --- a/examples/configuration/encrypt/go.sum +++ b/examples/configuration/encrypt/go.sum @@ -377,6 +377,7 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/polarismesh/specification v1.4.0 h1:fm7sUtFZC2g9+lLmRCtjGrUow47CY5JDFoZXwwCQGGY= github.com/polarismesh/specification v1.4.0/go.mod h1:rDvMMtl5qebPmqiBLNa5Ps0XtwkP31ZLirbH4kXA0YU= +github.com/polarismesh/specification v1.4.1/go.mod h1:rDvMMtl5qebPmqiBLNa5Ps0XtwkP31ZLirbH4kXA0YU= github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo= github.com/prometheus/client_golang v1.7.1/go.mod h1:PY5Wy2awLA44sXw4AOSfFBetzPP4j5+D6mVACh+pe2M= diff --git a/examples/quickstart/consumer/main.go b/examples/quickstart/consumer/main.go index 25ab8782..03c1aee3 100644 --- a/examples/quickstart/consumer/main.go +++ b/examples/quickstart/consumer/main.go @@ -92,7 +92,7 @@ func (svr *PolarisConsumer) runWebServer() { }, } ret.SetDelay(delay) - ret.SetRetCode(int32(resp.StatusCode)) + ret.SetRetCode(int32(http.StatusInternalServerError)) if err := svr.consumer.UpdateServiceCallResult(ret); err != nil { log.Printf("do report service call result : %+v", err) } diff --git a/examples/ratelimit/consumer/go.mod b/examples/ratelimit/consumer/go.mod index 9d750d88..681f4aa5 100644 --- a/examples/ratelimit/consumer/go.mod +++ b/examples/ratelimit/consumer/go.mod @@ -17,7 +17,7 @@ require ( github.com/modern-go/reflect2 v1.0.2 // indirect github.com/natefinch/lumberjack v2.0.0+incompatible // indirect github.com/pkg/errors v0.9.1 // indirect - github.com/polarismesh/specification v1.3.2-alpha.2 // indirect + github.com/polarismesh/specification v1.4.1 // indirect github.com/prometheus/client_golang v1.12.2 // indirect github.com/prometheus/client_model v0.2.0 // indirect github.com/prometheus/common v0.32.1 // indirect diff --git a/examples/ratelimit/consumer/go.sum b/examples/ratelimit/consumer/go.sum index 093a5191..48997cc2 100644 --- a/examples/ratelimit/consumer/go.sum +++ b/examples/ratelimit/consumer/go.sum @@ -377,6 +377,7 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/polarismesh/specification v1.3.2-alpha.2 h1:cMghyvCnRVM5ca2kYCGHOgIIxVnokiMvw0720q8a8RA= github.com/polarismesh/specification v1.3.2-alpha.2/go.mod h1:rDvMMtl5qebPmqiBLNa5Ps0XtwkP31ZLirbH4kXA0YU= +github.com/polarismesh/specification v1.4.1/go.mod h1:rDvMMtl5qebPmqiBLNa5Ps0XtwkP31ZLirbH4kXA0YU= github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo= github.com/prometheus/client_golang v1.7.1/go.mod h1:PY5Wy2awLA44sXw4AOSfFBetzPP4j5+D6mVACh+pe2M= diff --git a/examples/ratelimit/consumer/main.go b/examples/ratelimit/consumer/main.go index 107fc93a..ceb470b9 100644 --- a/examples/ratelimit/consumer/main.go +++ b/examples/ratelimit/consumer/main.go @@ -91,6 +91,7 @@ func (svr *PolarisConsumer) runWebServer() { RetStatus: model.RetFail, }, } + ret.SetRetCode(int32(http.StatusInternalServerError)) ret.SetDelay(delay) if err := svr.consumer.UpdateServiceCallResult(ret); err != nil { log.Printf("do report service call result : %+v", err) diff --git a/examples/ratelimit/provider/go.mod b/examples/ratelimit/provider/go.mod index 7956582c..ae31e1f1 100644 --- a/examples/ratelimit/provider/go.mod +++ b/examples/ratelimit/provider/go.mod @@ -17,7 +17,7 @@ require ( github.com/modern-go/reflect2 v1.0.2 // indirect github.com/natefinch/lumberjack v2.0.0+incompatible // indirect github.com/pkg/errors v0.9.1 // indirect - github.com/polarismesh/specification v1.3.2-alpha.2 // indirect + github.com/polarismesh/specification v1.4.1 // indirect github.com/prometheus/client_golang v1.12.2 // indirect github.com/prometheus/client_model v0.2.0 // indirect github.com/prometheus/common v0.32.1 // indirect diff --git a/examples/ratelimit/provider/go.sum b/examples/ratelimit/provider/go.sum index 093a5191..48997cc2 100644 --- a/examples/ratelimit/provider/go.sum +++ b/examples/ratelimit/provider/go.sum @@ -377,6 +377,7 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/polarismesh/specification v1.3.2-alpha.2 h1:cMghyvCnRVM5ca2kYCGHOgIIxVnokiMvw0720q8a8RA= github.com/polarismesh/specification v1.3.2-alpha.2/go.mod h1:rDvMMtl5qebPmqiBLNa5Ps0XtwkP31ZLirbH4kXA0YU= +github.com/polarismesh/specification v1.4.1/go.mod h1:rDvMMtl5qebPmqiBLNa5Ps0XtwkP31ZLirbH4kXA0YU= github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo= github.com/prometheus/client_golang v1.7.1/go.mod h1:PY5Wy2awLA44sXw4AOSfFBetzPP4j5+D6mVACh+pe2M= diff --git a/examples/route/dynamic/consumer/go.mod b/examples/route/dynamic/consumer/go.mod index 24797423..cf4bca32 100644 --- a/examples/route/dynamic/consumer/go.mod +++ b/examples/route/dynamic/consumer/go.mod @@ -17,7 +17,7 @@ require ( github.com/modern-go/reflect2 v1.0.2 // indirect github.com/natefinch/lumberjack v2.0.0+incompatible // indirect github.com/pkg/errors v0.9.1 // indirect - github.com/polarismesh/specification v1.3.2-alpha.2 // indirect + github.com/polarismesh/specification v1.4.1 // indirect github.com/prometheus/client_golang v1.12.2 // indirect github.com/prometheus/client_model v0.2.0 // indirect github.com/prometheus/common v0.32.1 // indirect diff --git a/examples/route/dynamic/consumer/go.sum b/examples/route/dynamic/consumer/go.sum index 093a5191..48997cc2 100644 --- a/examples/route/dynamic/consumer/go.sum +++ b/examples/route/dynamic/consumer/go.sum @@ -377,6 +377,7 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/polarismesh/specification v1.3.2-alpha.2 h1:cMghyvCnRVM5ca2kYCGHOgIIxVnokiMvw0720q8a8RA= github.com/polarismesh/specification v1.3.2-alpha.2/go.mod h1:rDvMMtl5qebPmqiBLNa5Ps0XtwkP31ZLirbH4kXA0YU= +github.com/polarismesh/specification v1.4.1/go.mod h1:rDvMMtl5qebPmqiBLNa5Ps0XtwkP31ZLirbH4kXA0YU= github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo= github.com/prometheus/client_golang v1.7.1/go.mod h1:PY5Wy2awLA44sXw4AOSfFBetzPP4j5+D6mVACh+pe2M= diff --git a/examples/route/dynamic/provider/go.mod b/examples/route/dynamic/provider/go.mod index 61721201..afb785c0 100644 --- a/examples/route/dynamic/provider/go.mod +++ b/examples/route/dynamic/provider/go.mod @@ -17,7 +17,7 @@ require ( github.com/modern-go/reflect2 v1.0.2 // indirect github.com/natefinch/lumberjack v2.0.0+incompatible // indirect github.com/pkg/errors v0.9.1 // indirect - github.com/polarismesh/specification v1.3.2-alpha.2 // indirect + github.com/polarismesh/specification v1.4.1 // indirect github.com/prometheus/client_golang v1.12.2 // indirect github.com/prometheus/client_model v0.2.0 // indirect github.com/prometheus/common v0.32.1 // indirect diff --git a/examples/route/dynamic/provider/go.sum b/examples/route/dynamic/provider/go.sum index 093a5191..48997cc2 100644 --- a/examples/route/dynamic/provider/go.sum +++ b/examples/route/dynamic/provider/go.sum @@ -377,6 +377,7 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/polarismesh/specification v1.3.2-alpha.2 h1:cMghyvCnRVM5ca2kYCGHOgIIxVnokiMvw0720q8a8RA= github.com/polarismesh/specification v1.3.2-alpha.2/go.mod h1:rDvMMtl5qebPmqiBLNa5Ps0XtwkP31ZLirbH4kXA0YU= +github.com/polarismesh/specification v1.4.1/go.mod h1:rDvMMtl5qebPmqiBLNa5Ps0XtwkP31ZLirbH4kXA0YU= github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo= github.com/prometheus/client_golang v1.7.1/go.mod h1:PY5Wy2awLA44sXw4AOSfFBetzPP4j5+D6mVACh+pe2M= diff --git a/examples/route/nearby/consumer/go.mod b/examples/route/nearby/consumer/go.mod index c4ae5266..a1d24e1d 100644 --- a/examples/route/nearby/consumer/go.mod +++ b/examples/route/nearby/consumer/go.mod @@ -19,7 +19,7 @@ require ( github.com/modern-go/reflect2 v1.0.2 // indirect github.com/natefinch/lumberjack v2.0.0+incompatible // indirect github.com/pkg/errors v0.9.1 // indirect - github.com/polarismesh/specification v1.3.2-alpha.2 // indirect + github.com/polarismesh/specification v1.4.1 // indirect github.com/prometheus/client_golang v1.12.2 // indirect github.com/prometheus/client_model v0.2.0 // indirect github.com/prometheus/common v0.32.1 // indirect diff --git a/examples/route/nearby/consumer/go.sum b/examples/route/nearby/consumer/go.sum index 093a5191..48997cc2 100644 --- a/examples/route/nearby/consumer/go.sum +++ b/examples/route/nearby/consumer/go.sum @@ -377,6 +377,7 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/polarismesh/specification v1.3.2-alpha.2 h1:cMghyvCnRVM5ca2kYCGHOgIIxVnokiMvw0720q8a8RA= github.com/polarismesh/specification v1.3.2-alpha.2/go.mod h1:rDvMMtl5qebPmqiBLNa5Ps0XtwkP31ZLirbH4kXA0YU= +github.com/polarismesh/specification v1.4.1/go.mod h1:rDvMMtl5qebPmqiBLNa5Ps0XtwkP31ZLirbH4kXA0YU= github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo= github.com/prometheus/client_golang v1.7.1/go.mod h1:PY5Wy2awLA44sXw4AOSfFBetzPP4j5+D6mVACh+pe2M= diff --git a/examples/route/nearby/provider/go.mod b/examples/route/nearby/provider/go.mod index 10d1ee58..83408ebb 100644 --- a/examples/route/nearby/provider/go.mod +++ b/examples/route/nearby/provider/go.mod @@ -17,7 +17,7 @@ require ( github.com/modern-go/reflect2 v1.0.2 // indirect github.com/natefinch/lumberjack v2.0.0+incompatible // indirect github.com/pkg/errors v0.9.1 // indirect - github.com/polarismesh/specification v1.4.0 // indirect + github.com/polarismesh/specification v1.4.1 // indirect github.com/prometheus/client_golang v1.12.2 // indirect github.com/prometheus/client_model v0.2.0 // indirect github.com/prometheus/common v0.32.1 // indirect diff --git a/examples/route/nearby/provider/go.sum b/examples/route/nearby/provider/go.sum index 41c830a6..2a18abaf 100644 --- a/examples/route/nearby/provider/go.sum +++ b/examples/route/nearby/provider/go.sum @@ -377,6 +377,7 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/polarismesh/specification v1.4.0 h1:fm7sUtFZC2g9+lLmRCtjGrUow47CY5JDFoZXwwCQGGY= github.com/polarismesh/specification v1.4.0/go.mod h1:rDvMMtl5qebPmqiBLNa5Ps0XtwkP31ZLirbH4kXA0YU= +github.com/polarismesh/specification v1.4.1/go.mod h1:rDvMMtl5qebPmqiBLNa5Ps0XtwkP31ZLirbH4kXA0YU= github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo= github.com/prometheus/client_golang v1.7.1/go.mod h1:PY5Wy2awLA44sXw4AOSfFBetzPP4j5+D6mVACh+pe2M= diff --git a/examples/watchinstance/go.mod b/examples/watchinstance/go.mod index f25e40d8..db10fd28 100644 --- a/examples/watchinstance/go.mod +++ b/examples/watchinstance/go.mod @@ -19,7 +19,7 @@ require ( github.com/modern-go/reflect2 v1.0.2 // indirect github.com/natefinch/lumberjack v2.0.0+incompatible // indirect github.com/pkg/errors v0.9.1 // indirect - github.com/polarismesh/specification v1.3.2-alpha.2 // indirect + github.com/polarismesh/specification v1.4.1 // indirect github.com/prometheus/client_golang v1.12.2 // indirect github.com/prometheus/client_model v0.2.0 // indirect github.com/prometheus/common v0.32.1 // indirect diff --git a/examples/watchinstance/go.sum b/examples/watchinstance/go.sum index 093a5191..48997cc2 100644 --- a/examples/watchinstance/go.sum +++ b/examples/watchinstance/go.sum @@ -377,6 +377,7 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/polarismesh/specification v1.3.2-alpha.2 h1:cMghyvCnRVM5ca2kYCGHOgIIxVnokiMvw0720q8a8RA= github.com/polarismesh/specification v1.3.2-alpha.2/go.mod h1:rDvMMtl5qebPmqiBLNa5Ps0XtwkP31ZLirbH4kXA0YU= +github.com/polarismesh/specification v1.4.1/go.mod h1:rDvMMtl5qebPmqiBLNa5Ps0XtwkP31ZLirbH4kXA0YU= github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo= github.com/prometheus/client_golang v1.7.1/go.mod h1:PY5Wy2awLA44sXw4AOSfFBetzPP4j5+D6mVACh+pe2M= diff --git a/plugin/metrics/common/collector.go b/plugin/metrics/common/collector.go index 4ee7b825..3cbe08c0 100644 --- a/plugin/metrics/common/collector.go +++ b/plugin/metrics/common/collector.go @@ -114,6 +114,10 @@ type StatInfoRevisionCollector struct { currentRevision int64 } +func (src *StatInfoRevisionCollector) IncRevision() int64 { + return atomic.AddInt64(&src.currentRevision, 1) +} + func (src *StatInfoRevisionCollector) GetCurrentRevision() int64 { return atomic.LoadInt64(&src.currentRevision) } @@ -179,21 +183,26 @@ func PutDataFromContainerInOrder(metricVecCaches map[string]*prometheus.GaugeVec if !ok { continue } + canReport := true switch rs := metricValue.(type) { case *StatRevisionMetric: if rs.GetRevision() < currentRevision-RevisionMaxScope { // 如果连续两个版本还没有数据,就清除该数据 gauge.Delete(rs.GetLabels()) collector.RemoveStatMetric(rs.GetSignature()) + canReport = false continue } if rs.GetRevision() < currentRevision { // 如果版本为老版本,则清零数据 gauge.Delete(rs.GetLabels()) gauge.With(rs.GetLabels()).Set(0) + canReport = false continue } } - gauge.With(metricValue.GetLabels()).Set(float64(metricValue.GetValue())) + if canReport { + gauge.With(metricValue.GetLabels()).Set(float64(metricValue.GetValue())) + } } } diff --git a/plugin/metrics/prometheus/config.go b/plugin/metrics/prometheus/config.go index c2646af5..0d5c7221 100644 --- a/plugin/metrics/prometheus/config.go +++ b/plugin/metrics/prometheus/config.go @@ -54,7 +54,6 @@ func (c *Config) SetDefault() { } if c.PortStr == "" { c.port = defaultMetricPort - return } if c.Interval == 0 { c.Interval = 15 * time.Second diff --git a/plugin/metrics/prometheus/reporter.go b/plugin/metrics/prometheus/reporter.go index 7c019de1..193121c3 100644 --- a/plugin/metrics/prometheus/reporter.go +++ b/plugin/metrics/prometheus/reporter.go @@ -283,16 +283,19 @@ func (pa *PullAction) doAggregation(ctx context.Context) { action := func() { defer func() { if err := recover(); err != nil { - log.GetBaseLogger().Errorf("stat metrics prometheus panic", zap.Any("error", err)) + log.GetBaseLogger().Errorf("[metrics][pull] stat metrics prometheus panic", zap.Any("error", err)) } }() - log.GetBaseLogger().Infof("start aggregation stat metrics prometheus") + log.GetBaseLogger().Infof("[metrics][pull] start aggregation stat metrics prometheus") statcommon.PutDataFromContainerInOrder(pa.reporter.metricVecCaches, pa.reporter.insCollector, pa.reporter.insCollector.GetCurrentRevision()) statcommon.PutDataFromContainerInOrder(pa.reporter.metricVecCaches, pa.reporter.circuitBreakerCollector, 0) statcommon.PutDataFromContainerInOrder(pa.reporter.metricVecCaches, pa.reporter.rateLimitCollector, pa.reporter.rateLimitCollector.GetCurrentRevision()) + + log.GetBaseLogger().Debugf("[metrics][push] revision collector inc current revision to %d", pa.reporter.insCollector.IncRevision()) + log.GetBaseLogger().Debugf("[metrics][push] collector inc current revision to %d", pa.reporter.rateLimitCollector.IncRevision()) } for { @@ -313,7 +316,7 @@ func (pa *PullAction) Run(ctx context.Context) { go func() { ln, err := net.Listen("tcp", fmt.Sprintf("%s:%d", pa.bindIP, pa.bindPort)) if err != nil { - log.GetBaseLogger().Errorf("start metrics http-server fail: %v", err) + log.GetBaseLogger().Errorf("[metrics][push] start metrics http-server fail: %v", err) pa.bindPort = -1 return } @@ -323,9 +326,9 @@ func (pa *PullAction) Run(ctx context.Context) { handler: promhttp.HandlerFor(pa.reporter.registry, promhttp.HandlerOpts{}), } - log.GetBaseLogger().Infof("start metrics http-server address : %s", fmt.Sprintf("%s:%d", pa.bindIP, pa.bindPort)) + log.GetBaseLogger().Infof("[metrics][push] start metrics http-server address : %s", fmt.Sprintf("%s:%d", pa.bindIP, pa.bindPort)) if err := http.Serve(ln, &handler); err != nil { - log.GetBaseLogger().Errorf("start metrics http-server fail : %s", err) + log.GetBaseLogger().Errorf("[metrics][push] start metrics http-server fail : %s", err) return } }() @@ -365,11 +368,11 @@ func (pa *PushAction) Run(ctx context.Context) { action := func() { defer func() { if err := recover(); err != nil { - log.GetBaseLogger().Errorf("stat metrics prometheus panic", zap.Any("error", err)) + log.GetBaseLogger().Errorf("[metrics][push] stat metrics to pushgateway panic", zap.Any("error", err)) } }() - log.GetBaseLogger().Infof("start push stat metrics prometheus") + log.GetBaseLogger().Infof("[metrics][push] start push stat metrics to pushgateway") statcommon.PutDataFromContainerInOrder(pa.reporter.metricVecCaches, pa.reporter.insCollector, pa.reporter.insCollector.GetCurrentRevision()) @@ -382,7 +385,11 @@ func (pa *PushAction) Run(ctx context.Context) { Gatherer(pa.reporter.registry). Push(); err != nil { log.GetBaseLogger().Errorf("push metrics to pushgateway fail: %s", err.Error()) + return } + + log.GetBaseLogger().Debugf("[metrics][push] revision collector inc current revision to %d", pa.reporter.insCollector.IncRevision()) + log.GetBaseLogger().Debugf("[metrics][push] collector inc current revision to %d", pa.reporter.rateLimitCollector.IncRevision()) } for {