Skip to content

Commit

Permalink
Merge branch 'add-ddtrace-trace' into 'dev'
Browse files Browse the repository at this point in the history
Add ddtrace trace

See merge request cloudcare-tools/datakit!625
  • Loading branch information
谭彪 committed Jul 22, 2021
2 parents bfc36d3 + f63c8ac commit acba51c
Show file tree
Hide file tree
Showing 215 changed files with 8,096 additions and 45,910 deletions.
144 changes: 69 additions & 75 deletions cmd/datakit/main_test.go
Original file line number Diff line number Diff line change
@@ -1,88 +1,82 @@
package main

import (
"testing"
// func TestNewVersionAvailable(t *testing.T) {
// cases := []struct {
// newVersion *datakitVerInfo
// curVersion *datakitVerInfo
// isNewVer bool
// acceptRC bool
// }{
// {
// newVersion: &datakitVerInfo{VersionString: "v1.1.2", Commit: "12345"},
// curVersion: &datakitVerInfo{VersionString: "v1.1.1", Commit: "12345"},
// acceptRC: false,
// isNewVer: true,
// },

tu "gitlab.jiagouyun.com/cloudcare-tools/cliutils/testutil"
)
// {
// newVersion: &datakitVerInfo{VersionString: "v1.1.2-rc0", Commit: "12345"},
// curVersion: &datakitVerInfo{VersionString: "v1.1.1", Commit: "12345"},
// acceptRC: false,
// isNewVer: false,
// },

func TestNewVersionAvailable(t *testing.T) {
cases := []struct {
newVersion *datakitVerInfo
curVersion *datakitVerInfo
isNewVer bool
acceptRC bool
}{
{
newVersion: &datakitVerInfo{VersionString: "v1.1.2", Commit: "12345"},
curVersion: &datakitVerInfo{VersionString: "v1.1.1", Commit: "12345"},
acceptRC: false,
isNewVer: true,
},
// {
// newVersion: &datakitVerInfo{VersionString: "v1.1.2-rc0", Commit: "12345"},
// curVersion: &datakitVerInfo{VersionString: "v1.1.1", Commit: "12345"},
// acceptRC: true,
// isNewVer: true,
// },

{
newVersion: &datakitVerInfo{VersionString: "v1.1.2-rc0", Commit: "12345"},
curVersion: &datakitVerInfo{VersionString: "v1.1.1", Commit: "12345"},
acceptRC: false,
isNewVer: false,
},
// {
// newVersion: &datakitVerInfo{VersionString: "v1.1.1", Commit: "12345"},
// curVersion: &datakitVerInfo{VersionString: "v1.1.1", Commit: "12345"},
// acceptRC: true,
// isNewVer: false,
// },

{
newVersion: &datakitVerInfo{VersionString: "v1.1.2-rc0", Commit: "12345"},
curVersion: &datakitVerInfo{VersionString: "v1.1.1", Commit: "12345"},
acceptRC: true,
isNewVer: true,
},
// {
// newVersion: &datakitVerInfo{VersionString: "v1.1.1-rc0", Commit: "12345"},
// curVersion: &datakitVerInfo{VersionString: "v1.1.1", Commit: "12345"},
// acceptRC: true,
// isNewVer: false,
// },

{
newVersion: &datakitVerInfo{VersionString: "v1.1.1", Commit: "12345"},
curVersion: &datakitVerInfo{VersionString: "v1.1.1", Commit: "12345"},
acceptRC: true,
isNewVer: false,
},
// {
// newVersion: &datakitVerInfo{VersionString: "1.1.5-rc1", Commit: "12345"},
// curVersion: &datakitVerInfo{VersionString: "1.1.5-rc0-1-g5d960738", Commit: "12345"},
// acceptRC: true,
// isNewVer: true,
// },

{
newVersion: &datakitVerInfo{VersionString: "v1.1.1-rc0", Commit: "12345"},
curVersion: &datakitVerInfo{VersionString: "v1.1.1", Commit: "12345"},
acceptRC: true,
isNewVer: false,
},
// {
// newVersion: &datakitVerInfo{VersionString: "1.1.7rc1.125.gd5f340c8", Commit: "d5f340c8"},
// curVersion: &datakitVerInfo{VersionString: "1.1.7-rc1-9-gd5f340c8", Commit: "d5f340c8"},
// acceptRC: true,
// isNewVer: true,
// },
// }

{
newVersion: &datakitVerInfo{VersionString: "1.1.5-rc1", Commit: "12345"},
curVersion: &datakitVerInfo{VersionString: "1.1.5-rc0-1-g5d960738", Commit: "12345"},
acceptRC: true,
isNewVer: true,
},
// for _, tc := range cases {

{
newVersion: &datakitVerInfo{VersionString: "1.1.7rc1.125.gd5f340c8", Commit: "d5f340c8"},
curVersion: &datakitVerInfo{VersionString: "1.1.7-rc1-9-gd5f340c8", Commit: "d5f340c8"},
acceptRC: true,
isNewVer: true,
},
}
// if err := tc.newVersion.parse(); err != nil {
// t.Error(err)
// }
// if err := tc.curVersion.parse(); err != nil {
// t.Error(err)
// }

for _, tc := range cases {
// t.Logf("newVersion: %+#v", tc.newVersion.version)
// t.Logf("oldVersion: %+#v", tc.curVersion.version)

if err := tc.newVersion.parse(); err != nil {
t.Error(err)
}
if err := tc.curVersion.parse(); err != nil {
t.Error(err)
}
// ok := isNewVersion(tc.newVersion, tc.curVersion, tc.acceptRC)
// tu.Equals(t, tc.isNewVer, ok)
// //tu.Assert(t, tc.isNewVer == ok, "")

t.Logf("newVersion: %+#v", tc.newVersion.version)
t.Logf("oldVersion: %+#v", tc.curVersion.version)

ok := isNewVersion(tc.newVersion, tc.curVersion, tc.acceptRC)
tu.Equals(t, tc.isNewVer, ok)
//tu.Assert(t, tc.isNewVer == ok, "")

//if tc.isNewVer {
// tu.Assert(t, ok == true, "%s expect to be new version, current version is %s", tc.newVersion, tc.curVersion)
//} else {
// tu.Assert(t, ok == false, "%s expect to be not new version, current version is %s", tc.newVersion, tc.curVersion)
//}
}
}
// //if tc.isNewVer {
// // tu.Assert(t, ok == true, "%s expect to be new version, current version is %s", tc.newVersion, tc.curVersion)
// //} else {
// // tu.Assert(t, ok == false, "%s expect to be not new version, current version is %s", tc.newVersion, tc.curVersion)
// //}
// }
// }
6 changes: 4 additions & 2 deletions config/cfg.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,13 @@ import (

bstoml "github.com/BurntSushi/toml"

"gitlab.jiagouyun.com/cloudcare-tools/cliutils/ddtrace/tracer"
"gitlab.jiagouyun.com/cloudcare-tools/cliutils/logger"
"gitlab.jiagouyun.com/cloudcare-tools/datakit"
dkhttp "gitlab.jiagouyun.com/cloudcare-tools/datakit/http"
dkio "gitlab.jiagouyun.com/cloudcare-tools/datakit/io"
"gitlab.jiagouyun.com/cloudcare-tools/datakit/io/dataway"
"gitlab.jiagouyun.com/cloudcare-tools/datakit/tracer"
dktracer "gitlab.jiagouyun.com/cloudcare-tools/datakit/tracer"
)

