Skip to content

Commit ac970cb

Browse files
committed
rename validation-regex -> blacklist-regex
1 parent c989287 commit ac970cb

File tree

12 files changed

+43
-43
lines changed

12 files changed

+43
-43
lines changed

carbon/app.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ func (app *App) Start() (err error) {
256256
receiver.DropPast(uint32(conf.Tcp.DropPast.Value().Seconds())),
257257
receiver.DropLongerThan(conf.Tcp.DropLongerThan),
258258
receiver.ReadTimeout(uint32(conf.Tcp.ReadTimeout.Value().Seconds())),
259-
receiver.ValidationRegex(conf.Common.ValidationRegex),
259+
receiver.BlacklistRegex(conf.Common.BlacklistRegex),
260260
)
261261

262262
if err != nil {
@@ -275,7 +275,7 @@ func (app *App) Start() (err error) {
275275
receiver.DropFuture(uint32(conf.Udp.DropFuture.Value().Seconds())),
276276
receiver.DropPast(uint32(conf.Udp.DropPast.Value().Seconds())),
277277
receiver.DropLongerThan(conf.Udp.DropLongerThan),
278-
receiver.ValidationRegex(conf.Common.ValidationRegex),
278+
receiver.BlacklistRegex(conf.Common.BlacklistRegex),
279279
)
280280

281281
if err != nil {
@@ -294,7 +294,7 @@ func (app *App) Start() (err error) {
294294
receiver.DropFuture(uint32(conf.Pickle.DropFuture.Value().Seconds())),
295295
receiver.DropPast(uint32(conf.Pickle.DropPast.Value().Seconds())),
296296
receiver.DropLongerThan(conf.Pickle.DropLongerThan),
297-
receiver.ValidationRegex(conf.Common.ValidationRegex),
297+
receiver.BlacklistRegex(conf.Common.BlacklistRegex),
298298
)
299299

300300
if err != nil {
@@ -312,7 +312,7 @@ func (app *App) Start() (err error) {
312312
receiver.DropFuture(uint32(conf.Grpc.DropFuture.Value().Seconds())),
313313
receiver.DropPast(uint32(conf.Grpc.DropPast.Value().Seconds())),
314314
receiver.DropLongerThan(conf.Grpc.DropLongerThan),
315-
receiver.ValidationRegex(conf.Common.ValidationRegex),
315+
receiver.BlacklistRegex(conf.Common.BlacklistRegex),
316316
)
317317

318318
if err != nil {
@@ -330,7 +330,7 @@ func (app *App) Start() (err error) {
330330
receiver.DropFuture(uint32(conf.Prometheus.DropFuture.Value().Seconds())),
331331
receiver.DropPast(uint32(conf.Prometheus.DropPast.Value().Seconds())),
332332
receiver.DropLongerThan(conf.Prometheus.DropLongerThan),
333-
receiver.ValidationRegex(conf.Common.ValidationRegex),
333+
receiver.BlacklistRegex(conf.Common.BlacklistRegex),
334334
)
335335

336336
if err != nil {
@@ -349,7 +349,7 @@ func (app *App) Start() (err error) {
349349
receiver.DropPast(uint32(conf.TelegrafHttpJson.DropPast.Value().Seconds())),
350350
receiver.DropLongerThan(conf.TelegrafHttpJson.DropLongerThan),
351351
receiver.ConcatChar(conf.TelegrafHttpJson.Concat),
352-
receiver.ValidationRegex(conf.Common.ValidationRegex),
352+
receiver.BlacklistRegex(conf.Common.BlacklistRegex),
353353
)
354354

355355
if err != nil {

carbon/config.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@ const (
2121
)
2222

2323
type commonConfig struct {
24-
MetricPrefix string `toml:"metric-prefix"`
25-
MetricInterval *config.Duration `toml:"metric-interval"`
26-
MetricEndpoint string `toml:"metric-endpoint"`
27-
MaxCPU int `toml:"max-cpu"`
28-
Enabled bool `toml:"enabled"`
29-
ValidationRegex string `toml:"validation-regex"`
24+
MetricPrefix string `toml:"metric-prefix"`
25+
MetricInterval *config.Duration `toml:"metric-interval"`
26+
MetricEndpoint string `toml:"metric-endpoint"`
27+
MaxCPU int `toml:"max-cpu"`
28+
Enabled bool `toml:"enabled"`
29+
BlacklistRegex string `toml:"blacklist-regex"`
3030
}
3131

3232
type clickhouseConfig struct {
@@ -281,9 +281,9 @@ func ReadConfig(filename string, exactConfig bool) (*Config, error) {
281281
}
282282
}
283283

284-
if cfg.Common.ValidationRegex != "" {
285-
if _, err := regexp.Compile(cfg.Common.ValidationRegex); err != nil {
286-
return nil, fmt.Errorf("invalid regex in validation-regex option: %s", err.Error())
284+
if cfg.Common.BlacklistRegex != "" {
285+
if _, err := regexp.Compile(cfg.Common.BlacklistRegex); err != nil {
286+
return nil, fmt.Errorf("invalid regex in blacklist-regex option: %s", err.Error())
287287
}
288288
}
289289

receiver/base.go

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,16 @@ const droppedListSize = 1000
1919
type Base struct {
2020
stop.Struct
2121
stat struct {
22-
samplesReceived uint64 // atomic
23-
messagesReceived uint64 // atomic
24-
metricsReceived uint64 // atomic
25-
errors uint64 // atomic
26-
active int64 // atomic
27-
incompleteReceived uint64 // atomic
28-
futureDropped uint64 // atomic
29-
pastDropped uint64 // atomic
30-
tooLongDropped uint64 // atomic
31-
validationRegexDropped uint64 // atomic
22+
samplesReceived uint64 // atomic
23+
messagesReceived uint64 // atomic
24+
metricsReceived uint64 // atomic
25+
errors uint64 // atomic
26+
active int64 // atomic
27+
incompleteReceived uint64 // atomic
28+
futureDropped uint64 // atomic
29+
pastDropped uint64 // atomic
30+
tooLongDropped uint64 // atomic
31+
blacklistRegexDropped uint64 // atomic
3232
}
3333
droppedList [droppedListSize]string
3434
droppedListNext int
@@ -38,7 +38,7 @@ type Base struct {
3838
dropPastSeconds uint32
3939
dropTooLongLimit uint16
4040
readTimeoutSeconds uint32
41-
validationRegex *regexp.Regexp
41+
blacklistRegex *regexp.Regexp
4242
writeChan chan *RowBinary.WriteBuffer
4343
logger *zap.Logger
4444
Tags tags.TagConfig
@@ -88,9 +88,9 @@ func (base *Base) isDropMetricNameTooLong(name string) bool {
8888
return false
8989
}
9090

91-
func (base *Base) isMatchedByValidationRegex(name []byte) bool {
92-
if base.validationRegex != nil && base.validationRegex.Match(name) {
93-
atomic.AddUint64(&base.stat.validationRegexDropped, 1)
91+
func (base *Base) isMatchedByBlacklistRegex(name []byte) bool {
92+
if base.blacklistRegex != nil && base.blacklistRegex.Match(name) {
93+
atomic.AddUint64(&base.stat.blacklistRegexDropped, 1)
9494
return true
9595
}
9696
return false
@@ -154,8 +154,8 @@ func (base *Base) SendStat(send func(metric string, value float64), fields ...st
154154
sendUint64Counter(send, f, &base.stat.pastDropped)
155155
case "tooLongDropped":
156156
sendUint64Counter(send, f, &base.stat.tooLongDropped)
157-
case "validationRegexDropped":
158-
sendUint64Counter(send, f, &base.stat.validationRegexDropped)
157+
case "blacklistRegexDropped":
158+
sendUint64Counter(send, f, &base.stat.blacklistRegexDropped)
159159
case "errors":
160160
sendUint64Counter(send, f, &base.stat.errors)
161161
case "active":

receiver/grpc.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ func (g *GRPC) Addr() net.Addr {
3232
}
3333

3434
func (g *GRPC) Stat(send func(metric string, value float64)) {
35-
g.SendStat(send, "metricsReceived", "errors", "futureDropped", "pastDropped", "tooLongDropped", "validationRegexDropped")
35+
g.SendStat(send, "metricsReceived", "errors", "futureDropped", "pastDropped", "tooLongDropped", "blacklistRegexDropped")
3636
}
3737

3838
// Listen bind port. Receive messages and send to out channel

receiver/pickle.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ func (rcv *Pickle) Addr() net.Addr {
3333

3434
func (rcv *Pickle) Stat(send func(metric string, value float64)) {
3535
rcv.SendStat(send, "metricsReceived", "messagesReceived", "errors", "active", "futureDropped", "pastDropped",
36-
"tooLongDropped", "validationRegexDropped")
36+
"tooLongDropped", "blacklistRegexDropped")
3737
}
3838

3939
func (rcv *Pickle) HandleConnection(conn net.Conn) {

receiver/plain.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,8 @@ func (base *Base) PlainParseLine(p []byte, now uint32, buf *tags.GraphiteBuf) ([
7070
i3--
7171
}
7272

73-
if base.isMatchedByValidationRegex(p[:i1]) {
74-
return nil, 0, 0, errors.New("metric name matched by validation regex: '" + unsafeString(p) + "'")
73+
if base.isMatchedByBlacklistRegex(p[:i1]) {
74+
return nil, 0, 0, errors.New("metric name matched by blacklist regex: '" + unsafeString(p) + "'")
7575
}
7676

7777
value, err := strconv.ParseFloat(unsafeString(p[i1+1:i2]), 64)

receiver/plain_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ func TestPlainParseLine(t *testing.T) {
309309
{"app:service:metric;env=prod:primary 42.15 1422642189\n", "app:service:metric?env=prod%3Aprimary", 42.15, 1422642189},
310310
}
311311

312-
baseWithValidation := &Base{validationRegex: regexp.MustCompile(`[^a-zA-Z0-9.;\-_:=]{1}`)}
312+
baseWithValidation := &Base{blacklistRegex: regexp.MustCompile(`[^a-zA-Z0-9.;\-_:=]{1}`)}
313313
for _, p := range tableWithValidation {
314314
name, value, timestamp, err := baseWithValidation.PlainParseLine([]byte(p.b), now, &tagBuf)
315315
if p.name == "" {

receiver/prometheus.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ func (rcv *PrometheusRemoteWrite) Addr() net.Addr {
199199
}
200200

201201
func (rcv *PrometheusRemoteWrite) Stat(send func(metric string, value float64)) {
202-
rcv.SendStat(send, "samplesReceived", "errors", "futureDropped", "pastDropped", "tooLongDropped", "validationRegexDropped")
202+
rcv.SendStat(send, "samplesReceived", "errors", "futureDropped", "pastDropped", "tooLongDropped", "blacklistRegexDropped")
203203
}
204204

205205
// Listen bind port. Receive messages and send to out channel

receiver/receiver.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,12 +91,12 @@ func ConcatChar(concat string) Option {
9191
}
9292
}
9393

94-
// ValidationRegex creates option for New constructor
95-
func ValidationRegex(regex string) Option {
94+
// BlacklistRegex creates option for New constructor
95+
func BlacklistRegex(regex string) Option {
9696
return func(r interface{}) error {
9797
if t, ok := r.(*Base); ok {
9898
if regex != "" {
99-
t.validationRegex = regexp.MustCompile(regex)
99+
t.blacklistRegex = regexp.MustCompile(regex)
100100
}
101101
}
102102
return nil

receiver/tcp.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ func (rcv *TCP) Addr() net.Addr {
2828
}
2929

3030
func (rcv *TCP) Stat(send func(metric string, value float64)) {
31-
rcv.SendStat(send, "metricsReceived", "errors", "active", "futureDropped", "pastDropped", "tooLongDropped", "validationRegexDropped")
31+
rcv.SendStat(send, "metricsReceived", "errors", "active", "futureDropped", "pastDropped", "tooLongDropped", "blacklistRegexDropped")
3232
}
3333

3434
func (rcv *TCP) HandleConnection(conn net.Conn) {

0 commit comments

Comments
 (0)