Skip to content

Commit

Permalink
feat: upgrade go agent to v2 (#4939)
Browse files Browse the repository at this point in the history
* feat: upgrade go agent to v2

go.elastic.co/apm v1 has been deprecated for a while. Update the dependency
to v2.

* lint: reorder imports to fix linter issues

* build: run go mod tidy

* lint: remove duplicate go.mod lines

* lint: keep go.elastic.co/apm version unchanged
  • Loading branch information
kruskall authored Jul 9, 2024
1 parent f49e1d8 commit d19603b
Show file tree
Hide file tree
Showing 25 changed files with 78 additions and 294 deletions.
251 changes: 20 additions & 231 deletions NOTICE.txt

Large diffs are not rendered by default.

10 changes: 4 additions & 6 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,9 @@ require (
github.com/stretchr/testify v1.9.0
github.com/tsg/go-daemon v0.0.0-20200207173439-e704b93fd89b
github.com/winlabs/gowin32 v0.0.0-20221003142512-0d265587d3c9
go.elastic.co/apm/module/apmgorilla v1.15.0
go.elastic.co/apm/module/apmgorilla/v2 v2.6.0
go.elastic.co/apm/module/apmgrpc/v2 v2.6.0
go.elastic.co/apm/v2 v2.6.0
go.elastic.co/ecszap v1.0.2
go.elastic.co/go-licence-detector v0.6.0
go.uber.org/zap v1.27.0
Expand Down Expand Up @@ -255,10 +257,9 @@ require (
github.com/tklauser/numcpus v0.6.1 // indirect
github.com/valyala/fastjson v1.6.4 // indirect
github.com/yusufpapurcu/wmi v1.2.4 // indirect
go.elastic.co/apm/module/apmhttp v1.15.0 // indirect
go.elastic.co/apm v1.15.0 // indirect
go.elastic.co/apm/module/apmhttp/v2 v2.6.0 // indirect
go.elastic.co/apm/module/apmzap/v2 v2.6.0 // indirect
go.elastic.co/apm/v2 v2.6.0 // indirect
go.elastic.co/fastjson v1.3.0 // indirect
go.etcd.io/bbolt v1.3.10 // indirect
go.opencensus.io v0.24.0 // indirect
Expand Down Expand Up @@ -306,7 +307,6 @@ require (
gonum.org/v1/gonum v0.15.0 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20240520151616-dc85e6b867a5 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240624140628-dc46fd24d27d // indirect
google.golang.org/grpc/examples v0.0.0-20220304170021-431ea809a767 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect
howett.net/plist v1.0.1 // indirect
Expand All @@ -320,8 +320,6 @@ require (
require (
github.com/hashicorp/go-version v1.7.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect; indirecthttps://github.com/elastic/ingest-dev/issues/3253
go.elastic.co/apm v1.15.0
go.elastic.co/apm/module/apmgrpc v1.15.0
k8s.io/klog/v2 v2.110.1 // indirect
)

Expand Down
20 changes: 6 additions & 14 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1167,10 +1167,8 @@ github.com/googleapis/gnostic v0.5.5/go.mod h1:7+EbHbldMins07ALC74bsA81Ovc97Dwqy
github.com/googleapis/go-type-adapters v1.0.0/go.mod h1:zHW75FOG2aur7gAO2B+MLby+cLsWGBF62rFAi7WjWO4=
github.com/googleapis/google-cloud-go-testing v0.0.0-20200911160855-bcd43fbb19e8/go.mod h1:dvDLG8qkwmyD9a/MJJN3XJcT3xFxOKAvTZGvuZmac9g=
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
github.com/gorilla/context v1.1.1/go.mod h1:kBGZzfjB9CEq2AlWe17Uuf7NDRt0dE0s8S51q0aT7Yg=
github.com/gorilla/handlers v0.0.0-20150720190736-60c7bfde3e33/go.mod h1:Qkdc/uu4tH4g6mTK6auzZ766c4CA0Ng8+o/OAirnOIQ=
github.com/gorilla/handlers v1.5.1/go.mod h1:t8XrUpc4KVXb7HGyJ4/cEnwQiaxrX/hz1Zv/4g96P1Q=
github.com/gorilla/mux v1.6.2/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs=
github.com/gorilla/mux v1.7.2/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs=
github.com/gorilla/mux v1.7.3/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs=
github.com/gorilla/mux v1.8.0 h1:i40aqfkR1h2SlN9hojwV5ZA91wcXFOvkdNIeFDP5koI=
Expand Down Expand Up @@ -2022,13 +2020,11 @@ go.elastic.co/apm/module/apmelasticsearch v1.10.0 h1:5Vq4uDpoS6kfTTBuNrEd3KJ4kwv
go.elastic.co/apm/module/apmelasticsearch v1.10.0/go.mod h1:lwoaGDfZzfb9e6TXd3h8/KNmLAONOas7o5NLVNmv8Xk=
go.elastic.co/apm/module/apmelasticsearch/v2 v2.6.0 h1:ukMcwyMaDXsS1dRK2qRYXT2AsfwaUy74TOOYCqkWJow=
go.elastic.co/apm/module/apmelasticsearch/v2 v2.6.0/go.mod h1:YpfiTTrqX5LB/CKBwX89oDCBAxuLJTFv40gcfxJyehM=
go.elastic.co/apm/module/apmgorilla v1.15.0 h1:1yTAksffgaFXYEIwlLRiQnxLfy3p3RtpDw8HDupIJfY=
go.elastic.co/apm/module/apmgorilla v1.15.0/go.mod h1:+23mZudYvZ9VgxCQjseLo9EF5gkKEr0KSQBupw+rzP8=
go.elastic.co/apm/module/apmgrpc v1.15.0 h1:Z7h58uuMJUoYXK6INFunlcGEXZQ18QKAhPh6NFYDNHE=
go.elastic.co/apm/module/apmgrpc v1.15.0/go.mod h1:IEbTGJzY5Xx737PkHDT3bbzh9syovK+IfAlckJsUgPE=
go.elastic.co/apm/module/apmgorilla/v2 v2.6.0 h1:vXMZPNFss4a9146sIuT4zxQemVpQjNUDIIS9RMOr9PE=
go.elastic.co/apm/module/apmgorilla/v2 v2.6.0/go.mod h1:w3/W4oDZPWBye0McuIpM7d5xSQ1WoFnMmgmEIzCsxIk=
go.elastic.co/apm/module/apmgrpc/v2 v2.6.0 h1:0HPYGtjjS6wUE/f7Pw7L4R7IvgptGlXY8qMKFifFZj0=
go.elastic.co/apm/module/apmgrpc/v2 v2.6.0/go.mod h1:96P3OJkfJe3ZzkCHmFofu5VOWa4CAPRWyUiCt4NgWkk=
go.elastic.co/apm/module/apmhttp v1.10.0/go.mod h1:Y4timwcJ8sQWbWpcw3Y7Mat1OssNpGhpwyfUnpqIDew=
go.elastic.co/apm/module/apmhttp v1.15.0 h1:Le/DhI0Cqpr9wG/NIGOkbz7+rOMqJrfE4MRG6q/+leU=
go.elastic.co/apm/module/apmhttp v1.15.0/go.mod h1:NruY6Jq8ALLzWUVUQ7t4wIzn+onKoiP5woJJdTV7GMg=
go.elastic.co/apm/module/apmhttp/v2 v2.6.0 h1:s8UeNFQmVBCNd4eoz7KDD9rEFhQC0HeUFXz3z9gpAmQ=
go.elastic.co/apm/module/apmhttp/v2 v2.6.0/go.mod h1:D0GLppLuI0Ddwvtl595GUxRgn6Z8L5KaDFVMv2H3GK0=
go.elastic.co/apm/module/apmzap/v2 v2.6.0 h1:R/iVORzGu3F9uM43iEVHD0nwiRo59O0bIXdayKsgayQ=
Expand Down Expand Up @@ -2709,7 +2705,6 @@ golang.org/x/time v0.3.0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/time v0.5.0 h1:o7cqy6amK/52YcAKIPlM3a+Fpj35zvRj2TP+e1xFSfk=
golang.org/x/time v0.5.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM=
golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20180828015842-6cd1fcedba52/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20181011042414-1f849cf54d09/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20181030221726-6c7e314b6563/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
Expand Down Expand Up @@ -2898,7 +2893,6 @@ google.golang.org/genproto v0.0.0-20200527145253-8367513e4ece/go.mod h1:jDfRM7Fc
google.golang.org/genproto v0.0.0-20200618031413-b414f8b61790/go.mod h1:jDfRM7FcilCzHH/e9qn6dsT145K34l5v+OpcnNgKAAA=
google.golang.org/genproto v0.0.0-20200729003335-053ba62fc06f/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
google.golang.org/genproto v0.0.0-20200804131852-c06518451d9c/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
google.golang.org/genproto v0.0.0-20200806141610-86f49bd18e98/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
google.golang.org/genproto v0.0.0-20200825200019-8632dd797987/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
google.golang.org/genproto v0.0.0-20200904004341-0bd0a958aa1d/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
google.golang.org/genproto v0.0.0-20201019141844-1ed22bb0c154/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
Expand Down Expand Up @@ -2989,7 +2983,6 @@ google.golang.org/genproto/googleapis/api v0.0.0-20240520151616-dc85e6b867a5/go.
google.golang.org/genproto/googleapis/rpc v0.0.0-20240624140628-dc46fd24d27d h1:k3zyW3BYYR30e8v3x0bTDdE9vpYFjZHK+HcyqkrppWk=
google.golang.org/genproto/googleapis/rpc v0.0.0-20240624140628-dc46fd24d27d/go.mod h1:Ue6ibwXGpU+dqIcODieyLOcgj7z8+IcskoNIgZxtrFY=
google.golang.org/grpc v0.0.0-20160317175043-d3ddb4469d5a/go.mod h1:yo6s7OP7yaDglbqo1J04qKzAhqBH6lvTonzMVmEdcZw=
google.golang.org/grpc v1.17.0/go.mod h1:6QZJwpn2B+Zp71q/5VxRsJ6NXXVCE5NRUHRo+f3cWCs=
google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38=
google.golang.org/grpc v1.21.0/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM=
Expand Down Expand Up @@ -3036,8 +3029,8 @@ google.golang.org/grpc v1.52.0/go.mod h1:pu6fVzoFb+NBYNAvQL08ic+lvB2IojljRYuun5v
google.golang.org/grpc v1.64.0 h1:KH3VH9y/MgNQg1dE7b3XfVK0GsPSIzJwdF617gUSbvY=
google.golang.org/grpc v1.64.0/go.mod h1:oxjF8E3FBnjp+/gVFYdWacaLDx9na1aqy9oovLpxQYg=
google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.1.0/go.mod h1:6Kw0yEErY5E/yWrBtf03jp27GLLJujG4z/JK95pnjjw=
google.golang.org/grpc/examples v0.0.0-20220304170021-431ea809a767 h1:r16FSFCMhn7+LU8CzbtAIKppYeU6NUPJVdvXeIqVIq8=
google.golang.org/grpc/examples v0.0.0-20220304170021-431ea809a767/go.mod h1:wKDg0brwMZpaizQ1i7IzYcJjH1TmbJudYdnQC9+J+LE=
google.golang.org/grpc/examples v0.0.0-20230831183909-e498bbc9bd37 h1:kNDwMX0e15RGrBh4L1jfhVxyddRi6J/y8Gg+dcZr+S8=
google.golang.org/grpc/examples v0.0.0-20230831183909-e498bbc9bd37/go.mod h1:GGFp5xqHkVYOZBc9//ZnLinno7HB6j97fG1nL3au94o=
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0=
google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM=
Expand Down Expand Up @@ -3120,7 +3113,6 @@ gotest.tools/v3 v3.4.0/go.mod h1:CtbdzLSsqVhDgMtKsx03ird5YTGB3ar27v0u/yKBW5g=
gotest.tools/v3 v3.5.1 h1:EENdUnS3pdur5nybKYIh2Vfgc8IUNBjxDPSjtiJcOzU=
gotest.tools/v3 v3.5.1/go.mod h1:isy3WKz7GK6uNw/sbHzfKBLvlvXwUyV06n6brMxxopU=
helm.sh/helm/v3 v3.11.2/go.mod h1:Hw+09mfpDiRRKAgAIZlFkPSeOkvv7Acl5McBvQyNPVw=
honnef.co/go/tools v0.0.0-20180728063816-88497007e858/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
Expand Down
2 changes: 1 addition & 1 deletion internal/pkg/agent/application/application.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
"github.com/elastic/elastic-agent/pkg/limits"
"github.com/elastic/elastic-agent/version"

"go.elastic.co/apm"
"go.elastic.co/apm/v2"

"github.com/elastic/elastic-agent-libs/logp"

Expand Down
2 changes: 1 addition & 1 deletion internal/pkg/agent/application/coordinator/coordinator.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (

"github.com/hashicorp/go-multierror"

"go.elastic.co/apm"
"go.elastic.co/apm/v2"
"gopkg.in/yaml.v2"

"github.com/elastic/elastic-agent-client/v7/pkg/client"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

"go.elastic.co/apm/apmtest"
"go.elastic.co/apm/v2/apmtest"

"github.com/elastic/elastic-agent-libs/logp"

Expand Down
2 changes: 1 addition & 1 deletion internal/pkg/agent/application/dispatcher/dispatcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"strings"
"time"

"go.elastic.co/apm"
"go.elastic.co/apm/v2"

"github.com/elastic/elastic-agent/internal/pkg/agent/application/actions"
"github.com/elastic/elastic-agent/internal/pkg/agent/application/upgrade/details"
Expand Down
4 changes: 2 additions & 2 deletions internal/pkg/agent/application/monitoring/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import (
"strings"

"github.com/gorilla/mux"
"go.elastic.co/apm"
"go.elastic.co/apm/module/apmgorilla"
"go.elastic.co/apm/module/apmgorilla/v2"
"go.elastic.co/apm/v2"

"github.com/elastic/elastic-agent-libs/api"
"github.com/elastic/elastic-agent-libs/monitoring"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"context"

"github.com/hashicorp/go-multierror"
"go.elastic.co/apm"
"go.elastic.co/apm/v2"

"github.com/elastic/elastic-agent/internal/pkg/agent/application/upgrade/artifact"
"github.com/elastic/elastic-agent/internal/pkg/agent/application/upgrade/artifact/download"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"os"
"path/filepath"

"go.elastic.co/apm"
"go.elastic.co/apm/v2"

"github.com/elastic/elastic-agent/internal/pkg/agent/application/paths"
"github.com/elastic/elastic-agent/internal/pkg/agent/application/upgrade/artifact"
Expand Down
2 changes: 1 addition & 1 deletion internal/pkg/agent/application/upgrade/step_download.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (

"github.com/cenkalti/backoff/v4"

"go.elastic.co/apm"
"go.elastic.co/apm/v2"

"github.com/elastic/elastic-agent/internal/pkg/agent/application/paths"
"github.com/elastic/elastic-agent/internal/pkg/agent/application/upgrade/artifact"
Expand Down
2 changes: 1 addition & 1 deletion internal/pkg/agent/application/upgrade/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (
"time"

"github.com/otiai10/copy"
"go.elastic.co/apm"
"go.elastic.co/apm/v2"

"github.com/elastic/elastic-agent/internal/pkg/agent/application/info"
"github.com/elastic/elastic-agent/internal/pkg/agent/application/paths"
Expand Down
2 changes: 1 addition & 1 deletion internal/pkg/agent/cmd/enroll_cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
"strings"
"time"

"go.elastic.co/apm"
"go.elastic.co/apm/v2"
"gopkg.in/yaml.v2"

"github.com/elastic/elastic-agent-libs/transport/httpcommon"
Expand Down
22 changes: 12 additions & 10 deletions internal/pkg/agent/cmd/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ import (
"syscall"
"time"

"go.elastic.co/apm"
apmtransport "go.elastic.co/apm/transport"
"go.elastic.co/apm/v2"
apmtransport "go.elastic.co/apm/v2/transport"
"gopkg.in/yaml.v2"

"github.com/spf13/cobra"
Expand Down Expand Up @@ -595,7 +595,7 @@ func tryDelayEnroll(ctx context.Context, logger *logger.Logger, cfg *configurati
}

func initTracer(agentName, version string, mcfg *monitoringCfg.MonitoringConfig) (*apm.Tracer, error) {
apm.DefaultTracer.Close()
apm.DefaultTracer().Close()

if !mcfg.Enabled || !mcfg.MonitorTraces {
return nil, nil
Expand Down Expand Up @@ -625,10 +625,7 @@ func initTracer(agentName, version string, mcfg *monitoringCfg.MonitoringConfig)
defer os.Unsetenv(envCACert)
}

ts, err := apmtransport.NewHTTPTransport()
if err != nil {
return nil, err
}
opts := apmtransport.HTTPTransportOptions{}

if len(cfg.Hosts) > 0 {
hosts := make([]*url.URL, 0, len(cfg.Hosts))
Expand All @@ -639,12 +636,17 @@ func initTracer(agentName, version string, mcfg *monitoringCfg.MonitoringConfig)
}
hosts = append(hosts, u)
}
ts.SetServerURL(hosts...)
opts.ServerURLs = hosts
}
if cfg.APIKey != "" {
ts.SetAPIKey(cfg.APIKey)
opts.APIKey = cfg.APIKey
} else {
ts.SetSecretToken(cfg.SecretToken)
opts.SecretToken = cfg.SecretToken
}

ts, err := apmtransport.NewHTTPTransport(opts)
if err != nil {
return nil, err
}

return apm.NewTracerOptions(apm.TracerOptions{
Expand Down
2 changes: 1 addition & 1 deletion internal/pkg/basecmd/version/cmd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"go.elastic.co/apm/apmtest"
"go.elastic.co/apm/v2/apmtest"
"gopkg.in/yaml.v2"

"github.com/elastic/elastic-agent-libs/logp"
Expand Down
2 changes: 1 addition & 1 deletion internal/pkg/fleetapi/ack_cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"fmt"
"io"

"go.elastic.co/apm"
"go.elastic.co/apm/v2"

"github.com/elastic/elastic-agent/internal/pkg/agent/errors"
"github.com/elastic/elastic-agent/internal/pkg/fleetapi/client"
Expand Down
2 changes: 1 addition & 1 deletion internal/pkg/fleetapi/acker/fleet/fleet_acker.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"strings"
"time"

"go.elastic.co/apm"
"go.elastic.co/apm/v2"

"github.com/elastic/elastic-agent/internal/pkg/agent/errors"
"github.com/elastic/elastic-agent/internal/pkg/fleetapi"
Expand Down
2 changes: 1 addition & 1 deletion internal/pkg/fleetapi/acker/lazy/lazy_acker.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"context"
"net/http"

"go.elastic.co/apm"
"go.elastic.co/apm/v2"

"github.com/elastic/elastic-agent/internal/pkg/fleetapi"
"github.com/elastic/elastic-agent/pkg/core/logger"
Expand Down
23 changes: 13 additions & 10 deletions pkg/component/fake/component/comp/apm.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ import (
"github.com/elastic/elastic-agent-client/v7/pkg/client"
"github.com/elastic/elastic-agent-client/v7/pkg/proto"

"go.elastic.co/apm"
apmtransport "go.elastic.co/apm/transport"
"go.elastic.co/apm/v2"
apmtransport "go.elastic.co/apm/v2/transport"

"github.com/elastic/elastic-agent/internal/pkg/agent/errors"
)
Expand Down Expand Up @@ -133,10 +133,7 @@ func (ats *apmTracesSender) createNewTracer(cfg *proto.APMConfig) (*apm.Tracer,
defer os.Unsetenv(envGlobalLabels)
}

ts, err := apmtransport.NewHTTPTransport()
if err != nil {
return nil, err
}
opts := apmtransport.HTTPTransportOptions{}

if len(cfg.Elastic.Hosts) > 0 {
hosts := make([]*url.URL, 0, len(cfg.Elastic.Hosts))
Expand All @@ -147,13 +144,19 @@ func (ats *apmTracesSender) createNewTracer(cfg *proto.APMConfig) (*apm.Tracer,
}
hosts = append(hosts, u)
}
ts.SetServerURL(hosts...)
opts.ServerURLs = hosts
}
if cfg.Elastic.ApiKey != "" {
ts.SetAPIKey(cfg.Elastic.ApiKey)
opts.APIKey = cfg.Elastic.ApiKey
} else if cfg.Elastic.SecretToken != "" {
ts.SetSecretToken(cfg.Elastic.SecretToken)
opts.SecretToken = cfg.Elastic.SecretToken
}

ts, err := apmtransport.NewHTTPTransport(opts)
if err != nil {
return nil, err
}

return apm.NewTracerOptions(apm.TracerOptions{
ServiceName: "fake-apm",
ServiceVersion: "0.1",
Expand Down Expand Up @@ -204,7 +207,7 @@ func newFakeAPMInput(logger zerolog.Logger, logLevel client.UnitLogLevel, unit *
logger = logger.Level(toZerologLevel(logLevel))

// close the default tracer to avoid unnecessary logs
apm.DefaultTracer.Close()
apm.DefaultTracer().Close()

apmInput := &fakeAPMInput{
logger: logger,
Expand Down
4 changes: 2 additions & 2 deletions pkg/component/runtime/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ import (
"time"

"github.com/gofrs/uuid"
"go.elastic.co/apm"
"go.elastic.co/apm/module/apmgrpc"
"go.elastic.co/apm/module/apmgrpc/v2"
"go.elastic.co/apm/v2"
"google.golang.org/grpc"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/credentials"
Expand Down
2 changes: 1 addition & 1 deletion pkg/component/runtime/manager_fake_input_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/stretchr/testify/suite"
"go.elastic.co/apm/apmtest"
"go.elastic.co/apm/v2/apmtest"

"github.com/elastic/elastic-agent-client/v7/pkg/client"
"github.com/elastic/elastic-agent-client/v7/pkg/proto"
Expand Down
2 changes: 1 addition & 1 deletion pkg/component/runtime/manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
"time"

"github.com/stretchr/testify/require"
"go.elastic.co/apm/apmtest"
"go.elastic.co/apm/v2/apmtest"

"github.com/elastic/elastic-agent-client/v7/pkg/client"
"github.com/elastic/elastic-agent-libs/logp"
Expand Down
2 changes: 1 addition & 1 deletion pkg/control/v1/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"github.com/elastic/elastic-agent/pkg/control/v1/proto"
v2proto "github.com/elastic/elastic-agent/pkg/control/v2/cproto"

"go.elastic.co/apm"
"go.elastic.co/apm/v2"

"github.com/elastic/elastic-agent/internal/pkg/release"
"github.com/elastic/elastic-agent/pkg/core/logger"
Expand Down
2 changes: 1 addition & 1 deletion pkg/control/v2/control_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"github.com/elastic/elastic-agent/pkg/control/v2/client"
"github.com/elastic/elastic-agent/pkg/control/v2/server"

"go.elastic.co/apm/apmtest"
"go.elastic.co/apm/v2/apmtest"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
Expand Down
Loading

0 comments on commit d19603b

Please sign in to comment.