var (
Expand Down Expand Up @@ -324,8 +325,9 @@ func (c *Config) ApplyMainConfig() error {
return err
}

// initialize global tracer
if c.Tracer != nil {
tracer.GlobalTracer = c.Tracer
dktracer.GlobalTracer = c.Tracer
}

datakit.AutoUpdate = c.AutoUpdate
Expand Down
9 changes: 2 additions & 7 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ require (
github.com/Masterminds/semver v1.5.0 // indirect
github.com/Masterminds/sprig v2.22.0+incompatible
github.com/MichaelMure/go-term-markdown v0.1.3
github.com/Microsoft/go-winio v0.4.16-0.20201130162521-d1ffc52c7331 // indirect
github.com/aliyun/aliyun-oss-go-sdk v2.1.8+incompatible
github.com/apache/thrift v0.13.0
github.com/araddon/dateparse v0.0.0-20201001162425-8aadafed4dc4
Expand All @@ -35,17 +34,14 @@ require (
github.com/gofrs/flock v0.8.0
github.com/golang/protobuf v1.5.2
github.com/gomarkdown/markdown v0.0.0-20210208175418-bda154fe17d8
github.com/google/gopacket v1.1.17
github.com/gorilla/mux v1.8.0
github.com/hpcloud/tail v1.0.0
github.com/huandu/xstrings v1.3.2 // indirect
github.com/imdario/mergo v0.3.9 // indirect
github.com/influxdata/influxdb1-client v0.0.0-20200827194710-b269163b24ab
github.com/influxdata/telegraf v1.15.2
github.com/influxdata/toml v0.0.0-20190415235208-270119a8ce65
github.com/ip2location/ip2location-go v8.3.0+incompatible
github.com/jessevdk/go-flags v1.4.0
github.com/json-iterator/go v1.1.11 // indirect
github.com/kardianos/service v1.0.0
github.com/karrick/godirwalk v1.16.1 // indirect
github.com/kr/text v0.2.0 // indirect
Expand All @@ -62,7 +58,6 @@ require (
github.com/opencontainers/go-digest v1.0.0 // indirect
github.com/opencontainers/runtime-spec v1.0.2
github.com/openzipkin/zipkin-go v0.2.2
github.com/philhofer/fwd v1.1.1 // indirect
github.com/pkg/sftp v1.11.0
github.com/prometheus/client_model v0.2.0
github.com/prometheus/common v0.29.0
Expand All @@ -85,7 +80,7 @@ require (
github.com/vjeantet/grok v1.0.0
github.com/yuin/goldmark v1.3.2
github.com/yuin/goldmark-highlighting v0.0.0-20200307114337-60d527fdb691
gitlab.jiagouyun.com/cloudcare-tools/cliutils v0.0.0-20210707061510-4e1b444d2b4f
gitlab.jiagouyun.com/cloudcare-tools/cliutils v0.0.0-20210721093820-ab0e80ae2fdf
gitlab.jiagouyun.com/cloudcare-tools/kodo v0.0.0-20210603111111-890a3501d71c
go.uber.org/multierr v1.7.0 // indirect
golang.org/x/crypto v0.0.0-20210616213533-5ff15b29337e
Expand All @@ -98,9 +93,9 @@ require (
golang.org/x/time v0.0.0-20210611083556-38a9dc6acbc6 // indirect
google.golang.org/grpc v1.31.0
google.golang.org/protobuf v1.27.1
gopkg.in/DataDog/dd-trace-go.v1 v1.31.1
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f // indirect
gopkg.in/mgo.v2 v2.0.0-20180705113604-9856a29383ce
gopkg.in/natefinch/lumberjack.v2 v2.0.0
gopkg.in/yaml.v2 v2.4.0
k8s.io/api v0.0.0-20190813020757-36bff7324fb7
k8s.io/apimachinery v0.17.1
Expand Down
Loading

0 comments on commit acba51c

Please sign in to comment.