Skip to content

Commit

Permalink
fix(dialtesting): remove dataway label in metric dataway_send_failed_…
Browse files Browse the repository at this point in the history
…number
  • Loading branch information
zhengbo committed Sep 4, 2024
1 parent a2abd1e commit 4799184
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 18 deletions.
5 changes: 1 addition & 4 deletions internal/plugins/inputs/dialtesting/dialer.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,6 @@ func (d *dialer) getSendFailCount() int {
}

func (d *dialer) run() error {
var maskURL string

if err := d.task.Init(); err != nil {
l.Errorf(`task init error: %s`, err.Error())
return err
Expand Down Expand Up @@ -141,7 +139,6 @@ func (d *dialer) run() error {
if tokens, ok := params["token"]; ok {
// check token
if len(tokens) >= 1 {
maskURL = getMaskURL(parts.String())
if isValid, err := dialWorker.sender.checkToken(tokens[0], parts.Scheme, parts.Host); err != nil {
l.Warnf("check token error: %s", err.Error())
} else if !isValid {
Expand Down Expand Up @@ -170,7 +167,7 @@ func (d *dialer) run() error {

for {
failCount := d.getSendFailCount()
taskDatawaySendFailedGauge.WithLabelValues(d.regionName, d.class, maskURL).Set(float64(failCount))
taskDatawaySendFailedGauge.WithLabelValues(d.regionName, d.class).Set(float64(failCount))

// exceed max send fail count, sleep for MaxSendFailSleepTime
if failCount > MaxSendFailCount {
Expand Down
14 changes: 4 additions & 10 deletions internal/plugins/inputs/dialtesting/input.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import (
"net/url"
"path/filepath"
"reflect"
"regexp"
"strconv"
"strings"
"sync"
Expand All @@ -39,11 +38,10 @@ import (
)

var ( // type assertions
_ inputs.ReadEnv = (*Input)(nil)
_ inputs.InputV2 = (*Input)(nil)
g = datakit.G("inputs_dialtesting")
urlMaskRegexp = regexp.MustCompile(`(token=tkn_[\w\d]{6})([\w\d]+)([\w\d]{6})`)
dialWorker *worker
_ inputs.ReadEnv = (*Input)(nil)
_ inputs.InputV2 = (*Input)(nil)
g = datakit.G("inputs_dialtesting")
dialWorker *worker
)

var (
Expand Down Expand Up @@ -776,10 +774,6 @@ func (ipt *Input) stopAlltask() {
})
}

func getMaskURL(url string) string {
return urlMaskRegexp.ReplaceAllString(url, `${1}******${3}`)
}

func defaultInput() *Input {
return &Input{
Tags: map[string]string{},
Expand Down
7 changes: 3 additions & 4 deletions internal/plugins/inputs/dialtesting/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@
package dialtesting

import (
"github.com/prometheus/client_golang/prometheus"

"github.com/GuanceCloud/cliutils/metrics"
"github.com/prometheus/client_golang/prometheus"
)

var (
Expand Down Expand Up @@ -44,9 +43,9 @@ func metricsSetup() {
Namespace: "datakit",
Subsystem: "dialtesting",
Name: "dataway_send_failed_number",
Help: "The number of failed sending for each Dataway",
Help: "The number of failed sending",
},
[]string{"region", "protocol", "dataway"},
[]string{"region", "protocol"},
)

taskPullCostSummary = prometheus.NewSummaryVec(
Expand Down

0 comments on commit 4799184

Please sign in to comment.