change: replace uuid lib

This commit is contained in:
debugtalk
2022-10-24 10:52:57 +08:00
parent b205e99ffb
commit e3912f219d
4 changed files with 7 additions and 9 deletions
+1 -1
View File
@@ -10,7 +10,6 @@ require (
github.com/go-openapi/spec v0.20.7 github.com/go-openapi/spec v0.20.7
github.com/go-ping/ping v1.1.0 github.com/go-ping/ping v1.1.0
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510
github.com/google/uuid v1.3.0
github.com/gorilla/websocket v1.5.0 github.com/gorilla/websocket v1.5.0
github.com/httprunner/funplugin v0.5.0 github.com/httprunner/funplugin v0.5.0
github.com/jinzhu/copier v0.3.5 github.com/jinzhu/copier v0.3.5
@@ -49,6 +48,7 @@ require (
github.com/go-openapi/jsonreference v0.20.0 // indirect github.com/go-openapi/jsonreference v0.20.0 // indirect
github.com/go-openapi/swag v0.22.3 // indirect github.com/go-openapi/swag v0.22.3 // indirect
github.com/golang/protobuf v1.5.2 // indirect github.com/golang/protobuf v1.5.2 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/hashicorp/go-hclog v1.3.0 // indirect github.com/hashicorp/go-hclog v1.3.0 // indirect
github.com/hashicorp/go-plugin v1.4.5 // indirect github.com/hashicorp/go-plugin v1.4.5 // indirect
github.com/hashicorp/yamux v0.1.1 // indirect github.com/hashicorp/yamux v0.1.1 // indirect
+2 -3
View File
@@ -5,8 +5,8 @@ import (
"github.com/denisbrodbeck/machineid" "github.com/denisbrodbeck/machineid"
"github.com/getsentry/sentry-go" "github.com/getsentry/sentry-go"
"github.com/google/uuid"
"github.com/rs/zerolog/log" "github.com/rs/zerolog/log"
uuid "github.com/satori/go.uuid"
"github.com/httprunner/httprunner/v4/hrp/internal/env" "github.com/httprunner/httprunner/v4/hrp/internal/env"
"github.com/httprunner/httprunner/v4/hrp/internal/version" "github.com/httprunner/httprunner/v4/hrp/internal/version"
@@ -23,8 +23,7 @@ func init() {
// init GA client // init GA client
clientID, err := machineid.ProtectedID("hrp") clientID, err := machineid.ProtectedID("hrp")
if err != nil { if err != nil {
nodeUUID, _ := uuid.NewUUID() clientID = uuid.NewV1().String()
clientID = nodeUUID.String()
} }
gaClient = NewGAClient(trackingID, clientID) gaClient = NewGAClient(trackingID, clientID)
+2 -3
View File
@@ -9,12 +9,12 @@ import (
"sync" "sync"
"time" "time"
"github.com/google/uuid"
"github.com/olekukonko/tablewriter" "github.com/olekukonko/tablewriter"
"github.com/pkg/errors" "github.com/pkg/errors"
"github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/push" "github.com/prometheus/client_golang/prometheus/push"
"github.com/rs/zerolog/log" "github.com/rs/zerolog/log"
uuid "github.com/satori/go.uuid"
"github.com/httprunner/httprunner/v4/hrp/internal/json" "github.com/httprunner/httprunner/v4/hrp/internal/json"
) )
@@ -461,10 +461,9 @@ var (
// NewPrometheusPusherOutput returns a PrometheusPusherOutput. // NewPrometheusPusherOutput returns a PrometheusPusherOutput.
func NewPrometheusPusherOutput(gatewayURL, jobName string, mode string) *PrometheusPusherOutput { func NewPrometheusPusherOutput(gatewayURL, jobName string, mode string) *PrometheusPusherOutput {
nodeUUID, _ := uuid.NewUUID()
return &PrometheusPusherOutput{ return &PrometheusPusherOutput{
pusher: push.New(gatewayURL, jobName). pusher: push.New(gatewayURL, jobName).
Grouping("instance", nodeUUID.String()). Grouping("instance", uuid.NewV1().String()).
Grouping("mode", mode), Grouping("mode", mode),
} }
} }
+2 -2
View File
@@ -10,8 +10,8 @@ import (
"strings" "strings"
"time" "time"
"github.com/google/uuid"
"github.com/rs/zerolog/log" "github.com/rs/zerolog/log"
uuid "github.com/satori/go.uuid"
"github.com/shirou/gopsutil/cpu" "github.com/shirou/gopsutil/cpu"
"github.com/shirou/gopsutil/mem" "github.com/shirou/gopsutil/mem"
"github.com/shirou/gopsutil/process" "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. // generate a random nodeID like locust does, using the same algorithm.
func getNodeID() (nodeID string) { func getNodeID() (nodeID string) {
hostname, _ := os.Hostname() hostname, _ := os.Hostname()
id := strings.Replace(uuid.New().String(), "-", "", -1) id := strings.Replace(uuid.NewV4().String(), "-", "", -1)
nodeID = fmt.Sprintf("%s_%s", hostname, id) nodeID = fmt.Sprintf("%s_%s", hostname, id)
return return
} }