improve IAM module

Signed-off-by: hongming <talonwan@yunify.com>
This commit is contained in:
hongming
2020-05-22 09:35:05 +08:00
parent 0d12529051
commit 8f93266ec0
640 changed files with 50221 additions and 18179 deletions

View File

@@ -34,10 +34,8 @@ type Counter struct {
// However, the object returned will not measure anything unless the collector is first
// registered, since the metric is lazily instantiated.
func NewCounter(opts *CounterOpts) *Counter {
// todo: handle defaulting better
if opts.StabilityLevel == "" {
opts.StabilityLevel = ALPHA
}
opts.StabilityLevel.setDefaults()
kc := &Counter{
CounterOpts: opts,
lazyMetric: lazyMetric{},
@@ -86,10 +84,8 @@ type CounterVec struct {
// However, the object returned will not measure anything unless the collector is first
// registered, since the metric is lazily instantiated.
func NewCounterVec(opts *CounterOpts, labels []string) *CounterVec {
// todo: handle defaulting better
if opts.StabilityLevel == "" {
opts.StabilityLevel = ALPHA
}
opts.StabilityLevel.setDefaults()
cv := &CounterVec{
CounterVec: noopCounterVec,
CounterOpts: opts,
@@ -143,7 +139,7 @@ func (v *CounterVec) WithLabelValues(lvs ...string) CounterMetric {
// must match those of the VariableLabels in Desc). If that label map is
// accessed for the first time, a new Counter is created IFF the counterVec has
// been registered to a metrics registry.
func (v *CounterVec) With(labels prometheus.Labels) CounterMetric {
func (v *CounterVec) With(labels map[string]string) CounterMetric {
if !v.IsCreated() {
return noop // return no-op counter
}
@@ -157,9 +153,18 @@ func (v *CounterVec) With(labels prometheus.Labels) CounterMetric {
// with those of the VariableLabels in Desc. However, such inconsistent Labels
// can never match an actual metric, so the method will always return false in
// that case.
func (v *CounterVec) Delete(labels prometheus.Labels) bool {
func (v *CounterVec) Delete(labels map[string]string) bool {
if !v.IsCreated() {
return false // since we haven't created the metric, we haven't deleted a metric with the passed in values
}
return v.CounterVec.Delete(labels)
}
// Reset deletes all metrics in this vector.
func (v *CounterVec) Reset() {
if !v.IsCreated() {
return
}
v.CounterVec.Reset()
}