change: replace uuid lib

This commit is contained in:
debugtalk
2022-10-24 00:28:13 +08:00
parent b288a1945a
commit d518def919
4 changed files with 7 additions and 9 deletions

View File

@@ -9,12 +9,12 @@ import (
"sync"
"time"
"github.com/google/uuid"
"github.com/olekukonko/tablewriter"
"github.com/pkg/errors"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/push"
"github.com/rs/zerolog/log"
uuid "github.com/satori/go.uuid"
"github.com/httprunner/httprunner/v4/hrp/internal/json"
)
@@ -461,10 +461,9 @@ var (
// NewPrometheusPusherOutput returns a PrometheusPusherOutput.
func NewPrometheusPusherOutput(gatewayURL, jobName string, mode string) *PrometheusPusherOutput {
nodeUUID, _ := uuid.NewUUID()
return &PrometheusPusherOutput{
pusher: push.New(gatewayURL, jobName).
Grouping("instance", nodeUUID.String()).
Grouping("instance", uuid.NewV1().String()).
Grouping("mode", mode),
}
}

View File

@@ -10,8 +10,8 @@ import (
"strings"
"time"
"github.com/google/uuid"
"github.com/rs/zerolog/log"
uuid "github.com/satori/go.uuid"
"github.com/shirou/gopsutil/cpu"
"github.com/shirou/gopsutil/mem"
"github.com/shirou/gopsutil/process"
@@ -84,7 +84,7 @@ func startCPUProfile(file string, duration time.Duration) (err error) {
// generate a random nodeID like locust does, using the same algorithm.
func getNodeID() (nodeID string) {
hostname, _ := os.Hostname()
id := strings.Replace(uuid.New().String(), "-", "", -1)
id := strings.Replace(uuid.NewV4().String(), "-", "", -1)
nodeID = fmt.Sprintf("%s_%s", hostname, id)
return
}