From 2b87c34f31879a9e87873da19cf6113f6db3295f Mon Sep 17 00:00:00 2001 From: kongfei Date: Wed, 19 Apr 2023 17:03:03 +0800 Subject: [PATCH] reformat code before release --- go.mod | 13 ++++++------- go.sum | 9 ++------- inputs/xskyapi/xskyapi.go | 29 ++++++++++++++--------------- traces/collector.go | 3 ++- traces/host.go | 5 +++-- traces/service.go | 7 ++++--- 6 files changed, 31 insertions(+), 35 deletions(-) diff --git a/go.mod b/go.mod index 00a16699..2d788b50 100644 --- a/go.mod +++ b/go.mod @@ -98,10 +98,8 @@ require ( github.com/jackc/pgproto3/v2 v2.3.1 // indirect github.com/jackc/pgservicefile v0.0.0-20200714003250-2b9c44734f2b // indirect github.com/jackc/pgtype v1.12.0 // indirect - github.com/open-telemetry/opentelemetry-collector-contrib/exporter/prometheusremotewriteexporter v0.54.0 // indirect github.com/open-telemetry/opentelemetry-collector-contrib/pkg/resourcetotelemetry v0.54.0 // indirect github.com/open-telemetry/opentelemetry-collector-contrib/pkg/translator/prometheusremotewrite v0.54.0 // indirect - github.com/open-telemetry/opentelemetry-collector-contrib/receiver/prometheusreceiver v0.54.0 // indirect github.com/rogpeppe/go-internal v1.8.1 // indirect github.com/tidwall/gjson v1.10.2 // indirect github.com/tidwall/match v1.1.1 // indirect @@ -122,6 +120,8 @@ require ( github.com/aws/aws-sdk-go-v2/service/cloudwatch v1.5.0 github.com/aws/aws-sdk-go-v2/service/sts v1.18.3 github.com/coreos/go-systemd/v22 v22.3.2 + github.com/open-telemetry/opentelemetry-collector-contrib/exporter/prometheusremotewriteexporter v0.54.0 + github.com/open-telemetry/opentelemetry-collector-contrib/receiver/prometheusreceiver v0.54.0 github.com/prometheus-community/pro-bing v0.1.0 github.com/vmware/govmomi v0.29.0 ) @@ -132,7 +132,6 @@ require ( cloud.google.com/go/compute v1.7.0 // indirect contrib.go.opencensus.io/exporter/prometheus v0.4.1 // indirect github.com/Azure/azure-sdk-for-go v65.0.0+incompatible // indirect - github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 // indirect github.com/Azure/go-autorest v14.2.0+incompatible // indirect github.com/Azure/go-autorest/autorest v0.11.27 // indirect github.com/Azure/go-autorest/autorest/adal v0.9.20 // indirect @@ -318,14 +317,14 @@ require ( github.com/xdg/stringprep v1.0.3 // indirect github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d // indirect github.com/yusufpapurcu/wmi v1.2.2 // indirect - go.opencensus.io v0.23.0 // indirect - go.opentelemetry.io/collector/pdata v0.54.0 // indirect + go.opencensus.io v0.23.0 + go.opentelemetry.io/collector/pdata v0.54.0 go.opentelemetry.io/collector/semconv v0.54.0 // indirect go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.32.0 // indirect go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.32.0 // indirect go.opentelemetry.io/otel v1.7.0 // indirect go.opentelemetry.io/otel/exporters/prometheus v0.30.0 // indirect - go.opentelemetry.io/otel/sdk v1.7.0 // indirect + go.opentelemetry.io/otel/sdk v1.7.0 go.opentelemetry.io/otel/sdk/metric v0.30.0 // indirect go.uber.org/atomic v1.9.0 // indirect go.uber.org/automaxprocs v1.5.1 // indirect @@ -340,7 +339,7 @@ require ( google.golang.org/api v0.86.0 // indirect google.golang.org/appengine v1.6.7 // indirect google.golang.org/genproto v0.0.0-20220628213854-d9e0b6570c03 // indirect - google.golang.org/grpc v1.47.0 // indirect + google.golang.org/grpc v1.47.0 google.golang.org/protobuf v1.28.1 // indirect gopkg.in/inf.v0 v0.9.1 // indirect gopkg.in/ini.v1 v1.66.4 // indirect diff --git a/go.sum b/go.sum index 6bc2accf..142fb898 100644 --- a/go.sum +++ b/go.sum @@ -69,7 +69,6 @@ github.com/Azure/azure-sdk-for-go/sdk/azcore v0.19.0/go.mod h1:h6H6c8enJmmocHUbL github.com/Azure/azure-sdk-for-go/sdk/azidentity v0.11.0/go.mod h1:HcM1YX14R7CJcghJGOYCgdezslRSVzqwLf/q+4Y2r/0= github.com/Azure/azure-sdk-for-go/sdk/internal v0.7.0/go.mod h1:yqy467j36fJxcRV2TzfVZ1pCb5vxm4BtZPUdYWe/Xo8= github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 h1:UQHMgLO+TxOElx5B5HZ4hJQsoJ/PvUvKRhJHDQXO8P8= -github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1/go.mod h1:xomTg63KZ2rFqZQzSB4Vz2SUXa1BpHTVz9L5PTmPC4E= github.com/Azure/go-autorest v14.2.0+incompatible h1:V5VMDjClD3GiElqLWO7mz2MxNAK/vTfRHdAubSIPRgs= github.com/Azure/go-autorest v14.2.0+incompatible/go.mod h1:r+4oMnoxhatjLLJ6zxSWATqVooLgysK6ZNox3g/xq24= github.com/Azure/go-autorest/autorest v0.11.18/go.mod h1:dSiJPy22c3u0OtOKDNttNgqpNFY/GeWa7GH/Pz56QRA= @@ -363,8 +362,6 @@ github.com/felixge/httpsnoop v1.0.3 h1:s/nj+GCswXYzN5v2DpNMuMQYe+0DDwt5WVCU6CWBd github.com/felixge/httpsnoop v1.0.3/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U= github.com/flashcatcloud/client_golang v1.12.2-0.20220704074148-3b31f0c90903 h1:CfWf8xXOpjs1G8xsE2ZAueqtPynok/pS5VHWhlwgRrg= github.com/flashcatcloud/client_golang v1.12.2-0.20220704074148-3b31f0c90903/go.mod h1:nDOYPpTKRWyFSHGWY5QbDUvjSMBusROfFzxhmDKUNWo= -github.com/flashcatcloud/opentelemetry-collector v0.54.1-0.20220628041301-3b8dabd1bcd0 h1:RUknqWUJ7dTtK5rZ602dqYZyDVJiYlY3a8Dep2zuLjU= -github.com/flashcatcloud/opentelemetry-collector v0.54.1-0.20220628041301-3b8dabd1bcd0/go.mod h1:FgNzyfb4sAGb5cqusB5znETJ8Pz4OQUBGbOeGIZ2rlQ= github.com/fogleman/gg v1.2.1-0.20190220221249-0403632d5b90/go.mod h1:R/bRT+9gY/C5z7JzPU0zXsXHKM4/ayA+zqcVNZzPa1k= github.com/form3tech-oss/jwt-go v3.2.2+incompatible/go.mod h1:pbq4aXjuKjdthFRnoDwaVPLA+WlJuPGy+QneDUgJi2k= github.com/form3tech-oss/jwt-go v3.2.3+incompatible/go.mod h1:pbq4aXjuKjdthFRnoDwaVPLA+WlJuPGy+QneDUgJi2k= @@ -674,7 +671,6 @@ github.com/hashicorp/consul/sdk v0.8.0 h1:OJtKBtEjboEZvG6AOUdh4Z1Zbyu0WcxQ0qatRr github.com/hashicorp/consul/sdk v0.8.0/go.mod h1:GBvyrGALthsZObzUGsfgHZQDXjg4lOjagTIwIR1vPms= github.com/hashicorp/cronexpr v1.1.1 h1:NJZDd87hGXjoZBdvyCF9mX4DCq5Wy7+A/w+A7q0wn6c= github.com/hashicorp/cronexpr v1.1.1/go.mod h1:P4wA0KBl9C5q2hABiMO7cp6jcIg96CDh1Efb3g1PWA4= -github.com/hashicorp/errwrap v1.0.0 h1:hLrqtEDnRye3+sgx6z4qVLNuviH3MR5aQ0ykNJa/UYA= github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= github.com/hashicorp/errwrap v1.1.0 h1:OxrOeh75EUXMY8TBjag2fzXGZ40LB6IKw45YeGUDY2I= github.com/hashicorp/errwrap v1.1.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= @@ -686,8 +682,6 @@ github.com/hashicorp/go-hclog v0.0.0-20180709165350-ff2cf002a8dd/go.mod h1:9bjs9 github.com/hashicorp/go-hclog v0.8.0/go.mod h1:5CU+agLiy3J7N7QjHK5d05KxGsuXiQLrjA0H7acj2lQ= github.com/hashicorp/go-hclog v0.9.2/go.mod h1:5CU+agLiy3J7N7QjHK5d05KxGsuXiQLrjA0H7acj2lQ= github.com/hashicorp/go-hclog v0.12.0/go.mod h1:whpDNt7SSdeAju8AWKIWsul05p54N/39EeqMAyrmvFQ= -github.com/hashicorp/go-hclog v1.2.0 h1:La19f8d7WIlm4ogzNHB0JGqs5AUDAZ2UfCY4sJXcJdM= -github.com/hashicorp/go-hclog v1.2.0/go.mod h1:whpDNt7SSdeAju8AWKIWsul05p54N/39EeqMAyrmvFQ= github.com/hashicorp/go-hclog v1.2.1 h1:YQsLlGDJgwhXFpucSPyVbCBviQtjlHv3jLTlp8YmtEw= github.com/hashicorp/go-hclog v1.2.1/go.mod h1:W4Qnvbt70Wk/zYJryRzDRU/4r0kIg0PVHBcfoyhpF5M= github.com/hashicorp/go-immutable-radix v1.0.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60= @@ -1045,6 +1039,8 @@ github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1y github.com/onsi/gomega v1.16.0/go.mod h1:HnhC7FXeEQY45zxNK3PPoIUhzk/80Xly9PcubAlGdZY= github.com/onsi/gomega v1.18.1 h1:M1GfJqGRrBrrGGsbxzV5dqM2U2ApXefZCQpkukxYRLE= github.com/op/go-logging v0.0.0-20160315200505-970db520ece7/go.mod h1:HzydrMdWErDVzsI23lYNej1Htcns9BCg93Dk0bBINWk= +github.com/open-telemetry/opentelemetry-collector v0.54.0 h1:Ib3aRVdlDhqy6FUcSP/ID1YoPnTnXKCP84g8HPM3Z9o= +github.com/open-telemetry/opentelemetry-collector v0.54.0/go.mod h1:FgNzyfb4sAGb5cqusB5znETJ8Pz4OQUBGbOeGIZ2rlQ= github.com/open-telemetry/opentelemetry-collector-contrib/exporter/alibabacloudlogserviceexporter v0.54.0 h1:bLOTsnh+ctD1n9jqQ1TgWba5NgHVA0H4ygCpK2dyqJk= github.com/open-telemetry/opentelemetry-collector-contrib/exporter/alibabacloudlogserviceexporter v0.54.0/go.mod h1:9k9/UPofhLdDvhNQwyPlpfe5TALtWD2NY5BzA2EDS2c= github.com/open-telemetry/opentelemetry-collector-contrib/exporter/jaegerexporter v0.54.0 h1:+Q4Mc0BzLKi79sDn3YL7hdzfr8Kk4HOCzJxpT9cx/Kw= @@ -1293,7 +1289,6 @@ github.com/tidwall/gjson v1.10.2 h1:APbLGOM0rrEkd8WBw9C24nllro4ajFuJu0Sc9hRz8Bo= github.com/tidwall/gjson v1.10.2/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA= github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM= -github.com/tidwall/pretty v1.0.0 h1:HsD+QiTn7sK6flMKIvNmpqz1qrpP3Ps6jOKIKMooyg4= github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk= github.com/tidwall/pretty v1.2.0 h1:RWIZEg2iJ8/g6fDDYzMpobmaoGh5OLl4AXtGUGPcqCs= github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU= diff --git a/inputs/xskyapi/xskyapi.go b/inputs/xskyapi/xskyapi.go index 0546e51f..2b5d8df0 100644 --- a/inputs/xskyapi/xskyapi.go +++ b/inputs/xskyapi/xskyapi.go @@ -3,10 +3,6 @@ package xskyapi import ( "bytes" "encoding/json" - "flashcat.cloud/categraf/config" - "flashcat.cloud/categraf/inputs" - "flashcat.cloud/categraf/pkg/tls" - "flashcat.cloud/categraf/types" "fmt" "io" "log" @@ -17,6 +13,11 @@ import ( "strings" "sync" "time" + + "flashcat.cloud/categraf/config" + "flashcat.cloud/categraf/inputs" + "flashcat.cloud/categraf/pkg/tls" + "flashcat.cloud/categraf/types" ) const inputName = "xskyapi" @@ -149,7 +150,7 @@ func (ins *Instance) gather(slist *types.SampleList, server string, token string // acquire quota data of 3 mainstream distributed storage service provided by Xsky switch ins.DssType { - case "oss": //object storage + case "oss": // object storage // oss users @@ -164,7 +165,7 @@ func (ins *Instance) gather(slist *types.SampleList, server string, token string er := json.Unmarshal(resp, &osUsers) if er != nil { - fmt.Printf("Parsing JSON string exception:%s\n", err) + log.Printf("Parsing JSON string exception:%s\n", err) } labels := map[string]string{"server": server} @@ -190,7 +191,7 @@ func (ins *Instance) gather(slist *types.SampleList, server string, token string err = json.Unmarshal(resp, &osBuckets) if err != nil { - fmt.Printf("Parsing JSON string exception:%s\n", err) + log.Printf("Parsing JSON string exception:%s\n", err) } labels = map[string]string{"server": server} @@ -221,7 +222,7 @@ func (ins *Instance) gather(slist *types.SampleList, server string, token string er := json.Unmarshal(resp, &dfsQuotas) if er != nil { - fmt.Printf("Parsing JSON string exception:%s\n", err) + log.Printf("Parsing JSON string exception:%s\n", err) } labels := map[string]string{"server": server} @@ -247,7 +248,7 @@ func (ins *Instance) gather(slist *types.SampleList, server string, token string err = json.Unmarshal(resp, &blockVolumes) if err != nil { - fmt.Printf("Parsing JSON string exception:%s\n", err) + log.Printf("Parsing JSON string exception:%s\n", err) } labels = map[string]string{"server": server} @@ -276,7 +277,7 @@ func (ins *Instance) gather(slist *types.SampleList, server string, token string er := json.Unmarshal(resp, &fsFolders) if er != nil { - fmt.Printf("Parsing JSON string exception:%s\n", err) + log.Printf("Parsing JSON string exception:%s\n", err) } labels := map[string]string{"server": server} @@ -302,12 +303,12 @@ func (ins *Instance) gather(slist *types.SampleList, server string, token string err = json.Unmarshal(resp, &blockVolumes) if err != nil { - fmt.Printf("Parsing JSON string exception:%s\n", err) + log.Printf("Parsing JSON string exception:%s\n", err) } labels = map[string]string{"server": server} fields = make(map[string]interface{}) - //log.Println("D! len(OsUsers):", len(osUsers.OsUser)) + // log.Println("D! len(OsUsers):", len(osUsers.OsUser)) for _, blockVolume := range blockVolumes.BlockVolume { labels["name"] = blockVolume.Name @@ -375,7 +376,6 @@ func (ins *Instance) sendRequest(serverURL string, token string) ([]byte, float6 } type osUser struct { - //Email string `json:"email"` ID int `json:"id"` Name string `json:"name"` Samples []struct { @@ -389,8 +389,7 @@ type OsUsers struct { } type osBucket struct { - ID int `json:"id"` - //MaxBuckets int `json:"max_buckets"` + ID int `json:"id"` Name string `json:"name"` Owner struct { ID int `json:"id"` diff --git a/traces/collector.go b/traces/collector.go index dc10c537..a0ddc48f 100644 --- a/traces/collector.go +++ b/traces/collector.go @@ -7,9 +7,10 @@ import ( "fmt" "log" + "go.opentelemetry.io/collector/component" + "flashcat.cloud/categraf/config" "flashcat.cloud/categraf/config/traces" - "go.opentelemetry.io/collector/component" ) // Collector simply wrapped the OpenTelemetry Collector, which means you can get a full support diff --git a/traces/host.go b/traces/host.go index 98e36136..e4681d45 100644 --- a/traces/host.go +++ b/traces/host.go @@ -3,10 +3,11 @@ package traces import ( - "flashcat.cloud/categraf/pkg/otel/extensions" - "flashcat.cloud/categraf/pkg/otel/pipelines" "go.opentelemetry.io/collector/component" "go.opentelemetry.io/collector/config" + + "flashcat.cloud/categraf/pkg/otel/extensions" + "flashcat.cloud/categraf/pkg/otel/pipelines" ) var _ component.Host = (*serviceHost)(nil) diff --git a/traces/service.go b/traces/service.go index 56eb2477..58197687 100644 --- a/traces/service.go +++ b/traces/service.go @@ -6,14 +6,15 @@ import ( "context" "fmt" - "flashcat.cloud/categraf/pkg/otel/extensions" - "flashcat.cloud/categraf/pkg/otel/pipelines" - "flashcat.cloud/categraf/pkg/otel/telemetrylogs" "go.opentelemetry.io/collector/component" "go.opentelemetry.io/collector/config" "go.opentelemetry.io/otel/metric/nonrecording" "go.opentelemetry.io/otel/trace" "go.uber.org/multierr" + + "flashcat.cloud/categraf/pkg/otel/extensions" + "flashcat.cloud/categraf/pkg/otel/pipelines" + "flashcat.cloud/categraf/pkg/otel/telemetrylogs" ) type service struct {