From e5e63e28879f83ec156eb54d0a29d04c2609faa5 Mon Sep 17 00:00:00 2001 From: Owen Cabalceta Date: Thu, 11 Jan 2024 15:36:27 -0500 Subject: [PATCH 01/13] chore: demo of validator metrics --- wrpvalidator/metrics.go | 28 ++++++++++++++++++++++ wrpvalidator/spec_validator.go | 29 +++++++++++++++++++--- wrpvalidator/spec_validator_test.go | 33 +++++++++++++++++++++++++ wrpvalidator/validator.go | 37 +++++++++++++++++++++++++++++ 4 files changed, 124 insertions(+), 3 deletions(-) create mode 100644 wrpvalidator/metrics.go diff --git a/wrpvalidator/metrics.go b/wrpvalidator/metrics.go new file mode 100644 index 0000000..6510364 --- /dev/null +++ b/wrpvalidator/metrics.go @@ -0,0 +1,28 @@ +// SPDX-FileCopyrightText: 2022 Comcast Cable Communications Management, LLC +// SPDX-License-Identifier: Apache-2.0 + +package wrpvalidator + +import ( + "github.com/prometheus/client_golang/prometheus" + "github.com/xmidt-org/touchstone" +) + +const ( + // MetricPrefix is prepended to all metrics exposed by this package. + metricPrefix = "wrp_" + + // utf8ValidatorName is the name of the counter for all UTF8 validation. + utf8ValidatorName = metricPrefix + "utf8_validator" + + // utf8ValidatorHelp is the help text for the UTF8 Validator metric. + utf8ValidatorHelp = "the total number of UTF8 Validator metric" +func NewUTF8ValidatorErrorTotal(f *touchstone.Factory, labelNames ...string) (m *prometheus.CounterVec, err error) { + return f.NewCounterVec( + prometheus.CounterOpts{ + Name: utf8ValidatorName, + Help: utf8ValidatorHelp, + }, + labelNames... + ) +} diff --git a/wrpvalidator/spec_validator.go b/wrpvalidator/spec_validator.go index 3cf12ef..886c4d6 100644 --- a/wrpvalidator/spec_validator.go +++ b/wrpvalidator/spec_validator.go @@ -12,7 +12,10 @@ import ( "unicode" "github.com/google/uuid" + "github.com/prometheus/client_golang/prometheus" + "github.com/xmidt-org/touchstone" "github.com/xmidt-org/wrp-go/v3" + "go.uber.org/multierr" ) const ( @@ -45,11 +48,31 @@ var locatorPattern = regexp.MustCompile( // SpecValidators validates the following fields: UTF8 (all string fields), MessageType, Source, Destination func SpecValidators() Validators { return Validators{}.AddFunc(UTF8Validator, MessageTypeValidator, SourceValidator, DestinationValidator) +func SpecValidatorsWithMetrics(f *touchstone.Factory, labelNames ...string) (Validators, error) { + var errs error + utf8, err := NewUTF8Validator(f, labelNames...) + if err != nil { + errs = multierr.Append(errs, err) + } + + return Validators{}.AddFuncWithMetrics(utf8), errs +} + +func NewUTF8Validator(f *touchstone.Factory, labelNames ...string) (ValidatorWithMetricsFunc, error) { + m, err := NewUTF8ValidatorErrorTotal(f, labelNames...) + return func(msg wrp.Message, ls prometheus.Labels) error { + err := UTF8Validator(msg) + if err != nil { + m.With(ls).Add(1.0) + } + + return err + }, err } // UTF8Validator takes messages and validates that it contains UTF-8 strings. func UTF8Validator(m wrp.Message) error { - if err := UTF8(m); err != nil { + if err := wrp.UTF8(m); err != nil { return fmt.Errorf("%w: %v", ErrorInvalidMessageEncoding, err) } @@ -58,12 +81,12 @@ func UTF8Validator(m wrp.Message) error { // MessageTypeValidator takes messages and validates their Type. func MessageTypeValidator(m wrp.Message) error { - if m.Type < Invalid0MessageType || m.Type > LastMessageType { + if m.Type < wrp.Invalid0MessageType || m.Type > wrp.LastMessageType { return ErrorInvalidMessageType } switch m.Type { - case Invalid0MessageType, Invalid1MessageType, LastMessageType: + case wrp.Invalid0MessageType, wrp.Invalid1MessageType, wrp.LastMessageType: return ErrorInvalidMessageType } diff --git a/wrpvalidator/spec_validator_test.go b/wrpvalidator/spec_validator_test.go index aca489f..cd084c6 100644 --- a/wrpvalidator/spec_validator_test.go +++ b/wrpvalidator/spec_validator_test.go @@ -7,7 +7,13 @@ import ( "fmt" "testing" + prometheus "command-line-arguments/Users/odc/go/pkg/mod/github.com/prometheus/client_golang@v1.11.1/prometheus/counter.go" + + "github.com/prometheus/client_golang/prometheus" "github.com/stretchr/testify/assert" + "github.com/xmidt-org/sallust" + "github.com/xmidt-org/touchstone" + "github.com/xmidt-org/wrp-go/v3" ) func TestSpecHelperValidators(t *testing.T) { @@ -186,6 +192,33 @@ func ExampleTypeValidator_Validate_specValidators() { // Output: false true true false } +func ExampleTypeValidator_Validate_specValidators() { + + cfg := touchstone.Config{ + DefaultNamespace: "n", + DefaultSubsystem: "s", + } + _, pr, err := touchstone.New(cfg) + f := touchstone.NewFactory(cfg, sallust.Default(), pr) + utf8ValidatorWithMetric, err := NewUTF8Validator(f, "sat_client_id", "foo") + + if err != nil { + return + } + + _ = utf8ValidatorWithMetric.ValidateWithMetrics(wrp.Message{}, prometheus.Labels{"sat_client_id": "123", "foo": "bar"}) + // for backwards compatibility and if the client doesn't want metrics for this validator + _ = utf8ValidatorWithMetric.Validate(wrp.Message{}) + + // using the version of UTF8Validator that has no metric middle ware + utf8ValidatorWithOutMetric := ValidatorFunc(UTF8Validator) + + _ = utf8ValidatorWithOutMetric.Validate(wrp.Message{}) + // the prometheus labels are ignoreed + _ = utf8ValidatorWithOutMetric.ValidateWithMetrics(wrp.Message{}, prometheus.Labels{"sat_client_id": "123", "foo": "bar"}) // Found error + +} + func testUTF8Validator(t *testing.T) { var ( expectedStatus int64 = 3471 diff --git a/wrpvalidator/validator.go b/wrpvalidator/validator.go index 9b123d6..d0003c5 100644 --- a/wrpvalidator/validator.go +++ b/wrpvalidator/validator.go @@ -7,6 +7,7 @@ import ( "errors" "strings" + "github.com/prometheus/client_golang/prometheus" "github.com/xmidt-org/wrp-go/v3" "go.uber.org/multierr" ) @@ -78,6 +79,7 @@ func NewValidatorError(err error, m string, f []string) ValidatorError { // Validator is a WRP validator that allows access to the Validate function. type Validator interface { Validate(m wrp.Message) error + ValidateWithMetrics(wrp.Message, prometheus.Labels) error } // Validators is a WRP validator that ensures messages are valid based on @@ -97,6 +99,17 @@ func (vs Validators) Validate(m wrp.Message) error { return err } +func (vs Validators) ValidateWithMetrics(m wrp.Message, ls prometheus.Labels) error { + var err error + for _, v := range vs { + if v != nil { + err = multierr.Append(err, v.ValidateWithMetrics(m, ls)) + } + } + + return err +} + // Add returns a new Validators with the appended Validator list func (vs Validators) Add(v ...Validator) Validators { for _, v := range v { @@ -119,6 +132,16 @@ func (vs Validators) AddFunc(vf ...ValidatorFunc) Validators { return vs } +func (vs Validators) AddFuncWithMetrics(vf ...ValidatorWithMetricsFunc) Validators { + for _, v := range vf { + if v != nil { + vs = append(vs, v) + } + } + + return vs +} + // ValidatorFunc is a WRP validator that takes messages and validates them // against functions. type ValidatorFunc func(wrp.Message) error @@ -126,6 +149,20 @@ type ValidatorFunc func(wrp.Message) error // Validate executes its own ValidatorFunc receiver and returns the result. func (vf ValidatorFunc) Validate(m wrp.Message) error { return vf(m) } +func (vf ValidatorFunc) ValidateWithMetrics(m wrp.Message, _ prometheus.Labels) error { + return vf(m) +} + +type ValidatorWithMetricsFunc func(wrp.Message, prometheus.Labels) error + +func (vf ValidatorWithMetricsFunc) Validate(m wrp.Message) error { + return vf(m, prometheus.Labels{}) +} + +func (vf ValidatorWithMetricsFunc) ValidateWithMetrics(m wrp.Message, ls prometheus.Labels) error { + return vf(m, ls) +} + // TypeValidator is a WRP validator that validates based on message type // or using the defaultValidator if message type is unfound. type TypeValidator struct { From ebf03693c2ada72811a22f78e97f8344c20716f6 Mon Sep 17 00:00:00 2001 From: Owen Cabalceta Date: Thu, 11 Jan 2024 15:38:25 -0500 Subject: [PATCH 02/13] chore: remove typo fix --- wrpvalidator/spec_validator.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/wrpvalidator/spec_validator.go b/wrpvalidator/spec_validator.go index 886c4d6..7da22ab 100644 --- a/wrpvalidator/spec_validator.go +++ b/wrpvalidator/spec_validator.go @@ -72,7 +72,7 @@ func NewUTF8Validator(f *touchstone.Factory, labelNames ...string) (ValidatorWit // UTF8Validator takes messages and validates that it contains UTF-8 strings. func UTF8Validator(m wrp.Message) error { - if err := wrp.UTF8(m); err != nil { + if err := UTF8(m); err != nil { return fmt.Errorf("%w: %v", ErrorInvalidMessageEncoding, err) } @@ -81,12 +81,12 @@ func UTF8Validator(m wrp.Message) error { // MessageTypeValidator takes messages and validates their Type. func MessageTypeValidator(m wrp.Message) error { - if m.Type < wrp.Invalid0MessageType || m.Type > wrp.LastMessageType { + if m.Type < Invalid0MessageType || m.Type > LastMessageType { return ErrorInvalidMessageType } switch m.Type { - case wrp.Invalid0MessageType, wrp.Invalid1MessageType, wrp.LastMessageType: + case wrp.Invalid0MessageType, Invalid1MessageType, LastMessageType: return ErrorInvalidMessageType } From 8fde9e7d68a1f45571b4377e78dda6e08c5578e4 Mon Sep 17 00:00:00 2001 From: Owen Cabalceta Date: Thu, 11 Jan 2024 15:39:07 -0500 Subject: [PATCH 03/13] chore: remove typo fix --- wrpvalidator/spec_validator.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wrpvalidator/spec_validator.go b/wrpvalidator/spec_validator.go index 7da22ab..a4586d6 100644 --- a/wrpvalidator/spec_validator.go +++ b/wrpvalidator/spec_validator.go @@ -86,7 +86,7 @@ func MessageTypeValidator(m wrp.Message) error { } switch m.Type { - case wrp.Invalid0MessageType, Invalid1MessageType, LastMessageType: + case Invalid0MessageType, Invalid1MessageType, LastMessageType: return ErrorInvalidMessageType } From 740dcd3972fa65b80b72edfa151fea31263f725a Mon Sep 17 00:00:00 2001 From: Owen Cabalceta Date: Thu, 11 Jan 2024 15:39:38 -0500 Subject: [PATCH 04/13] Update metrics.go --- wrpvalidator/metrics.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/wrpvalidator/metrics.go b/wrpvalidator/metrics.go index 6510364..40b21f3 100644 --- a/wrpvalidator/metrics.go +++ b/wrpvalidator/metrics.go @@ -17,6 +17,8 @@ const ( // utf8ValidatorHelp is the help text for the UTF8 Validator metric. utf8ValidatorHelp = "the total number of UTF8 Validator metric" +) + func NewUTF8ValidatorErrorTotal(f *touchstone.Factory, labelNames ...string) (m *prometheus.CounterVec, err error) { return f.NewCounterVec( prometheus.CounterOpts{ From a5c249f2670cb37949de2ed0c33849a7b549f0a1 Mon Sep 17 00:00:00 2001 From: Owen Cabalceta Date: Thu, 11 Jan 2024 15:40:39 -0500 Subject: [PATCH 05/13] Update spec_validator.go --- wrpvalidator/spec_validator.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/wrpvalidator/spec_validator.go b/wrpvalidator/spec_validator.go index a4586d6..f00c5a5 100644 --- a/wrpvalidator/spec_validator.go +++ b/wrpvalidator/spec_validator.go @@ -48,6 +48,8 @@ var locatorPattern = regexp.MustCompile( // SpecValidators validates the following fields: UTF8 (all string fields), MessageType, Source, Destination func SpecValidators() Validators { return Validators{}.AddFunc(UTF8Validator, MessageTypeValidator, SourceValidator, DestinationValidator) +} + func SpecValidatorsWithMetrics(f *touchstone.Factory, labelNames ...string) (Validators, error) { var errs error utf8, err := NewUTF8Validator(f, labelNames...) From 05228c0d474c387633ecb1ac64ed9a35a3473495 Mon Sep 17 00:00:00 2001 From: Owen Cabalceta Date: Thu, 11 Jan 2024 15:41:09 -0500 Subject: [PATCH 06/13] Update spec_validator_test.go --- wrpvalidator/spec_validator_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wrpvalidator/spec_validator_test.go b/wrpvalidator/spec_validator_test.go index cd084c6..c3a3f36 100644 --- a/wrpvalidator/spec_validator_test.go +++ b/wrpvalidator/spec_validator_test.go @@ -215,7 +215,7 @@ func ExampleTypeValidator_Validate_specValidators() { _ = utf8ValidatorWithOutMetric.Validate(wrp.Message{}) // the prometheus labels are ignoreed - _ = utf8ValidatorWithOutMetric.ValidateWithMetrics(wrp.Message{}, prometheus.Labels{"sat_client_id": "123", "foo": "bar"}) // Found error + _ = utf8ValidatorWithOutMetric.ValidateWithMetrics(wrp.Message{}, prometheus.Labels{"sat_client_id": "123", "foo": "bar"}) } From 27fe93251410c3c60612d975f3d864007e0a1888 Mon Sep 17 00:00:00 2001 From: Owen Cabalceta Date: Tue, 16 Jan 2024 12:50:58 -0500 Subject: [PATCH 07/13] Update spec_validator.go --- wrpvalidator/spec_validator.go | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/wrpvalidator/spec_validator.go b/wrpvalidator/spec_validator.go index f00c5a5..926e10c 100644 --- a/wrpvalidator/spec_validator.go +++ b/wrpvalidator/spec_validator.go @@ -46,11 +46,7 @@ var locatorPattern = regexp.MustCompile( // SpecValidators ensures messages are valid based on // each spec validator in the list. Only validates the opinionated portions of the spec. // SpecValidators validates the following fields: UTF8 (all string fields), MessageType, Source, Destination -func SpecValidators() Validators { - return Validators{}.AddFunc(UTF8Validator, MessageTypeValidator, SourceValidator, DestinationValidator) -} - -func SpecValidatorsWithMetrics(f *touchstone.Factory, labelNames ...string) (Validators, error) { +func SpecValidators(f *touchstone.Factory, labelNames ...string) (Validators, error) { var errs error utf8, err := NewUTF8Validator(f, labelNames...) if err != nil { From 8b5a187f28fedf278ab31e26b67f698345ec0a8b Mon Sep 17 00:00:00 2001 From: Owen Cabalceta Date: Tue, 16 Jan 2024 12:54:16 -0500 Subject: [PATCH 08/13] Update validator.go --- wrpvalidator/validator.go | 42 ++++++++------------------------------- 1 file changed, 8 insertions(+), 34 deletions(-) diff --git a/wrpvalidator/validator.go b/wrpvalidator/validator.go index d0003c5..169438d 100644 --- a/wrpvalidator/validator.go +++ b/wrpvalidator/validator.go @@ -78,8 +78,7 @@ func NewValidatorError(err error, m string, f []string) ValidatorError { // Validator is a WRP validator that allows access to the Validate function. type Validator interface { - Validate(m wrp.Message) error - ValidateWithMetrics(wrp.Message, prometheus.Labels) error + Validate(wrp.Message, prometheus.Labels) error } // Validators is a WRP validator that ensures messages are valid based on @@ -88,18 +87,7 @@ type Validators []Validator // Validate runs messages through each validator in the validators list. // It returns as soon as the message is considered invalid, otherwise returns nil if valid. -func (vs Validators) Validate(m wrp.Message) error { - var err error - for _, v := range vs { - if v != nil { - err = multierr.Append(err, v.Validate(m)) - } - } - - return err -} - -func (vs Validators) ValidateWithMetrics(m wrp.Message, ls prometheus.Labels) error { +func (vs Validators) Validate(m wrp.Message, ls prometheus.Labels) error { var err error for _, v := range vs { if v != nil { @@ -144,24 +132,10 @@ func (vs Validators) AddFuncWithMetrics(vf ...ValidatorWithMetricsFunc) Validato // ValidatorFunc is a WRP validator that takes messages and validates them // against functions. -type ValidatorFunc func(wrp.Message) error +type ValidatorFunc func(wrp.Message, prometheus.Labels) error // Validate executes its own ValidatorFunc receiver and returns the result. -func (vf ValidatorFunc) Validate(m wrp.Message) error { return vf(m) } - -func (vf ValidatorFunc) ValidateWithMetrics(m wrp.Message, _ prometheus.Labels) error { - return vf(m) -} - -type ValidatorWithMetricsFunc func(wrp.Message, prometheus.Labels) error - -func (vf ValidatorWithMetricsFunc) Validate(m wrp.Message) error { - return vf(m, prometheus.Labels{}) -} - -func (vf ValidatorWithMetricsFunc) ValidateWithMetrics(m wrp.Message, ls prometheus.Labels) error { - return vf(m, ls) -} +func (vf ValidatorFunc) Validate(m wrp.Message, ls prometheus.Labels) error { return vf(m, ls) } // TypeValidator is a WRP validator that validates based on message type // or using the defaultValidator if message type is unfound. @@ -172,13 +146,13 @@ type TypeValidator struct { // Validate validates messages based on message type or using the defaultValidator // if message type is unfound. -func (tv TypeValidator) Validate(msg Message) error { - vs := tv.m[msg.MessageType()] +func (tv TypeValidator) Validate(m wrp.Message, ls prometheus.Labels) error { + vs := tv.m[m.MessageType()] if vs == nil { - return tv.defaultValidator.Validate(msg) + return tv.defaultValidator.ValidateWithMetrics(m, ls) } - return vs.Validate(msg) + return vs.ValidateWithMetrics(m, ls) } // NewTypeValidator is a TypeValidator factory. From 5bc460a78a97ebf62a70ed5d73aba621199d3b06 Mon Sep 17 00:00:00 2001 From: Owen Cabalceta Date: Tue, 16 Jan 2024 12:54:43 -0500 Subject: [PATCH 09/13] Update validator.go --- wrpvalidator/validator.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/wrpvalidator/validator.go b/wrpvalidator/validator.go index 169438d..2cc55d8 100644 --- a/wrpvalidator/validator.go +++ b/wrpvalidator/validator.go @@ -149,10 +149,10 @@ type TypeValidator struct { func (tv TypeValidator) Validate(m wrp.Message, ls prometheus.Labels) error { vs := tv.m[m.MessageType()] if vs == nil { - return tv.defaultValidator.ValidateWithMetrics(m, ls) + return tv.defaultValidator.Validate(m, ls) } - return vs.ValidateWithMetrics(m, ls) + return vs.Validate(m, ls) } // NewTypeValidator is a TypeValidator factory. From 32da0abf6a5f8a24c7ea5728387ba449ace482fa Mon Sep 17 00:00:00 2001 From: Owen Cabalceta Date: Tue, 16 Jan 2024 12:55:13 -0500 Subject: [PATCH 10/13] Update validator.go --- wrpvalidator/validator.go | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/wrpvalidator/validator.go b/wrpvalidator/validator.go index 2cc55d8..216fad6 100644 --- a/wrpvalidator/validator.go +++ b/wrpvalidator/validator.go @@ -120,16 +120,6 @@ func (vs Validators) AddFunc(vf ...ValidatorFunc) Validators { return vs } -func (vs Validators) AddFuncWithMetrics(vf ...ValidatorWithMetricsFunc) Validators { - for _, v := range vf { - if v != nil { - vs = append(vs, v) - } - } - - return vs -} - // ValidatorFunc is a WRP validator that takes messages and validates them // against functions. type ValidatorFunc func(wrp.Message, prometheus.Labels) error From 88a15101871b8a39d0e23454b18f636cff7905ac Mon Sep 17 00:00:00 2001 From: Owen Cabalceta Date: Tue, 16 Jan 2024 12:56:02 -0500 Subject: [PATCH 11/13] Update validator.go --- wrpvalidator/validator.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wrpvalidator/validator.go b/wrpvalidator/validator.go index 216fad6..3e94cad 100644 --- a/wrpvalidator/validator.go +++ b/wrpvalidator/validator.go @@ -91,7 +91,7 @@ func (vs Validators) Validate(m wrp.Message, ls prometheus.Labels) error { var err error for _, v := range vs { if v != nil { - err = multierr.Append(err, v.ValidateWithMetrics(m, ls)) + err = multierr.Append(err, v.Validate(m, ls)) } } From 4df56f31331518fb22973a9733538b969337e27b Mon Sep 17 00:00:00 2001 From: Owen Cabalceta Date: Tue, 16 Jan 2024 12:57:57 -0500 Subject: [PATCH 12/13] Update spec_validator_test.go --- wrpvalidator/spec_validator_test.go | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/wrpvalidator/spec_validator_test.go b/wrpvalidator/spec_validator_test.go index c3a3f36..06ebab1 100644 --- a/wrpvalidator/spec_validator_test.go +++ b/wrpvalidator/spec_validator_test.go @@ -193,7 +193,6 @@ func ExampleTypeValidator_Validate_specValidators() { } func ExampleTypeValidator_Validate_specValidators() { - cfg := touchstone.Config{ DefaultNamespace: "n", DefaultSubsystem: "s", @@ -201,22 +200,11 @@ func ExampleTypeValidator_Validate_specValidators() { _, pr, err := touchstone.New(cfg) f := touchstone.NewFactory(cfg, sallust.Default(), pr) utf8ValidatorWithMetric, err := NewUTF8Validator(f, "sat_client_id", "foo") - if err != nil { return } - _ = utf8ValidatorWithMetric.ValidateWithMetrics(wrp.Message{}, prometheus.Labels{"sat_client_id": "123", "foo": "bar"}) - // for backwards compatibility and if the client doesn't want metrics for this validator - _ = utf8ValidatorWithMetric.Validate(wrp.Message{}) - - // using the version of UTF8Validator that has no metric middle ware - utf8ValidatorWithOutMetric := ValidatorFunc(UTF8Validator) - - _ = utf8ValidatorWithOutMetric.Validate(wrp.Message{}) - // the prometheus labels are ignoreed - _ = utf8ValidatorWithOutMetric.ValidateWithMetrics(wrp.Message{}, prometheus.Labels{"sat_client_id": "123", "foo": "bar"}) - + _ = utf8ValidatorWithMetric.Validate(wrp.Message{}, prometheus.Labels{"sat_client_id": "123", "foo": "bar"}) } func testUTF8Validator(t *testing.T) { From f1998ae92b0dee62fd0fd84060137e15b12355eb Mon Sep 17 00:00:00 2001 From: Owen Cabalceta Date: Tue, 16 Jan 2024 12:59:16 -0500 Subject: [PATCH 13/13] Update spec_validator.go --- wrpvalidator/spec_validator.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/wrpvalidator/spec_validator.go b/wrpvalidator/spec_validator.go index 926e10c..96d2ca7 100644 --- a/wrpvalidator/spec_validator.go +++ b/wrpvalidator/spec_validator.go @@ -53,10 +53,10 @@ func SpecValidators(f *touchstone.Factory, labelNames ...string) (Validators, er errs = multierr.Append(errs, err) } - return Validators{}.AddFuncWithMetrics(utf8), errs + return Validators{}.AddFunc(utf8), errs } -func NewUTF8Validator(f *touchstone.Factory, labelNames ...string) (ValidatorWithMetricsFunc, error) { +func NewUTF8Validator(f *touchstone.Factory, labelNames ...string) (ValidatorFunc, error) { m, err := NewUTF8ValidatorErrorTotal(f, labelNames...) return func(msg wrp.Message, ls prometheus.Labels) error { err := UTF8Validator(msg)